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 parentheses with casting #168

Open
mmkal opened this issue Sep 11, 2024 · 0 comments
Open

incorrect parentheses with casting #168

mmkal opened this issue Sep 11, 2024 · 0 comments

Comments

@mmkal
Copy link

mmkal commented Sep 11, 2024

hi, it seems like some stuff is going wrong with cast-ed jsonb dereferencing:

import * as pgsqlAstParser from 'pgsql-ast-parser'

const input = `select json->'foo'::text->>'bar'::text as bar from json_table`
const ast = pgsqlAstParser.parse(input)[0]
const output = pgsqlAstParser.toSql.statement(ast)

console.log(output) // SELECT ((((json->'foo')::text )->>'bar')::text ) AS bar  FROM **table_with_json

So you can see it casts json->'foo' to text, and then when we try to do ->>'bar', there will be an error because ->> is an operator on jsonb, not text.

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