support MySQL UNSIGNED #425
Closed
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 9.47s Running `target/debug/examples/cli create_table.sql --mysql` Parsing from file 'create_table.sql' using MySqlDialect 2022-02-20T08:14:31.123Z DEBUG [sqlparser::parser] Parsing sql 'CREATE TABLE `warehouses` ( `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), -- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 '... Error during parsing: ParserError("Expected ',' or ')' after column definition, found: UNSIGNED")add
UNSIGNEDto column option for MySQL Dialect.❯ 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.95s Running `target/debug/examples/cli create_table.sql --mysql` Parsing from file 'create_table.sql' using MySqlDialect 2022-02-20T08:15:27.661Z DEBUG [sqlparser::parser] Parsing sql 'CREATE TABLE `warehouses` ( `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 '... Round-trip: 'CREATE TABLE `warehouses` (`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' 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": "Unsigned" }, { "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" } } ]