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:
AugustoFKL 2022-10-19 18:24:38 -03:00 committed by GitHub
parent e3c936a6ce
commit 2aba3f8c91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 242 additions and 5 deletions

View file

@ -2089,10 +2089,10 @@ fn parse_create_table_hive_array() {
let dialects = TestedDialects {
dialects: vec![Box::new(PostgreSqlDialect {}), Box::new(HiveDialect {})],
};
let sql = "CREATE TABLE IF NOT EXISTS something (key int, val array<int>)";
let sql = "CREATE TABLE IF NOT EXISTS something (name int, val array<int>)";
match dialects.one_statement_parses_to(
sql,
"CREATE TABLE IF NOT EXISTS something (key INT, val INT[])",
"CREATE TABLE IF NOT EXISTS something (name INT, val INT[])",
) {
Statement::CreateTable {
if_not_exists,
@ -2106,7 +2106,7 @@ fn parse_create_table_hive_array() {
columns,
vec![
ColumnDef {
name: Ident::new("key"),
name: Ident::new("name"),
data_type: DataType::Int(None),
collation: None,
options: vec![],
@ -2123,7 +2123,8 @@ fn parse_create_table_hive_array() {
_ => unreachable!(),
}
let res = parse_sql_statements("CREATE TABLE IF NOT EXISTS something (key int, val array<int)");
let res =
parse_sql_statements("CREATE TABLE IF NOT EXISTS something (name int, val array<int)");
assert!(res
.unwrap_err()
.to_string()