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]: Time with precision in drizzle-orm/pg-core adds double-quotes around type #1804

Open
xprnio opened this issue Jan 16, 2024 · 4 comments · May be fixed by #2863
Open

[BUG]: Time with precision in drizzle-orm/pg-core adds double-quotes around type #1804

xprnio opened this issue Jan 16, 2024 · 4 comments · May be fixed by #2863
Assignees
Labels
bug Something isn't working drizzle-kit

Comments

@xprnio
Copy link

xprnio commented Jan 16, 2024

What version of drizzle-orm are you using?

0.29.3

What version of drizzle-kit are you using?

0.20.9

Describe the Bug

export const table = pgTable('table_name', {
  // ...

  time: time('time', { precision: 0 }).notNull(),

  // ...
});

The above table generates the following query:

CREATE TABLE IF NOT EXISTS "table_name" (
  "time" "time(0)" NOT NULL
);

Expected behavior

The above table should instead generate the following query without the double quotes around the type:

CREATE TABLE IF NOT EXISTS "table_name" (
  "time" time(0) NOT NULL
);

Environment & setup

Client: drizzle-orm/pg-core
Driver: pg@8.11.3

@xprnio xprnio added the bug Something isn't working label Jan 16, 2024
@AndriiSherman AndriiSherman self-assigned this Feb 3, 2024
@AndriiSherman
Copy link
Member

Will work on this one

@Uzaaft
Copy link

Uzaaft commented Feb 24, 2024

@AndriiSherman Sorry about the ping, but this is currently a blocker for me. Do you have a timeline?

@yz3440
Copy link

yz3440 commented Apr 14, 2024

I'm having the same problem with pgvector-node in drizzle. I've been just manually removing the quotes from the migration files. Not a huge deal once the specific column is in there and don't get modified, but definitely annoying.

"drizzle-orm": "0.29.4",
"drizzle-kit": "0.20.14",

Describe the Bug

import { vector } from "pgvector/drizzle-orm";

export const table = pgTable('table_name', {
  // ...
   embedding: vector("embedding", { dimensions: 3 }),
  // ...
});

The above table generates the following query:

CREATE TABLE IF NOT EXISTS "table_name" (
   "embedding" "vector(3)",
);

Expected behavior

CREATE TABLE IF NOT EXISTS "table_name" (
   "embedding" vector(3)
);

@mtarroyo
Copy link

mtarroyo commented Aug 27, 2024

I have the same problem with a geography(Point,4326) typed column. When the migration file is generated drizzle-kit put double quotes around it like:

CREATE TABLE IF NOT EXISTS "table_name" (
   "location" "geography(Point,4326)" NOT NULL
);

This will raise an SQL exception saying that the type does not exist.

SQL Error [42704]: ERROR: type "geography(Point,4326)" does not exist

My temporary solution to take advantage of migrations on this specific project was to add a script that read the SQL files generated by drizzle-kit and remove the double quotes for this specific type.

{
    "drizzle:mig": "drizzle-kit migrate && tsx ./remove-pgsql-quotes.ts"
}

This solution solves part of the problem because I can use migrations for production deployment but I still cannot use the drizzle-kit push command while in development environment unless I edit the library source at node_modules.

Openned a pull request on this #2863

mtarroyo added a commit to mtarroyo/drizzle-orm that referenced this issue Aug 27, 2024
…ive types

Changed the portion of the SQL generator code that concatenates the column type to the final SQL statement, preventing the addition of double quotes. Issue drizzle-team#1804
mtarroyo added a commit to mtarroyo/drizzle-orm that referenced this issue Aug 27, 2024
Changed the portion of the SQL generator code that concatenates the column type to the SQL statement, preventing the addition of double quotes. Fix for drizzle-team#1804
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

Successfully merging a pull request may close this issue.

6 participants