Repository navigation
PostgreSQL: Support ALTER VIEW operations - #2730
LucaCappelletti94 wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2730 +/- ##
==========================================
+ Coverage 82.41% 82.48% +0.06%
==========================================
Files 42 42
Lines 35361 35472 +111
Branches 35361 35472 +111
==========================================
+ Hits 29143 29259 +116
+ Misses 2681 2663 -18
- Partials 3537 3550 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| with_options, | ||
| } => { | ||
| if !with_options.is_empty() { | ||
| write!(f, "WITH ({}) ", display_comma_separated(with_options))?; |
There was a problem hiding this comment.
Pre-existing, but the parser reads (columns) before WITH (...) while this writes them the other way round, so ALTER VIEW v (a) WITH (x = 1) AS SELECT 1 displays as ALTER VIEW v WITH (x = 1) (a) AS SELECT 1, which doesn't re-parse. Swapping the two blocks here fixes the round-trip.
| } | ||
|
|
||
| #[test] | ||
| fn parse_alter_view_postgres() { |
There was a problem hiding this comment.
parse_alter_view has no dialect check, so these could use all_dialects() next to the existing parse_alter_view tests in sqlparser_common.rs.
a408cf1 to
27b559f
Compare
27b559f to
9246939
Compare
9246939 to
2540424
Compare
ALTER VIEW v OWNER TO oandALTER VIEW v SET (security_invoker = true)fail withExpected: AS, found: OWNER, becauseparse_alter_viewonly knows the MySQL formALTER VIEW v AS SELECT .... The other PostgreSQL forms of the statement fail the same way.Statement::AlterViewnow wraps anAlterViewstruct holdingIF EXISTSand anAlterViewOperation, the shapeAlterCollationalready uses. The MySQL form becomes one variant beside the PostgreSQL ones, which changes the public AST ofStatement::AlterView. PostgreSQL lets aSET (...)option omit its value, so such an option parses toSqlOption::Ident.The syntax follows https://www.postgresql.org/docs/current/sql-alterview.html.
Closes #886.