-
-
Notifications
You must be signed in to change notification settings - Fork 518
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
MySQL insert on conflict do nothing #2244
Conversation
src/query/insert.rs
Outdated
pub fn from_insert(mut insert: Insert<A>) -> Self { | ||
let primary_keys = <A::Entity as EntityTrait>::PrimaryKey::iter(); | ||
insert.query.on_conflict( | ||
OnConflict::columns(primary_keys.clone()) | ||
.do_nothing_on(primary_keys) | ||
.to_owned(), | ||
); | ||
|
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.
I don't think this code belongs here. on_empty_do_nothing
does not mean on_conflict_do_nothing
. on_empty_do_nothing
simply allows us to insert empty array.
we can create a method for on_conflict_do_nothing
that specifically means on PK conflict
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.
Updated! 27ce67e
🎉 Released In 1.0.0-rc.6 🎉Thank you everyone for the contribution! |
🎉 Released In 1.0.0 🎉Thank you everyone for the contribution! |
PR Info
New Features
https://dev.mysql.com/doc/refman/8.4/en/insert-on-duplicate.html