Skip to content

Insert builder: fix mutually exclusive methods#56

Merged
belchior merged 1 commit intomysqlfrom
mysql-insert
Jul 23, 2025
Merged

Insert builder: fix mutually exclusive methods#56
belchior merged 1 commit intomysqlfrom
mysql-insert

Conversation

@belchior
Copy link
Owner

Mutually exclusive methods

The methods Insert::values/Insert::row, Insert::select and Insert::set are mutually exclusive, the last called will overrides the previous ones. Insert::row and Insert::set are available on crate feature mysql only.

Example

#[cfg(feature = "mysql")]
{
  use sql_query_builder as sql;

  let query = sql::Insert::new()
    .values("('foo', 'Foo')")
    .row("('bar', 'Bar')")
    .set("login = 'foo'")
    .set("name = 'Foo'")
    .as_string();

  let expected = "SET login = 'foo', name = 'Foo'";

  assert_eq!(expected, query);
}

Output

SET login = 'foo', name = 'Foo'

@belchior belchior self-assigned this Jul 23, 2025
@belchior belchior added bug Something isn't working documentation Improvements or additions to documentation labels Jul 23, 2025
@belchior belchior merged commit 14c66ee into mysql Jul 23, 2025
1 check passed
@belchior belchior deleted the mysql-insert branch July 23, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments