Skip to content

pgschema dump produces invalid SQL for literal array casts #345

@ivgiuliani

Description

@ivgiuliani

Imagine the following case using the #>> operator (which returns a text[] array):

CREATE TABLE repro (
    id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
    data jsonb DEFAULT '{}'
);

CREATE POLICY p ON repro USING ((data #>> '{nested,key}'::text[]) = 'x');

I'd expect pgschema dump to return something like:

 CREATE POLICY p ON repro TO PUBLIC USING ((data #>> '{nested,key}'::text[]) = 'x');

Instead I get the following, which is invalid:

CREATE POLICY p ON repro TO PUBLIC USING ((data #>> '{nested,key}'[]) = 'x');

Not that the type name (::text) is being stripped from the explicit array literal casts and only the array part is left ([]), which results in an invalid syntax. I have managed to reproduce it with JSONB path operators (#>>, #>, ...) but I suspect this may go beyond that.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions