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
When ignoreDuplicates=true is applied to a create operation, Sequelize should not reject with an EmptyResultError as that is a perfectly acceptable result.
The ignoreDuplicates is declared on model types, and the actual SQL generated appears to respect the option as documented.
The issue is when it actually hits duplicates and returns nothing, Sequelize does not expect that case and throws an error.
Environment
Sequelize version: 16.19.0
Node version: 16.15.0 (does not appear to be node-specific)
Database: Postgres 13 (should be impacted by any database that supports ignoreDuplicates)
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.
Already have PR open for failing test, so would add onto that.
Two possible approaches I can think of:
Simply check for ignoreDuplicates flag before throwing the empty error
Convert an Insert query with ignoreDuplicates=true to an upsert internally (that updates nothing)
Former is easiest to implement, but also feels like there more be edge cases uncaught... Latter is probably a more robust solution but not sure if there are other side effects that will be triggered as a result
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
Issue Creation Checklist
Bug Description
SSCCE
#14469
See failing tests
What do you expect to happen?
When
ignoreDuplicates=true
is applied to a create operation, Sequelize should not reject with anEmptyResultError
as that is a perfectly acceptable result.What is actually happening?
Sequelize rejects with
EmptyResultError
.For postgres, that is thrown here: https://github.com/sequelize/sequelize/blob/main/src/dialects/postgres/query.js#L262
Note lack of check against
ignoreDuplicates
flagAdditional context
The
ignoreDuplicates
is declared on model types, and the actual SQL generated appears to respect the option as documented.The issue is when it actually hits duplicates and returns nothing, Sequelize does not expect that case and throws an error.
Environment
Sequelize version: 16.19.0
Node version: 16.15.0 (does not appear to be node-specific)
Database: Postgres 13 (should be impacted by any database that supports
ignoreDuplicates
)Would you be willing to resolve this issue by submitting a Pull Request?
Already have PR open for failing test, so would add onto that.
Two possible approaches I can think of:
ignoreDuplicates
flag before throwing the empty errorFormer is easiest to implement, but also feels like there more be edge cases uncaught... Latter is probably a more robust solution but not sure if there are other side effects that will be triggered as a result
The text was updated successfully, but these errors were encountered: