drawdb icon indicating copy to clipboard operation
drawdb copied to clipboard

[Bug] PostgreSQL - Import SQL faild when using custom type with double quotes

Open ifrvn opened this issue 1 year ago • 1 comments

When setting a custom type with double quotes in create table, import this sql file, drawdb throws an error.

CREATE TYPE "Gender" AS ENUM ('F', 'M', 'U');

CREATE TABLE "User" (
    "id" SERIAL NOT NULL,
    "gender" "Gender" NOT NULL,

    CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

image

SyntaxError [Ln 5, Col 14]: Expected "--", "->", "->>", ".", "/*", "BIGINT", "BIGSERIAL", "BOOL", "BOOLEAN", "CHAR", "CHARACTER", "DATE", "DATETIME", "DECIMAL", "DOUBLE", "ENUM", "FLOAT", "GEOMETRY", "INT", "INTEGER", "INTERVAL", "JSON", "JSONB", "LONGTEXT", "MEDIUMTEXT", "NUMERIC", "OID", "REAL", "RECORD", "REGCLASS", "REGCOLLATION", "REGCONFIG", "REGDICTIONARY", "REGNAMESPACE", "REGOPER", "REGOPERATOR", "REGPROC", "REGPROCEDURE", "REGROLE", "REGTYPE", "SERIAL", "SMALLINT", "TEXT", "TIME", "TIMESTAMP", "TINYINT", "TINYTEXT", "UUID", "VARCHAR", "bytea", [ \t\n\r], or [A-Za-z_一-龥] but """ found.

If I remove double quotes from "gender" "Gender" NOT NULL,, it'll work.

ifrvn avatar Jul 31 '24 06:07 ifrvn

Submitted an issue for this https://github.com/taozhi8833998/node-sql-parser/issues/2045.

1ilit avatar Aug 01 '24 08:08 1ilit

@1ilit I've submitted PR #607 that fixes this issue. The solution preprocesses PostgreSQL SQL to handle quoted custom types during import. Tested with the example SQL from this issue - now imports successfully.

sanki92 avatar Oct 03 '25 17:10 sanki92