-
-
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
Sqlite: bulkCreate with updateOnDuplicate fails when the model contains a composite key. #11534
Closed
2 of 7 tasks
Labels
dialect: sqlite
For issues and PRs. Things that involve SQLite (and do not involve all dialects).
status: understood
For issues. Applied when the issue is understood / reproducible.
type: bug
Comments
papb
added
dialect: sqlite
For issues and PRs. Things that involve SQLite (and do not involve all dialects).
status: understood
For issues. Applied when the issue is understood / reproducible.
type: bug
labels
Oct 23, 2019
Hello, thanks for the report!
Great! What kind of guidance do you want? |
This was referenced Oct 24, 2019
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Oct 25, 2019
…eateOptions` This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set, in postgres. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Oct 25, 2019
…eateOptions` This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set, in postgres. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
6 tasks
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Jan 8, 2020
…eateOptions` This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set, in postgres. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
6 tasks
Fixed with #11984 |
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Jun 9, 2020
Adds options `upsertKeys` and `upsertIndex`. This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set, in postgres. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Jun 9, 2020
Adds options `upsertKeys` and `upsertIndex`. This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set, in postgres. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Jun 9, 2020
Adds options `upsertKeys` and `upsertIndex`. This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set, in postgres. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
fnimick
added a commit
to fnimick/sequelize
that referenced
this issue
Jun 9, 2020
Adds options `upsertKeys` and `upsertIndex`. These options work with sqlite as well as postgres. This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
PitchLabsAsh
pushed a commit
to PitchLabs/sequelize
that referenced
this issue
Jul 8, 2020
Adds options `upsertKeys` and `upsertIndex`. These options work with sqlite as well as postgres. This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
PitchLabsAsh
pushed a commit
to PitchLabs/sequelize
that referenced
this issue
Oct 10, 2020
Adds options `upsertKeys` and `upsertIndex`. These options work with sqlite as well as postgres. This allows the use of a unique index for a `bulkCreate` with `updateOnDuplicate` set. The unique index may be a partial index. Closes sequelize#11534, sequelize#11569
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
dialect: sqlite
For issues and PRs. Things that involve SQLite (and do not involve all dialects).
status: understood
For issues. Applied when the issue is understood / reproducible.
type: bug
Related issue: #11432
Issue Description
The
bulkCreate
fails if the model contains a composite key and doesn't explicitly define a primary key.The
upsertKeys
array is emptied when the model contains a composite key since the length of the fields array of thecompositeKey
object will be of size > 1 (which causes this filter to skip it):sequelize/lib/model.js
Line 2705 in 3a60069
My model looks like this:
In this case, the
model.uniqueKeys
object only contains a singlecompositeKey
object.Shouldn't the
model.uniqueKeys
object also contain the automatically generatedid
primary key for this model?Changing the model to this works:
What are you doing?
Upserting users for testing:
What do you expect to happen?
I expect the
bulkCreate
method to succeed and upsert the test users to the database.What is actually happening?
Doing this with this model results in the following error:
The error is referring to the
ON CONFLICT()
since it is an error to have an emptyON CONFLICT
clause. This should be:Additional context
Add any other context or screenshots about the feature request here.
Environment
Issue Template Checklist
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: