Parse SIGNED INTEGER type in MySQL CAST (#1739)

This commit is contained in:
Michael Victor Zink 2025-02-25 22:00:08 -08:00 committed by GitHub
parent 648efd7057
commit de4dbc5b1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 101 additions and 35 deletions

View file

@ -1359,27 +1359,27 @@ fn parse_create_table_unsigned() {
vec![
ColumnDef {
name: Ident::new("bar_tinyint"),
data_type: DataType::UnsignedTinyInt(Some(3)),
data_type: DataType::TinyIntUnsigned(Some(3)),
options: vec![],
},
ColumnDef {
name: Ident::new("bar_smallint"),
data_type: DataType::UnsignedSmallInt(Some(5)),
data_type: DataType::SmallIntUnsigned(Some(5)),
options: vec![],
},
ColumnDef {
name: Ident::new("bar_mediumint"),
data_type: DataType::UnsignedMediumInt(Some(13)),
data_type: DataType::MediumIntUnsigned(Some(13)),
options: vec![],
},
ColumnDef {
name: Ident::new("bar_int"),
data_type: DataType::UnsignedInt(Some(11)),
data_type: DataType::IntUnsigned(Some(11)),
options: vec![],
},
ColumnDef {
name: Ident::new("bar_bigint"),
data_type: DataType::UnsignedBigInt(Some(20)),
data_type: DataType::BigIntUnsigned(Some(20)),
options: vec![],
},
],
@ -3339,3 +3339,21 @@ fn parse_drop_trigger() {
}
);
}
#[test]
fn parse_cast_integers() {
mysql().verified_expr("CAST(foo AS UNSIGNED)");
mysql().verified_expr("CAST(foo AS SIGNED)");
mysql().verified_expr("CAST(foo AS UNSIGNED INTEGER)");
mysql().verified_expr("CAST(foo AS SIGNED INTEGER)");
mysql()
.run_parser_method("CAST(foo AS UNSIGNED(3))", |p| p.parse_expr())
.expect_err("CAST doesn't allow display width");
mysql()
.run_parser_method("CAST(foo AS UNSIGNED(3) INTEGER)", |p| p.parse_expr())
.expect_err("CAST doesn't allow display width");
mysql()
.run_parser_method("CAST(foo AS UNSIGNED INTEGER(3))", |p| p.parse_expr())
.expect_err("CAST doesn't allow display width");
}