mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 03:07:20 +00:00
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:
parent
9420070a0d
commit
14e07ebdda
3 changed files with 17 additions and 11 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue