Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ pub const RESERVED_FOR_COLUMN_ALIAS: &[Keyword] = &[
Keyword::INTERSECT,
Keyword::CLUSTER,
Keyword::DISTRIBUTE,
Keyword::RETURNING,
// Reserved only as a column alias in the `SELECT` clause
Keyword::FROM,
Keyword::INTO,
Expand Down
19 changes: 19 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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]
fn parse_insert_sqlite() {
let dialect = SQLiteDialect {};
Expand Down