-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bulkCreate with unique partial index in postgres #12774
Comments
any updates on this ? |
upsert also has the same issue |
Having same issue with @papb @sushantdhiman given this was a important feature for v6, is this something we could prioritize fixing? |
I've been looking at the ramifications of v6's upsert changes for our upgrade, and I think this probably needs to be called out in the upgrade guide, as it's a big change that does not necessarily have a clean upgrade path. My $0.02 is that we probably need to add a new parameter to Even now, the current logic that automatically guesses which index to use is fairly naive. The current query generator chooses the first unique index that includes a column present in the values passed into the upsert operation. However, this might be a bad assumption if a table has multiple overlapping constraints! For example, if a table has uniqueness constraints on In the above scenario, I don't know if there's any way for Sequelize to choose the correct index to use. The best real-world solution would be to create a new uniqueness constraint on Partial indices make this much, much more complicated, and I honestly can't think of a good/elegant way to support them, apart from adding a parameter that allows users to manually specify the index name, ie. |
Any updates on this? It would be great to allow users what constraint to use |
Add support for where clauses used in the ON CONFLICT part of the queries generated by model.bulkCreate and model.upsert for usage > Closes sequelize#13240, sequelize#13066, sequelize#13031, sequelize#12774, sequelize#12742, sequelize#12595, sequelize#11656
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
Not stale. |
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
This is still an issue |
still an issue |
Still an issue in sequelize@6.20.1 |
Still an issue |
1 similar comment
Still an issue |
Sequelize is an awesome library! We love using it. As a general user-experience and developer-experience guideline, smart auto-configurations can never get it right 100% of the time--you will NEVER get it right 100%. This is why MS-Word autocorrect lets you override autocorrect settings, and most IDEs let you suppress eslint & other warnings by line/file/project. This is why test libraries have features for coverage exceptions. This may be a great feauture, but we need a fallback/override. For now, my team will look at hiding uniqueness constraints from the Sequelize models (leaving them only in the db) |
Issue Description
model bulkCreate function with updateOnDuplicate don't support partial unique index for postgres:
[SequelizeDatabaseError]: there is no unique or exclusion constraint matching the ON CONFLICT specification
What are you doing?
While trying to use bulkCreate function with unique partial index in postgres i could manage to use the model and create the query to bulkCreate
postgres partial unique index
Model Defination
Model usage
What do you expect to happen?
Expected to generate a insert query with
On Conflict
key and a where conditionExpected query
What is actually happening?
generate a insert query with
On Conflict
key but without a where condition that leaded toDatabaseError [SequelizeDatabaseError]: there is no unique or exclusion constraint matching the ON CONFLICT specification
output query
Additional context
Add any other context or screenshots about the feature request here.
Environment
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: