Skip to content
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

On conflict do nothing for MySql #684

Closed
wants to merge 9 commits into from

Conversation

darkmmon
Copy link
Contributor

PR Info

  • Dependencies:
  • Dependents:

New Features

  • added do_nothing_mysql([pk_cols]). This is to replace do_nothing() with MySql, require user to input the primary key columns manually.

Bug Fixes

  • fixed a bug where do_nothing() will return syntax error with MySql. See New Features for the new function.

Breaking Changes

Changes

[
r#"INSERT INTO `glyph` (`aspect`, `image`)"#,
r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#,
r#"ON DUPLICATE KEY UPDATE `id` = VALUES(`id`)"#,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make it id = id?

/// ]
/// .join(" ")
/// );
pub fn do_nothing_mysql<C, I>(&mut self, pk_cols: I) -> &mut Self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darkmmon I'm not sure, that naming is good...

@tyt2y3 what do you think?

Copy link
Member

@tyt2y3 tyt2y3 Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, may be do_nothing_on and add MySQL only in the doc? e.g.

/// Set column type as interval type with optional fields and precision. Postgres only

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with it

@@ -1161,7 +1183,7 @@ fn insert_on_conflict_0() {
[
r#"INSERT INTO `glyph` (`aspect`, `image`)"#,
r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#,
r#"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = VALUES(`image`)"#,
r#"ON DUPLICATE KEY UPDATE `aspect` = `aspect`, `image` = `image`"#,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sad, this is wrong. ON DUPLICATE KEY UPDATE id = id should only applies to do_nothing_on.
While the behaviour of update_columns() should not be changed.
The two expressions have different semantics.

Copy link
Member

@tyt2y3 tyt2y3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated

@tyt2y3 tyt2y3 marked this pull request as draft December 14, 2023 12:21
@billy1624 billy1624 closed this Apr 10, 2024
@billy1624 billy1624 mentioned this pull request Apr 10, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On conflict do nothing for MySQL
4 participants