mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-03 13:58:15 +00:00
Adding MySQL table option {INDEX | KEY} to the CREATE TABLE definiton (partial). (#665)
Theoretically the behavior should be the same as CREATE INDEX, but we cannot make that assumption, so the parse is (almost) identical as the input. Breaking changes: - Now HASH and BTREE are KEYWORDS, and using them as names can result in errors. - Now 'KEY' and 'INDEX' column names start the parsing of a table constraint if unquoted for the Generic dialect. This results in possible conficts if canonical results are compared for all dialects if a column is named 'key' without quotes.
This commit is contained in:
parent
e3c936a6ce
commit
2aba3f8c91
6 changed files with 242 additions and 5 deletions
|
@ -1073,6 +1073,49 @@ fn parse_limit_my_sql_syntax() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_with_index_definition() {
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, INDEX (id))",
|
||||
"CREATE TABLE tb (id INT, INDEX (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, index USING BTREE (id))",
|
||||
"CREATE TABLE tb (id INT, INDEX USING BTREE (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, KEY USING HASH (id))",
|
||||
"CREATE TABLE tb (id INT, KEY USING HASH (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, key index (id))",
|
||||
"CREATE TABLE tb (id INT, KEY index (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, INDEX 'index' (id))",
|
||||
"CREATE TABLE tb (id INT, INDEX 'index' (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, INDEX index USING BTREE (id))",
|
||||
"CREATE TABLE tb (id INT, INDEX index USING BTREE (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, INDEX index USING HASH (id))",
|
||||
"CREATE TABLE tb (id INT, INDEX index USING HASH (id))",
|
||||
);
|
||||
|
||||
mysql_and_generic().one_statement_parses_to(
|
||||
"CREATE TABLE tb (id INT, INDEX (c1, c2, c3, c4,c5))",
|
||||
"CREATE TABLE tb (id INT, INDEX (c1, c2, c3, c4, c5))",
|
||||
);
|
||||
}
|
||||
|
||||
fn mysql() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: vec![Box::new(MySqlDialect {})],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue