mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-21 13:19:46 +00:00
add on update for my sql (#522)
This commit is contained in:
parent
ca15a4edbf
commit
99697d26e1
2 changed files with 31 additions and 0 deletions
|
@ -2254,6 +2254,12 @@ impl<'a> Parser<'a> {
|
||||||
Ok(Some(ColumnOption::DialectSpecific(vec![
|
Ok(Some(ColumnOption::DialectSpecific(vec![
|
||||||
Token::make_keyword("AUTOINCREMENT"),
|
Token::make_keyword("AUTOINCREMENT"),
|
||||||
])))
|
])))
|
||||||
|
} else if self.parse_keywords(&[Keyword::ON, Keyword::UPDATE])
|
||||||
|
&& dialect_of!(self is MySqlDialect)
|
||||||
|
{
|
||||||
|
Ok(Some(ColumnOption::DialectSpecific(vec![
|
||||||
|
Token::make_keyword("ON UPDATE"),
|
||||||
|
])))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -834,6 +834,31 @@ fn parse_kill() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_table_colum_option_on_update() {
|
||||||
|
let sql1 = "CREATE TABLE foo (`modification_time` DATETIME ON UPDATE)";
|
||||||
|
match mysql().verified_stmt(sql1) {
|
||||||
|
Statement::CreateTable { name, columns, .. } => {
|
||||||
|
assert_eq!(name.to_string(), "foo");
|
||||||
|
assert_eq!(
|
||||||
|
vec![ColumnDef {
|
||||||
|
name: Ident::with_quote('`', "modification_time"),
|
||||||
|
data_type: DataType::Datetime,
|
||||||
|
collation: None,
|
||||||
|
options: vec![ColumnOptionDef {
|
||||||
|
name: None,
|
||||||
|
option: ColumnOption::DialectSpecific(vec![Token::make_keyword(
|
||||||
|
"ON UPDATE"
|
||||||
|
)]),
|
||||||
|
},],
|
||||||
|
}],
|
||||||
|
columns
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn mysql() -> TestedDialects {
|
fn mysql() -> TestedDialects {
|
||||||
TestedDialects {
|
TestedDialects {
|
||||||
dialects: vec![Box::new(MySqlDialect {})],
|
dialects: vec![Box::new(MySqlDialect {})],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue