Skip to content
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

Incorrect parsing of quotes in create aggregate #123

Open
k-koehler opened this issue Jun 25, 2024 · 0 comments
Open

Incorrect parsing of quotes in create aggregate #123

k-koehler opened this issue Jun 25, 2024 · 0 comments

Comments

@k-koehler
Copy link

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 = [] );'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant