-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix(bulkcreate): use correct PK column names in updateOnDuplicate #11434
Conversation
I'm debating where to add tests for this issue, since it relates to
Please advise and I will add appropriate tests. |
Hello! I see you are a first-time contributor, thank you for taking the time to help Sequelize! I hope to see more PRs from you in the future! 😬 As for the test, I think you should do the third option. It makes sense to be dialect agnostic to me because updateOnDuplicate should work on all dialects it is supported. So although it works on MySQL and MariaDB already, it should work on every supported dialect (i.e. every dialect except MSSQL). Therefore I think the best option is your third one ( |
I have tagged it as SQLite as well because I reproduced the same problem on SQLite. I would guess your suggested fix already fixes SQLite as well, but would you be willing to double check? And fix both in the same PR? Thank you very much!! |
Sure, thanks for the quick response. I'm on it |
added test case when a primary key field name does not match column name
Hi @papb, I've added a test for this fix. I also grouped two relevant tests under a single new I ran the tests with Postgres, Sqlite and Mysql and they pass. Is there anything you'd like me to add/change before this can be merged? |
I see the Travis build is failing but after a short investigation I don't see how it has anything to do with this PR. I'm continuing to investigate, but on the chance that this is caused by a flaky test- could I trigger a rebuild? I couldn't find it in the Travis UI. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #11434 +/- ##
=======================================
Coverage 92.49% 92.49%
=======================================
Files 91 91
Lines 8866 8866
=======================================
Hits 8201 8201
Misses 665 665
Continue to review full report at Codecov.
|
Alright, I pushed an inconsequential commit to trigger a rebuild (I was a little impatient...) and it does seem like a flaky test, the build passes now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, great work!!
🎉 This PR is included in version 5.19.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Reopened accidentally closed PR: #11433
Pull Request check-list
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
This pull request fixes the following issue:
#11432
When performing
bulkCreate
withupdateOnDuplicate
using Postgres dialect, the generated query has bad column names. The query has the Javascript model's field names instead of the column names.