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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query from node-pg-migrate that won't parse - REFERENCES #376

Open
timlesallen opened this issue Jan 4, 2024 · 0 comments
Open

Query from node-pg-migrate that won't parse - REFERENCES #376

timlesallen opened this issue Jan 4, 2024 · 0 comments

Comments

@timlesallen
Copy link

Describe the bug

One of my node-pg-migrate migrations do not parse the SQL correctly.

  馃挃 Your query failed to parse.
    This is most likely due to a SQL syntax error. However, you might also have hit a bug, or an unimplemented feature of pg-mem.
    If this is the case, please file an issue at https://github.com/oguimbal/pg-mem along with a query that reproduces this syntax error.

    馃憠 Failed query:

        CREATE TABLE "partner_referral_agreement" (
      "partner_referral_agreement_id" text PRIMARY KEY NOT NULL,
      "partner_id" text NOT NULL REFERENCES "partner",
      "promo_code" text NOT NULL,
      "created_at" timestamptz NOT NULL,
      "created_by" text NOT NULL,
      "valid_from" timestamptz NOT NULL,
      "valid_to" timestamptz,
      "cancelled_at" timestamptz,
      "cancelled_by" text,
      "payable_amount" numeric(6, 2) NOT NULL
    );
    COMMENT ON COLUMN "partner_referral_agreement"."created_by" IS $pga$The person who input the agreement.$pga$;
    COMMENT ON COLUMN "partner_referral_agreement"."cancelled_by" IS $pga$The person who cancelled the agreement.$pga$;
    COMMENT ON COLUMN "partner_referral_agreement"."payable_amount" IS $pga$positive for payable TO partner, negative for payable TO Amber$pga$;;

    馃拃 Syntax error at line 3 col 50:

    1  COMMENT ON COLUMN "partner_referral_agreement"."created_by" IS $pga$The person who input the agreement.$pga$;
    2  COMMENT ON COLUMN "partner_referral_agreement"."cancelled_by" IS $pga$The person who cancelled the agreement.$pga$;
    3  COMMENT ON COLUMN "partner_referral_agreement"."payable_amount" IS $pga$positive for payable TO partner, negative for payable TO Amber$pga$;;
                                                        ^
    Unexpected comma token: ",". Instead, I was expecting to see one of the following:

        - A "dot" token
        - A "lparen" token

      at parseSql (node_modules/pg-mem/src/parser/parse-cache.ts:55:15)
      at DbSchema.parse (node_modules/pg-mem/src/schema/schema.ts:93:28)
      at DbSchema.queries (node_modules/pg-mem/src/schema/schema.ts:103:31)
          at queries.next (<anonymous>)
      at DbSchema.query (node_modules/pg-mem/src/schema/schema.ts:79:20)
      at MemPg.query (node_modules/pg-mem/src/adapters/adapters.ts:104:76)
      at Object.query (node_modules/node-pg-migrate/dist/db.js:38:33)

To Reproduce

-- create tables
   CREATE TABLE partner (
    "partner_id" text PRIMARY KEY NOT NULL
   );
   CREATE TABLE "partner_referral_agreement" (
      "partner_referral_agreement_id" text PRIMARY KEY NOT NULL,
      "partner_id" text NOT NULL REFERENCES "partner",
      "promo_code" text NOT NULL,
      "created_at" timestamptz NOT NULL,
      "created_by" text NOT NULL,
      "valid_from" timestamptz NOT NULL,
      "valid_to" timestamptz,
      "cancelled_at" timestamptz,
      "cancelled_by" text,
      "payable_amount" numeric(6, 2) NOT NULL
    );

pg-mem version

2.7.4

(nb: the version in your package.json version is often not precise enough... please run "cat ./node_modules/pg-mem/package.json | grep version" to tell which minor version is actually installed)

@timlesallen timlesallen changed the title Query from node-pg-migrate that won't parse - REFERENCES? Query from node-pg-migrate that won't parse - REFERENCES Jan 4, 2024
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