Skip to content

Adds Mysql syntax to CreateIndex builder #46

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

Merged
merged 1 commit into from
Mar 8, 2025
Merged

Conversation

belchior
Copy link
Owner

@belchior belchior commented Mar 4, 2025

Builder API

use sql_query_builder as sql;

let query = sql::CreateIndex::new()
  // required methods
  .create_index("users_name_idx")
  .on("users")
  .column("name")
  // optional methods
  .unique()
  .using("btree")
  .lock("exclusive")
  .as_string();

let expected_query = "\
  CREATE UNIQUE INDEX users_name_idx \
  USING btree \
  ON users (name) \
  LOCK exclusive\
";

assert_eq!(expected, query);

Output

CREATE UNIQUE INDEX users_name_idx USING btree ON users (name) LOCK exclusive

@belchior belchior self-assigned this Mar 4, 2025
@belchior belchior changed the base branch from main to mysql March 4, 2025 22:53
@belchior belchior changed the title Mysql create index Adds Mysql syntax to CreateIndex builder Mar 4, 2025
@belchior belchior added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 4, 2025
@belchior belchior moved this to In Progress in SQL Query Builder Roadmap Mar 4, 2025
@belchior belchior linked an issue Mar 4, 2025 that may be closed by this pull request
@belchior belchior merged commit e79e6fd into mysql Mar 8, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in SQL Query Builder Roadmap Mar 8, 2025
@belchior belchior deleted the mysql-create-index branch March 8, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Add MySQL syntax
1 participant