Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow optional keywords in
create table
unique constraints (#2077)
* Add optional keywords to `create table` unique constraint * More tests * Move [INDEX | KEY] [index_name] to MySql dialect * Linter * Remove files moved
- Loading branch information
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
test/fixtures/dialects/mysql/create_table_constraint_unique.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE a( | ||
a INT NOT NULL, | ||
UNIQUE (a), | ||
UNIQUE idx_c(a), | ||
UNIQUE KEY (a), | ||
UNIQUE KEY idx_a(a), | ||
UNIQUE INDEX (a), | ||
UNIQUE INDEX idx_b(a) | ||
) |
81 changes: 81 additions & 0 deletions
81
test/fixtures/dialects/mysql/create_table_constraint_unique.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# YML test files are auto-generated from SQL files and should not be edited by | ||
# hand. To help enforce this, the "hash" field in the file must match a hash | ||
# computed by SQLFluff when running the tests. Please run | ||
# `python test/generate_parse_fixture_yml.py` to generate them after adding or | ||
# altering SQL files. | ||
_hash: 89f5acbd9b7f7b2a7f14cc5faa9666129d97246fbc7eb70c4d34e8c193eec5ab | ||
file: | ||
statement: | ||
create_table_statement: | ||
- keyword: CREATE | ||
- keyword: TABLE | ||
- table_reference: | ||
identifier: a | ||
- bracketed: | ||
- start_bracket: ( | ||
- column_definition: | ||
identifier: a | ||
data_type: | ||
data_type_identifier: INT | ||
column_constraint_segment: | ||
- keyword: NOT | ||
- keyword: 'NULL' | ||
- comma: ',' | ||
- table_constraint_segment: | ||
keyword: UNIQUE | ||
bracketed: | ||
start_bracket: ( | ||
column_reference: | ||
identifier: a | ||
end_bracket: ) | ||
- comma: ',' | ||
- table_constraint_segment: | ||
keyword: UNIQUE | ||
object_reference: | ||
identifier: idx_c | ||
bracketed: | ||
start_bracket: ( | ||
column_reference: | ||
identifier: a | ||
end_bracket: ) | ||
- comma: ',' | ||
- table_constraint_segment: | ||
- keyword: UNIQUE | ||
- keyword: KEY | ||
- bracketed: | ||
start_bracket: ( | ||
column_reference: | ||
identifier: a | ||
end_bracket: ) | ||
- comma: ',' | ||
- table_constraint_segment: | ||
- keyword: UNIQUE | ||
- keyword: KEY | ||
- object_reference: | ||
identifier: idx_a | ||
- bracketed: | ||
start_bracket: ( | ||
column_reference: | ||
identifier: a | ||
end_bracket: ) | ||
- comma: ',' | ||
- table_constraint_segment: | ||
- keyword: UNIQUE | ||
- keyword: INDEX | ||
- bracketed: | ||
start_bracket: ( | ||
column_reference: | ||
identifier: a | ||
end_bracket: ) | ||
- comma: ',' | ||
- table_constraint_segment: | ||
- keyword: UNIQUE | ||
- keyword: INDEX | ||
- object_reference: | ||
identifier: idx_b | ||
- bracketed: | ||
start_bracket: ( | ||
column_reference: | ||
identifier: a | ||
end_bracket: ) | ||
- end_bracket: ) |