sqldef
sqldef copied to clipboard
psqldef abort with syntax error on valid VIEW with any(ARRAY[])
Hi, I hit into 2 cases of psqldef parse error on VIEW.
And, I extracted reproducible DDL for each one. They may look meaningless, but taken from actual use cases.
1 case is split into #455, as they have different causes.
I think --skip-view
option would be helpful for an escape hatch, as table operation looks much stable and Views can be CREATE OR REPLACE
ed by psql.
Platform
- OS: Linux
- RDBMS: PostgreSQL
- Version: v0.16.9
Syntax error on any(ARRAY[])
This issue describes a syntax error VIEW while it's valid for PostgreSQL.
--export output
$ psqldef -Upostgres -hlocalhost -p5432 --export some_db
2023/10/23 12:50:14 found syntax error when parsing DDL "CREATE VIEW public.any_array AS SELECT 1 AS "?column?" WHERE (1 = ANY (ARRAY[1, 4, 5]))": syntax error at position 79 near '1'
Input SQL
CREATE VIEW any_array AS SELECT 1 WHERE 1 in (1, 4, 5);
PostgreSQL internally transforms this as follows:
CREATE VIEW any_array AS SELECT 1 WHERE 1 = ANY(ARRAY[1, 4, 5]);