add support for update statements that contain tuple assignments (#1317)

This commit is contained in:
Ophir LOJKINE 2024-06-18 15:28:39 +02:00 committed by GitHub
parent 0330f9def5
commit 345e2098fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 114 additions and 24 deletions

View file

@ -373,6 +373,40 @@ fn parse_attach_database() {
}
}
#[test]
fn parse_update_tuple_row_values() {
// See https://github.com/sqlparser-rs/sqlparser-rs/issues/1311
assert_eq!(
sqlite().verified_stmt("UPDATE x SET (a, b) = (1, 2)"),
Statement::Update {
assignments: vec![Assignment {
target: AssignmentTarget::Tuple(vec![
ObjectName(vec![Ident::new("a"),]),
ObjectName(vec![Ident::new("b"),]),
]),
value: Expr::Tuple(vec![
Expr::Value(Value::Number("1".parse().unwrap(), false)),
Expr::Value(Value::Number("2".parse().unwrap(), false))
])
}],
selection: None,
table: TableWithJoins {
relation: TableFactor::Table {
name: ObjectName(vec![Ident::new("x")]),
alias: None,
args: None,
with_hints: vec![],
version: None,
partitions: vec![]
},
joins: vec![],
},
from: None,
returning: None
}
);
}
#[test]
fn parse_where_in_empty_list() {
let sql = "SELECT * FROM t1 WHERE a IN ()";