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]:drizzle-zod not working with pgSchema #1458

Closed
KMJ-007 opened this issue Nov 3, 2023 · 10 comments
Closed

[BUG]:drizzle-zod not working with pgSchema #1458

KMJ-007 opened this issue Nov 3, 2023 · 10 comments
Labels
bug Something isn't working db/postgres drizzle/zod

Comments

@KMJ-007
Copy link

KMJ-007 commented Nov 3, 2023

What version of drizzle-orm are you using?

^0.28.6

What version of drizzle-kit are you using?

not using at the moment

Describe the Bug

when trying the pgSchema with drizzle-zod it is not working, works fine when using pgTable

gives the following error:

can't use the schema before initialization

Expected behavior

it should work with pgSchema also, as drizzel supports it!

i checked the code and test in the drizzel-zod there was no test or any mention about pgSchema

Environment & setup

node 20
mac os 14.0

@KMJ-007 KMJ-007 added the bug Something isn't working label Nov 3, 2023
@adicco
Copy link

adicco commented Nov 13, 2023

I can confirm the same regression of drizzle-zod when upgrading drizzle-orm from 0.28 to 0.29:

bun install drizzle-orm@^0.29.0

yields:

1. Argument of type 'SQLiteTableWithColumns<{ name: "users"; schema: undefined; columns: { id: SQLiteColumn<{ name: "id"; tableName: "users"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [...]; baseColumn: never; }, object>; ... 7 more ...; lastSignIn: SQLi...' is not assignable to parameter of type 'Table<TableConfig<Column<any, object, object>>>'.
     Property '[IsDrizzleTable]' is missing in type 'SQLiteTable<{ name: "users"; schema: undefined; columns: { id: SQLiteColumn<{ name: "id"; tableName: "users"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [...]; baseColumn: never; }, object>; ... 7 more ...; lastSignIn: SQLiteColumn<.....' but required in type 'Table<TableConfig<Column<any, object, object>>>'. [2345]

but

bun install drizzle-orm@^0.28.0

completely clears the error. drizzle-zod is at ^0.5.1

@adicco
Copy link

adicco commented Nov 16, 2023

Fixed it in this way: #1515 (comment)

@Angelelz
Copy link
Collaborator

Can we close this as a bun issue?

@KMJ-007
Copy link
Author

KMJ-007 commented Nov 21, 2023

i don't think it is bun issue

i am using yarn and still facing the same issue

@meech-ward
Copy link
Contributor

meech-ward commented Dec 13, 2023

I'm getting

Argument of type 'SQLiteTableWithColumns<{ name: "messages"; schema: undefined; columns: { id: SQLiteColumn<{ name: "id"; tableName: "messages"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, object>; ... 4 more ...; createdAt...' is not assignable to parameter of type 'Table<TableConfig<Column<any, object, object>>>'.
  Property '[IsDrizzleTable]' is missing in type 'SQLiteTable<{ name: "messages"; schema: undefined; columns: { id: SQLiteColumn<{ name: "id"; tableName: "messages"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, object>; ... 4 more ...; createdAt: SQLiteCol...' but required in type 'Table<TableConfig<Column<any, object, object>>>'.ts(2345)
table.d.ts(29, 5): '[IsDrizzleTable]' is declared here.

For this line of code:

export const MessageInsert = createInsertSchema(messages)

With:

    "drizzle-orm": "^0.29.1",
    "drizzle-zod": "^0.5.1",

downgrading to "drizzle-orm": "^0.28.6" fixes this issue

@emnnipal
Copy link

emnnipal commented Jan 9, 2024

I'm having the same issue with mysqlTable

Error:
image

    "drizzle-orm": "^0.29.3",
    "drizzle-zod": "^0.5.1",

@bsShoham
Copy link

I fixed it without needing overrides, by removing lockfile and then reinstalling modules (see my comment #1515 (comment)), that is what worked for me

@bhuynhdev
Copy link

bhuynhdev commented Feb 16, 2024

I was using drizzle-typebox and having same [IsDrizzleTable] issues on bun after upgrading to 0.29.1
It was somehow automatically resolved by removing node_modules and bun.lockb and reinstall everything

@cassianodaniel
Copy link

A pnpm install + "CTRL + SHIFT + P" > Typescript: Restart TS Server solved mine

@AndriiSherman
Copy link
Member

This one was fixed in the latest drizzle-zod@0.6.0

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

No branches or pull requests

10 participants