mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 19:27:21 +00:00
mysql unsigned datatype (#428)
* support MySQL UNSIGNED * fix: 🐛 `unsigned` is not column option * test: 💍 add `unsigned` test * fix: 🐛 `unsigned` is not column option * feat: 🎸 declare unsigned data_types * feat: 🎸 display unsigned * fix: 🐛 unsigned is not column type option * feat: 🎸 parse_data_type can parse unsigned * feat: 🎸 int or decimal or float is unsigned selectable * fix: 🐛 FLOAT/DOUBLE/DECIMAL + UNSIGNED is not recommended https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html * test: 💍 add test * style: 💄 fmt
This commit is contained in:
parent
3af3ca07b6
commit
994b86a45c
4 changed files with 109 additions and 14 deletions
|
@ -407,6 +407,46 @@ fn parse_create_table_with_minimum_display_width() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_unsigned() {
|
||||
let sql = "CREATE TABLE foo (bar_tinyint TINYINT(3) UNSIGNED, bar_smallint SMALLINT(5) UNSIGNED, bar_int INT(11) UNSIGNED, bar_bigint BIGINT(20) UNSIGNED)";
|
||||
match mysql().verified_stmt(sql) {
|
||||
Statement::CreateTable { name, columns, .. } => {
|
||||
assert_eq!(name.to_string(), "foo");
|
||||
assert_eq!(
|
||||
vec![
|
||||
ColumnDef {
|
||||
name: Ident::new("bar_tinyint"),
|
||||
data_type: DataType::UnsignedTinyInt(Some(3)),
|
||||
collation: None,
|
||||
options: vec![],
|
||||
},
|
||||
ColumnDef {
|
||||
name: Ident::new("bar_smallint"),
|
||||
data_type: DataType::UnsignedSmallInt(Some(5)),
|
||||
collation: None,
|
||||
options: vec![],
|
||||
},
|
||||
ColumnDef {
|
||||
name: Ident::new("bar_int"),
|
||||
data_type: DataType::UnsignedInt(Some(11)),
|
||||
collation: None,
|
||||
options: vec![],
|
||||
},
|
||||
ColumnDef {
|
||||
name: Ident::new("bar_bigint"),
|
||||
data_type: DataType::UnsignedBigInt(Some(20)),
|
||||
collation: None,
|
||||
options: vec![],
|
||||
},
|
||||
],
|
||||
columns
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "bigdecimal"))]
|
||||
fn parse_simple_insert() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue