sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

`CREATE OR REPLACE TRIGGER` is valid as of PostgreSQL 14

Open wilsonehusin opened this issue 4 years ago • 2 comments

Version

1.10.0

What happened?

To be fair, this is less of a bug but more about "follow upstream" report 😄

PostgreSQL 14 considers CREATE OR REPLACE TRIGGER a valid syntax. sqlc at the moment considers it as invalid syntax.

Relevant log output

❯ sqlc generate
# package db
sql/schema/foo.sql:1:1: syntax error at or near "TRIGGER"

Database schema

No response

SQL queries

No response

Configuration

version: "1"
packages:
  - name: "db"
    path: "internal/db"
    queries: "./sql/query/"
    schema: "./sql/schema/"
    engine: "postgresql"
    sql_package: "pgx/v4"
    emit_prepared_queries: true
    emit_interface: false
    emit_exact_table_names: false
    emit_empty_slices: false
    emit_json_tags: true
    json_tags_case_style: "camel"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

wilsonehusin avatar Oct 21 '21 22:10 wilsonehusin

FYI, seems like a valid workaround for now is to downgrade to older syntax e.g.

DROP TRIGGER my_trigger ON my_table;
CREATE TRIGGER my_trigger BEFORE UPDATE ON my_table
FOR EACH ROW EXECUTE PROCEDURE some_function(some_field);

sudotliu avatar May 24 '22 10:05 sudotliu

Tracking upstream https://github.com/pganalyze/libpg_query/issues/127

kyleconroy avatar Jun 12 '22 17:06 kyleconroy