Skip to content

fix(bulk-create): field field name mapping for postgres for upsertKeys - #11662

Closed
arinhouck wants to merge 1 commit into
sequelize:masterfrom
arinhouck:bulk-create-attr-fix
Closed

arinhouck wants to merge 1 commit into
sequelize:masterfrom
arinhouck:bulk-create-attr-fix

Conversation

@arinhouck

@arinhouck arinhouck commented Nov 9, 2019 •

Copy link
Copy Markdown

Pull Request check-list

Please make sure to review and check all of these items:

  • [ x ] Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • [ x ] Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • [x ] Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

bulkCreate on field/attributes that are defined in postgres that have a "pretty name" is not parametrizing query with the field attribute.

Similar issue in MSQL #9016 and realized it was an quick fix. Didn't see any tests in this area, so let me know if that is required.

From defined model

externalId: {
        type: DataTypes.TEXT,
        allowNull: true,
        comment: "null",
        unique: true,
        field: "external_id"
      },

Query contains

CONFLICT ("externalId") DO UPDATE SET "name"=EXCLUDED."name" RETURNING *;

Code executed

db.Location.bulkCreate(payload, {
      updateOnDuplicate: ["name"]
    });

Dialect: postgres
Database version: 10.7
Sequelize version: 5.2.21

@codecov

codecov Bot commented Nov 9, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #11662 into master will increase coverage by 3.79%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11662      +/-   ##
==========================================
+ Coverage   92.47%   96.26%   +3.79%     
==========================================
  Files          91       94       +3     
  Lines        8903     9190     +287     
==========================================
+ Hits         8233     8847     +614     
+ Misses        670      343     -327
Impacted Files Coverage Δ
lib/model.js 96.54% <100%> (ø) ⬆️
lib/dialects/sqlite/index.js 100% <0%> (ø)
lib/dialects/sqlite/query.js 98.65% <0%> (ø)
lib/dialects/sqlite/connection-manager.js 100% <0%> (ø)
lib/data-types.js 91.34% <0%> (+0.34%) ⬆️
lib/dialects/abstract/query-generator.js 97.01% <0%> (+0.51%) ⬆️
lib/dialects/abstract/query.js 91.98% <0%> (+0.96%) ⬆️
lib/sequelize.js 95.93% <0%> (+1.25%) ⬆️
lib/transaction.js 100% <0%> (+2.66%) ⬆️
lib/query-interface.js 92.19% <0%> (+3.41%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbef15f...3b260b0. Read the comment docs.

@huned

huned commented Nov 12, 2019

Copy link
Copy Markdown
Contributor

See also #11665

@dsdavis4

Copy link
Copy Markdown

Any status on this or #11665 being merged?

@sushantdhiman

Copy link
Copy Markdown
Contributor

Fixed by #11666

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants