Closed
Conversation
houqp
approved these changes
Feb 20, 2022
Pull Request Test Coverage Report for Build 1871338205
💛 - Coveralls |
alamb
requested changes
Feb 28, 2022
Contributor
alamb
left a comment
There was a problem hiding this comment.
Sorry for the delayed review @watarukura -- I have been away. I don't think adding UNSIGNED as ColumnOption is correct -- it should be a data type instead
| DialectSpecific(Vec<Token>), | ||
| CharacterSet(ObjectName), | ||
| Comment(String), | ||
| Unsigned, |
Contributor
There was a problem hiding this comment.
I think UNSIGNED is a DataType (not an option on the column definition)
Specifically you can do something like
mysql> select cast(x as unsigned) from bar;
+---------------------+
| cast(x as unsigned) |
+---------------------+
| 1 |
| NULL |
+---------------------+
2 rows in set (0.00 sec)
Contributor
Author
There was a problem hiding this comment.
Thanks for good review!
I think too, close this pull request, and I will retry.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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" } } ]