feat: Support expression in SET statement (#574)

Co-authored-by: Alex Vasilev <vaspiring@gmail.com>
This commit is contained in:
Dmitry Patsura 2022-08-18 20:29:55 +03:00 committed by GitHub
parent eb7f1b005e
commit 6d8aacd85b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 52 deletions

View file

@ -251,6 +251,26 @@ fn parse_use() {
);
}
#[test]
fn parse_set_variables() {
mysql_and_generic().verified_stmt("SET sql_mode = CONCAT(@@sql_mode, ',STRICT_TRANS_TABLES')");
assert_eq!(
mysql_and_generic().verified_stmt("SET LOCAL autocommit = 1"),
Statement::SetVariable {
local: true,
hivevar: false,
variable: ObjectName(vec!["autocommit".into()]),
value: vec![Expr::Value(Value::Number(
#[cfg(not(feature = "bigdecimal"))]
"1".to_string(),
#[cfg(feature = "bigdecimal")]
bigdecimal::BigDecimal::from(1),
false
))],
}
);
}
#[test]
fn parse_create_table_auto_increment() {
let sql = "CREATE TABLE foo (bar INT PRIMARY KEY AUTO_INCREMENT)";