mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Add support for ASC and DESC in CREATE TABLE column constraints for SQLite. (#1462)
This commit is contained in:
parent
8badcdc200
commit
ac956dc963
5 changed files with 63 additions and 0 deletions
|
|
@ -238,6 +238,43 @@ fn parse_create_table_auto_increment() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_primary_key_asc_desc() {
|
||||
let expected_column_def = |kind| ColumnDef {
|
||||
name: "bar".into(),
|
||||
data_type: DataType::Int(None),
|
||||
collation: None,
|
||||
options: vec![
|
||||
ColumnOptionDef {
|
||||
name: None,
|
||||
option: ColumnOption::Unique {
|
||||
is_primary: true,
|
||||
characteristics: None,
|
||||
},
|
||||
},
|
||||
ColumnOptionDef {
|
||||
name: None,
|
||||
option: ColumnOption::DialectSpecific(vec![Token::make_keyword(kind)]),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
let sql = "CREATE TABLE foo (bar INT PRIMARY KEY ASC)";
|
||||
match sqlite_and_generic().verified_stmt(sql) {
|
||||
Statement::CreateTable(CreateTable { columns, .. }) => {
|
||||
assert_eq!(vec![expected_column_def("ASC")], columns);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
let sql = "CREATE TABLE foo (bar INT PRIMARY KEY DESC)";
|
||||
match sqlite_and_generic().verified_stmt(sql) {
|
||||
Statement::CreateTable(CreateTable { columns, .. }) => {
|
||||
assert_eq!(vec![expected_column_def("DESC")], columns);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_sqlite_quote() {
|
||||
let sql = "CREATE TABLE `PRIMARY` (\"KEY\" INT, [INDEX] INT)";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue