Support arbitrary INSERT sources

INSERT takes arbitrary queries as sources, not just VALUES clauses. For
example, `INSERT INTO foo SELECT * FROM bar` is perfectly valid.
This commit is contained in:
Nikhil Benesch 2019-05-28 19:37:00 -04:00
parent 9420070a0d
commit 14e07ebdda
No known key found for this signature in database
GPG key ID: F7386C5DEADABA7F
3 changed files with 17 additions and 11 deletions

View file

@ -52,16 +52,23 @@ fn parse_insert_values() {
SQLStatement::SQLInsert {
table_name,
columns,
values,
source,
..
} => {
assert_eq!(table_name.to_string(), expected_table_name);
assert_eq!(columns, expected_columns);
assert_eq!(values.0.as_slice(), expected_rows);
match &source.body {
SQLSetExpr::Values(SQLValues(values)) => {
assert_eq!(values.as_slice(), expected_rows)
}
_ => unreachable!(),
}
}
_ => unreachable!(),
}
}
verified_stmt("INSERT INTO customer WITH foo AS (SELECT 1) SELECT * FROM foo UNION VALUES (1)");
}
#[test]