You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MSSQL: Upsert does not accept primary keys with a value of 0 or false. #11902
I expected that a row would be inserted also when the boolean part of the primary key was false.
What is actually happening?
An error is thrown. Message: Unique key should be passed to upsert query
Additional context
I think that the bug is in the file sequelize/lib/dialects/mssql/query-generator.js in the following code fragment (I have marked the bug with a comment):
//Filter NULL Clausesconstclauses=where[Op.or].filter(clause=>{letvalid=true;/* * Exclude NULL Composite PK/UK. Partial Composite clauses should also be excluded as it doesn't guarantee a single row */for(constkeyinclause){if(!clause[key]){/// ===> Bug: Should be 'if (clause != null)'valid=false;break;}}returnvalid;});
Environment
Sequelize version: 5.21.3
Node.js version: 10.16.3
Operating System: openSUSE 15.0
Issue Template Checklist
How does this problem relate to dialects?
I think this problem happens regardless of the dialect.
I think this problem happens only for the following dialect(s): MSSQL
I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX
Would you be willing to resolve this issue by submitting a Pull Request?
Yes, I have the time and I know how to start.
Yes, I have the time but I don't know how to start, I would need guidance.
No, I don't have the time, although I believe I could do it if I had the time...
No, I don't have the time and I wouldn't even know how to start.
Activity
TorstenForth commentedon Feb 5, 2020
... should be
if (clause == null)sushantdhiman commentedon Jul 4, 2020
🎉 This issue has been resolved in version 6.3.0 🎉
The release is available on:
Your semantic-release bot 📦🚀