Cover SET EXPRESSION span and empty expression
diff --git a/src/ast/spans.rs b/src/ast/spans.rs index a2b30c0..9d05ede 100644 --- a/src/ast/spans.rs +++ b/src/ast/spans.rs
@@ -3526,6 +3526,22 @@ } #[test] + fn test_alter_column_set_expression_span() { + let dialect = &crate::dialect::PostgreSqlDialect {}; + let sql = "ALTER TABLE d ALTER COLUMN x SET EXPRESSION AS (y + 2)"; + let mut test = SpanTest::new(dialect, sql); + + let operations = match test.0.parse_statement().unwrap() { + Statement::AlterTable(alter) => alter.operations, + stmt => panic!("expected ALTER TABLE, got {stmt:?}"), + }; + let AlterTableOperation::AlterColumn { op, .. } = &operations[0] else { + panic!("expected ALTER COLUMN, got {:?}", operations[0]); + }; + assert_eq!(test.get_source(op.span()), "y + 2"); + } + + #[test] fn test_create_foreign_table_partition_of_span() { let dialect = &crate::dialect::PostgreSqlDialect {}; let sql =
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index ed608ce..b862251 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs
@@ -14637,6 +14637,10 @@ "ALTER TABLE d ALTER COLUMN x SET EXPRESSION AS (y + 2", "Expected: ), found: EOF", ), + ( + "ALTER TABLE d ALTER COLUMN x SET EXPRESSION AS ()", + "Expected: an expression, found: )", + ), ] { assert_eq!( pg_and_generic()