Drizzle kit incorrectly handles string values with quotes for default statement which leads to syntax errors in PostgreSQL, MySQL, and SQLite.
For this schema:
export const tests = pgTable('table', {
id: serial('id').primaryKey(),
column: text('name').notNull().default("Column's value"), // default value with quote
});
generates this SQL:
CREATE TABLE IF NOT EXISTS "table" (
"id" serial PRIMARY KEY NOT 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:
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