You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In MySQL, creating a column expects integer unsigned (as an "attribute" on the integer type, see docs), while CAST expects unsigned integer or even just unsigned (see docs).
This can be seen in this transcript:
mysql> create table foo (x unsigned integer);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned integer)' at line 1
mysql> create table foo (x integer unsigned);
Query OK, 0 rows affected (0.03 sec)
mysql> select cast(x as unsigned integer) from foo;
Empty set (0.01 sec)
mysql> select cast(x as integer unsigned) from foo;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer unsigned) from foo' at line 1
sqlparser just has one parse_data_type procedure used in both contexts, which currently parses according to the column datatype rules, which means it fails to parse CAST correctly.
I don't know if it would be better to have a second, somewhat redundant parse_data_type_for_cast which we enter for mysql-alikes, or add some special casing in the existing parse_data_type. That may depend on whether there are other discrepancies between create and cast that need to be addressed. Not sure when I'll have time to address this, but any feedback on approach would be welcome.
The text was updated successfully, but these errors were encountered:
In MySQL, creating a column expects
integer unsigned
(as an "attribute" on the integer type, see docs), whileCAST
expectsunsigned integer
or even justunsigned
(see docs).This can be seen in this transcript:
sqlparser just has one
parse_data_type
procedure used in both contexts, which currently parses according to the column datatype rules, which means it fails to parseCAST
correctly.Incorrectly failing to parse
unsigned integer
:Incorrectly succeeding in parsing
integer unsigned
:I don't know if it would be better to have a second, somewhat redundant
parse_data_type_for_cast
which we enter for mysql-alikes, or add some special casing in the existingparse_data_type
. That may depend on whether there are other discrepancies between create and cast that need to be addressed. Not sure when I'll have time to address this, but any feedback on approach would be welcome.The text was updated successfully, but these errors were encountered: