You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drizzle kit incorrectly handles string values with quotes for default statement which leads to syntax errors in PostgreSQL, MySQL, and SQLite.
For this schema:
exportconsttests=pgTable('table',{id: serial('id').primaryKey(),column: text('name').notNull().default("Column's value"),// default value with quote});
generates this SQL:
CREATETABLEIF NOT EXISTS "table" (
"id"serialPRIMARY KEYNOT NULL,
"name"text DEFAULT 'Column's value' NOT NULL);
which leads to this error:
error: syntax error at or near "s"
Expected behavior
The expectation is for the Drizzle kit to generate correct SQL without syntax errors for all supported dialects. Currently, there is a workaround for PostgreSQL and MySQL:
exportconsttests=pgTable('table',{id: serial('id').primaryKey(),column: text('name').notNull().default("Column''s value"),// '' instead of '});
The generated SQL will correctly interpret the two single quotes as a single quote in the application
I got the same issue. The shema generated from SQLite should add quotes to Default value, while it didn't.
"drizzle-orm": "^0.30.8",
"drizzle-kit": "^0.20.14",
What version of
drizzle-orm
are you using?0.30.7
What version of
drizzle-kit
are you using?0.20.14
Describe the Bug
Drizzle kit incorrectly handles string values with quotes for default statement which leads to syntax errors in PostgreSQL, MySQL, and SQLite.
For this schema:
generates this SQL:
which leads to this error:
Expected behavior
The expectation is for the Drizzle kit to generate correct SQL without syntax errors for all supported dialects. Currently, there is a workaround for PostgreSQL and MySQL:
The generated SQL will correctly interpret the two single quotes as a single quote in the application
Environment & setup
No response
The text was updated successfully, but these errors were encountered: