Support COLLATE keyword on CREATE TABLE
#424
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This MySQL DDL I'm using in my project has the following definition.
ParseError occurred.
❯ cargo run --features json_example --example cli create_table.sql --mysql Compiling sqlparser v0.14.0 (/Users/watarukura/src/github.com/sqlparser-rs/sqlparser-rs) Finished dev [unoptimized + debuginfo] target(s) in 7.64s Running `target/debug/examples/cli create_table.sql --mysql` Parsing from file 'create_table.sql' using MySqlDialect 2022-02-20T07:04:04.134Z DEBUG [sqlparser::parser] Parsing sql 'CREATE TABLE `warehouses` ( `id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci '... Error during parsing: ParserError("Expected end of statement, found: COLLATE")add table's collation definition.
❯ cargo run --features json_example --example cli create_table.sql --mysql Compiling sqlparser v0.14.0 (/Users/watarukura/src/github.com/sqlparser-rs/sqlparser-rs) Finished dev [unoptimized + debuginfo] target(s) in 6.45s Running `target/debug/examples/cli create_table.sql --mysql` Parsing from file 'create_table.sql' using MySqlDialect 2022-02-20T07:06:01.449Z DEBUG [sqlparser::parser] Parsing sql 'CREATE TABLE `warehouses` ( `id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci '... Round-trip: 'CREATE TABLE `warehouses` (`id` BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' Serialized as JSON: [ { "CreateTable": { "or_replace": false, "temporary": false, "external": false, "if_not_exists": false, "name": [ { "value": "warehouses", "quote_style": "`" } ], "columns": [ { "name": { "value": "id", "quote_style": "`" }, "data_type": { "BigInt": null }, "collation": null, "options": [ { "name": null, "option": "NotNull" }, { "name": null, "option": { "DialectSpecific": [ { "Word": { "value": "AUTO_INCREMENT", "quote_style": null, "keyword": "AUTO_INCREMENT" } } ] } } ] } ], "constraints": [ { "Unique": { "name": null, "columns": [ { "value": "id", "quote_style": "`" } ], "is_primary": true } } ], "hive_distribution": "NONE", "hive_formats": { "row_format": null, "storage": null, "location": null }, "table_properties": [], "with_options": [], "file_format": null, "location": null, "query": null, "without_rowid": false, "like": null, "engine": "InnoDB", "default_charset": "utf8mb4", "collation": "utf8mb4_0900_ai_ci" } } ]