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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: single quote not escaped correctly in migration file #2184

Closed
TanGrumser opened this issue Apr 21, 2024 · 1 comment
Closed

[BUG]: single quote not escaped correctly in migration file #2184

TanGrumser opened this issue Apr 21, 2024 · 1 comment
Labels
bug Something isn't working drizzle/kit

Comments

@TanGrumser
Copy link

What version of drizzle-orm are you using?

0.30.8

What version of drizzle-kit are you using?

0.20.16

Describe the Bug

A schema that contains string literals with single quotes will generate a migration.sql file that contains unescaped single quotes. This leads to syntax errors in the migration file.

An example schema.ts:

export const moveEnum = pgEnum("move", [
  "U", "U2", "U'",
  "u", "u2", "u'",
]);

The generated migration.sql file:

DO $$ BEGIN
 CREATE TYPE "move" AS ENUM('U', 'U2', 'U'', 'u', 'u2', 'u'');
EXCEPTION

The single quotes need to be escaped manually for every migration that contains them.

Expected behavior

The single quotes should be escaped correctly. The migration file should look like

DO $$ BEGIN
 CREATE TYPE "move" AS ENUM('U', 'U2', 'U''', 'u', 'u2', 'u''');
EXCEPTION

where the single quotes are escaped by doubling them.

Environment & setup

node: v20.12.2
npm: v10.5.0
ts: v5.3.3

@TanGrumser TanGrumser added the bug Something isn't working label Apr 21, 2024
@AndriiSherman
Copy link
Member

Was fixed in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working drizzle/kit
Projects
None yet
Development

No branches or pull requests

3 participants