Skip to content

Incorrect parsing of quotes in create aggregate  #123

@k-koehler

Description

@k-koehler

I'm trying to create an aggregate like this

CREATE AGGREGATE json_agg_strict(anyelement)(
  SFUNC = json_agg_strict_sfunc,
  STYPE = jsonb,
  FINALFUNC = json_agg_strict_finalfunc,
  INITCOND = '[]'
);

But it deparses to (added newlines for clarity)

CREATE AGGREGATE json_agg_strict ( anyelement ) ( 
  sfunc = json_agg_strict_sfunc , 
  stype = jsonb , 
  finalfunc = json_agg_strict_finalfunc , 
  initcond = []
);

^ it should be initcond = '[]'

Below is how to reproduce

> const parser = require("pgsql-parser")
undefined
> const query = `
... CREATE AGGREGATE json_agg_strict(anyelement)(
...   SFUNC = json_agg_strict_sfunc,
...   STYPE = jsonb,
...   FINALFUNC = json_agg_strict_finalfunc,
...   INITCOND = '[]'
... );
... `;
undefined
> parser.deparse(parser.parse(query))
'CREATE AGGREGATE json_agg_strict ( anyelement ) ( sfunc = json_agg_strict_sfunc , stype = jsonb , finalfunc = json_agg_strict_finalfunc , initcond = [] );'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions