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 "CREATE TABLE" statement, removed quotes from column name #52

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

Comments

@divyenduz
Copy link

Original query (with fingerprint 45a041188bab2ec5):


CREATE TABLE public.ci_builds_runner_session (
    id bigint NOT NULL,
    build_id integer NOT NULL,
    url character varying NOT NULL,
    certificate character varying,
    "authorization" character varying
)

Deparsed query (with fingerprint 0):

CREATE TABLE public.ci_builds_runner_session (
 	id bigint NOT NULL,
	build_id int NOT NULL,
	url varchar NOT NULL,
	certificate varchar,
	authorization varchar 
);

And since authorization is a keyword, the deparsed query fails to parse again.

To reproduce:

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

async function main() {
    const stmts = parse(`
      
CREATE TABLE public.ci_builds_runner_session (
    id bigint NOT NULL,
    build_id integer NOT NULL,
    url character varying NOT NULL,
    certificate character varying,
    "authorization" character varying
)
    `)
    const stmts2 = deparse(stmts[0])
    console.log(stmts2)
}

main()

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

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