mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 23:44:07 +00:00
Support for pg ADD GENERATED in ALTER COLUMN statements (#1079)
Signed-off-by: Toby Hede <toby@cipherstash.com>
This commit is contained in:
parent
a430d1a5a7
commit
1d63466ef8
5 changed files with 106 additions and 6 deletions
|
@ -611,6 +611,42 @@ fn parse_alter_table_alter_column() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_alter_table_alter_column_add_generated() {
|
||||
pg_and_generic()
|
||||
.verified_stmt("ALTER TABLE t ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY");
|
||||
pg_and_generic()
|
||||
.verified_stmt("ALTER TABLE t ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY");
|
||||
pg_and_generic().verified_stmt("ALTER TABLE t ALTER COLUMN id ADD GENERATED AS IDENTITY");
|
||||
pg_and_generic().verified_stmt(
|
||||
"ALTER TABLE t ALTER COLUMN id ADD GENERATED AS IDENTITY ( INCREMENT 1 MINVALUE 1 )",
|
||||
);
|
||||
pg_and_generic().verified_stmt("ALTER TABLE t ALTER COLUMN id ADD GENERATED AS IDENTITY ( )");
|
||||
|
||||
let res = pg().parse_sql_statements(
|
||||
"ALTER TABLE t ALTER COLUMN id ADD GENERATED ( INCREMENT 1 MINVALUE 1 )",
|
||||
);
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected AS, found: (".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
|
||||
let res = pg().parse_sql_statements(
|
||||
"ALTER TABLE t ALTER COLUMN id ADD GENERATED AS IDENTITY ( INCREMENT )",
|
||||
);
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected a value, found: )".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
|
||||
let res =
|
||||
pg().parse_sql_statements("ALTER TABLE t ALTER COLUMN id ADD GENERATED AS IDENTITY (");
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected ), found: EOF".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_alter_table_add_columns() {
|
||||
match pg().verified_stmt("ALTER TABLE IF EXISTS ONLY tab ADD COLUMN a TEXT, ADD COLUMN b INT") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue