oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.95k stars 94 forks source link

ALTER TYPE public #328

Open mirkadev opened 1 year ago

mirkadev commented 1 year ago

Describe the bug

Cannot alter type with public and without it actually as well

QueryFailedError: 💔 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:

        ALTER TYPE "public"."qualification_rules_name_enum" RENAME TO "qualification_rules_name_enum_old";

    💀 Syntax error at line 1 col 12:

    1  ALTER TYPE "public"."qualification_rules_name_enum" RENAME TO "qualification_rules_name_enum_old";
                  ^
    Unexpected quoted_word token: "public". I did not expect any more input. Here is the state of my parse table:

        kw_index → %word ● 
        kw_sequence → %word ●

To Reproduce


CREATE TYPE "qualification_rules_name_enum" AS ENUM('1', '2', '3');

CREATE TABLE "qualification_rules" ("id" SERIAL NOT NULL, "column" character varying NOT NULL, "settings" jsonb DEFAULT '[]'::jsonb, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "taxonomyId" integer);
ALTER TABLE "qualification_rules" ALTER COLUMN "column" TYPE qualification_rules_name_enum;

-- with public

ALTER TYPE public."qualification_rules_name_enum" RENAME TO "qualification_rules_name_enum_old"

-- and without

ALTER TYPE "qualification_rules_name_enum" RENAME TO "qualification_rules_name_enum_old"

pg-mem version

 cat ./node_modules/pg-mem/package.json | grep version
  "version": "2.6.12",
  "description": "A memory version of postgres",
    "release-deno": "git add -A && git commit -m \"Build deno [autogenerated commit]\" && PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push --tags",
darioackermann commented 1 year ago

This functionality would be awesome to have :), Related bug in the parser https://github.com/oguimbal/pgsql-ast-parser/issues/95