Skip to content

Mysql create table #49

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
Apr 5, 2025
Merged

Mysql create table #49

merged 1 commit into from
Apr 5, 2025

Conversation

belchior
Copy link
Owner

@belchior belchior commented Apr 5, 2025

Builder API

let query = sql::CreateTable::new()
  // at least one of methods
  .create_table("users")
  .create_table_if_not_exists("users")
  // optional methods
  .column("id int not null auto_increment, login varchar(100) not null")
  .primary_key("(id)")
  .foreign_key("(address_id) references addresses(id)")
  .constraint("login users_login_key unique(login)")
  .as_string();

let expected_query = "\
  CREATE TABLE IF NOT EXISTS users (\
    id int not null auto_increment, login varchar(100) not null, \
    PRIMARY KEY(id), \
    CONSTRAINT login users_login_key unique(login), \
    FOREIGN KEY(address_id) references addresses(id)\
  )\
";

assert_eq!(expected_query, query);

Reference

@belchior belchior added the enhancement New feature or request label Apr 5, 2025
@belchior belchior self-assigned this Apr 5, 2025
@belchior belchior changed the base branch from main to mysql April 5, 2025 20:33
@belchior belchior moved this to In Progress in SQL Query Builder Roadmap Apr 5, 2025
@belchior belchior merged commit d9e2cf2 into mysql Apr 5, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in SQL Query Builder Roadmap Apr 5, 2025
@belchior belchior deleted the mysql-create-table branch April 12, 2025 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

1 participant