Repository navigation
Fixes MSSQL bulkInsertQuery when options and attributes are not passed - #6782
Conversation
|
Pinging @mickhansen @janmeier |
Current coverage is 94.50% (diff: 100%)
|
|
Was only MSSQL affected by this bug? |
|
@felixfbecker Yes, Since MSSQL has its own bulkInsertQuery |
| // special case for empty objects with primary keys | ||
| var fields = Object.keys(attrValueHash); | ||
| if (fields.length === 1 && attributes[fields[0]].autoIncrement && attrValueHash[fields[0]] === null) { | ||
| if (fields.length === 1 && attributes[fields[0]] && attributes[fields[0]].autoIncrement && attrValueHash[fields[0]] === null) { |
There was a problem hiding this comment.
This statement has gone a bit complex now. Please extract attributes[fields[0]] as a variable (firstAttr) so we can simplify the checks. May be we can get rid of null check from end as well
There was a problem hiding this comment.
@sushantdhiman The null check at the end is required. Tests seem to fail.
The null check condition generates the following query if true
INSERT INTO [Workers] DEFAULT VALUES;
MSSQL also allows autogenerated fields to be set explicitly by toggling the IDENTITY_INSERT value.
Eg query from test:
SET IDENTITY_INSERT [Workers] ON; INSERT INTO [Workers] ([id]) VALUES (5),(10); SET IDENTITY_INSERT [Workers] OFF;
|
👍 |
|
@janmeier Thanks for the merge. I need this patch in my project. Should i submit another PR to the v3 branch for it to get released? |
|
Yup, you can do a backport |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?Description of change
When the queryInterface bulkInsert is used with MSSQL dialect in the sequelize cli seed phase,
queryInterface.bulkInsertinternally callsQueryGenerator.bulkInsertQueryand is a separate function in case of MSSQL.PR Changes: