-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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: upsert with composite unique index #9454
base: develop
Are you sure you want to change the base?
fix: upsert with composite unique index #9454
Conversation
$constraints[] = current($index); | ||
// only one index can be used? | ||
foreach ($allIndexes as $index) { | ||
$constraints = $index->fields; |
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.
Would $constraints be just overwritten on iterations > 1?
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.
No, we break the loop after the first item.
Posgre has very different functioning then MySQL when it comes to upserts. Postgre offers much more features while mysql automatically applies any and all constraints. It was attempted apply the primary key if constraints were not set. Its really just a guess but it was done to try and provide the same functionality across all databases. For all the DBMS except mysql it is really recommended to use the onConstraint() method and explicitly define them. Perhaps the documentation should highlight this. |
While I agree that |
Description
This PR fixes a bug in
Postgre
andSQLite3
where composite indexes are not fully taken into account when usingupsert()
.Both handlers:
Fixes #9450
Checklist: