mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-01 19:57:30 +00:00
add support for insert into ... select ... returning ...
(#1132)
This commit is contained in:
parent
a5ac425f46
commit
d59b6638fa
2 changed files with 20 additions and 0 deletions
|
@ -810,6 +810,7 @@ pub const RESERVED_FOR_COLUMN_ALIAS: &[Keyword] = &[
|
||||||
Keyword::INTERSECT,
|
Keyword::INTERSECT,
|
||||||
Keyword::CLUSTER,
|
Keyword::CLUSTER,
|
||||||
Keyword::DISTRIBUTE,
|
Keyword::DISTRIBUTE,
|
||||||
|
Keyword::RETURNING,
|
||||||
// Reserved only as a column alias in the `SELECT` clause
|
// Reserved only as a column alias in the `SELECT` clause
|
||||||
Keyword::FROM,
|
Keyword::FROM,
|
||||||
Keyword::INTO,
|
Keyword::INTO,
|
||||||
|
|
|
@ -225,6 +225,25 @@ fn parse_insert_default_values() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_insert_select_returning() {
|
||||||
|
verified_stmt("INSERT INTO t SELECT 1 RETURNING 2");
|
||||||
|
let stmt = verified_stmt("INSERT INTO t SELECT x RETURNING x AS y");
|
||||||
|
match stmt {
|
||||||
|
Statement::Insert {
|
||||||
|
returning: Some(ret),
|
||||||
|
source: Some(_),
|
||||||
|
..
|
||||||
|
} => assert_eq!(ret.len(), 1),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_returning_as_column_alias() {
|
||||||
|
verified_stmt("SELECT 1 AS RETURNING");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_insert_sqlite() {
|
fn parse_insert_sqlite() {
|
||||||
let dialect = SQLiteDialect {};
|
let dialect = SQLiteDialect {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue