Skip to content

Fix 5407 PostgreSql create or replace view #5426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

griffio
Copy link
Contributor

@griffio griffio commented Aug 30, 2024

fixes #5407

  • Add grammar for CREATE OR REPLACE VIEW for PostgreSql syntax
  • Add CreateOrReplaceViewMixin basic annotations where only appending new columns are allowed by PostgreSql
  • Add fixture test
    • CREATE OR REPLACE VIEW is the PostgreSql extension similar to CREATE VIEW IF NOT EXISTS
    • filter out inherited ansi tests with invalid trigger syntax statements - PostgreSql triggers are not supported
  • Add migration test - creating and then create or replacing an existing view only makes sense in a migration scenario

Depends on sqldelight/sql-psi#644 this should be in sql-psi 0.5.0

@griffio griffio force-pushed the fix-5407-postgresql-create-or-replace-view branch from 3b484b5 to 17c2df8 Compare March 26, 2025 09:23
@griffio
Copy link
Contributor Author

griffio commented Mar 26, 2025

👓 Looking into error

Seems the fixture tests were getting confused - creating and then create or replacing an existing view only makes sense in a migration scenario
Filter out inherited ansi tests with invalid trigger syntax statements - not even valid PostgreSql

griffio added 5 commits March 26, 2025 10:57
Add grammar for PostgreSql
Add mixin CreateOrReplaceViewMixin for annotations
Remove the ansi tests with invalid syntax - such as triggers

CREATE VIEW IF EXISTS ... is not PostgreSql syntax
CREATE OR REPLACE VIEW is  a PostgreSql extension

It only makes sense to use CREATE VIEW and then CREATE OR REPLACE VIEW in a migration scenerio
Doesn't work when declared in single sq file

CREATE VIEW viewabc AS SELECT a, b FROM abc;

CREATE OR REPLACE VIEW viewabc AS SELECT a, b, c FROM abc;

Only works and makes sense for migration files
@griffio griffio force-pushed the fix-5407-postgresql-create-or-replace-view branch from 17c2df8 to 00ee10d Compare March 26, 2025 13:00
@griffio griffio marked this pull request as ready for review March 26, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

PostgreSql Dialect - Support for CREATE OR REPLACE VIEW
1 participant