Skip to content

Insert builder: fix mutually exclusive methods#57

Merged
belchior merged 1 commit intomysqlfrom
insert-builder
Sep 6, 2025
Merged

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

Conversation

@belchior
Copy link
Owner

Mutually exclusive methods on Insert builder

Avaliable on sqlite only

Methods Insert::insert_into, Insert::insert_or and Insert::replace_into are mutually exclusive, the last called will overrides the previous ones.

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

  let insert = sql::Insert::new()
    .insert_into("users (login, name)")
    .replace_into("users (login, name)")
    .as_string();
}

Output

REPLACE INTO users (login, name)

Avaliable on mysql only

Methods Insert::insert_into and the splitted version (Insert::insert, Insert::into, Insert::column) are mutually exclusive, the last called will overrides the previous ones.

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

  let insert = sql::Insert::new()
    .insert_into("users (login, name)")
    .insert("low_priority")
    .into("users")
    .column("login")
    .as_string();
}

Output

INSERT low_priority INTO users (login)

@belchior belchior self-assigned this Jul 26, 2025
@belchior belchior added bug Something isn't working documentation Improvements or additions to documentation labels Jul 26, 2025
@belchior belchior moved this to In Progress in SQL Query Builder Roadmap Jul 27, 2025
@belchior belchior merged commit b309798 into mysql Sep 6, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in SQL Query Builder Roadmap Sep 6, 2025
@belchior belchior deleted the insert-builder branch September 6, 2025 20:17
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

Development

Successfully merging this pull request may close these issues.

1 participant

Comments