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

deparse altered "COMMENT ON COLUMN" statement, the string is escaped and a ' is removed #50

Open
divyenduz opened this issue Oct 21, 2021 · 0 comments

Comments

@divyenduz
Copy link

Original query (with fingerprint 7bbdf5f425075dd4):

COMMENT ON COLUMN public.posts.reply_to_post_number IS 'If this post is a reply to another, this column is the post_number of the post it''s replying to. [FKEY posts.topic_id, posts.post_number]'

Deparsed query (with fingerprint 0):

COMMENT ON COLUMN public.posts.reply_to_post_number IS E'If this post is a reply to another, this column is the post_number of the post it's replying to. [FKEY posts.topic_id, posts.post_number]';
  • The deparsed query also fails parsing with Error: syntax error at or near "s" 🤔

To reproduce:

const fs = require('fs')
const { parse, deparse } = require('pgsql-parser');

async function main() {
    const stmts = parse(`
COMMENT ON COLUMN public.posts.reply_to_post_number IS 'If this post is a reply to another, this column is the post_number of the post it''s replying to. [FKEY posts.topic_id, posts.post_number]'
    `)
    const stmts2 = deparse(stmts[0])
    console.log(stmts2)
}

main()

Schema at https://github.com/prisma/database-schema-examples/tree/main/postgres/discourse

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