Drizzle zod infer wrong type

Using createInsertSchema* with a jsonb field number | null for month is transformed into any
No description
No description
5 Replies
Mukund
Mukund2w ago
Hi, which version of drizzle orm are you using?
Mukund
Mukund2w ago
I tried replicating the issue but am unable to do so.
const test = createTable("test", {
endDate: jsonb().$type<{
year: number;
month: number | null;
}>(),
});

type Test = typeof test.$inferSelect;
const test = createTable("test", {
endDate: jsonb().$type<{
year: number;
month: number | null;
}>(),
});

type Test = typeof test.$inferSelect;
This is what I did.
type Test = {
endDate: {
year: number;
month: number | null;
} | null;
}
type Test = {
endDate: {
year: number;
month: number | null;
} | null;
}
This is what I am getting as the type
No description
No description
Arthur
ArthurOP2w ago
Hi @Mukund , I'm using drizzle-zod package to infer the type, with createInsertSchema method using 0.7.0 drizzle zod, latest drizzle orm 0.39.3 using postgres (pgTable) with createInsertSchema**
Arthur
ArthurOP3d ago
follow up: created an issue related to this @Mario564 thanks for your work on this lib, excited to try rqbv2 !! 🙂
GitHub
[BUG]: create_x_Schema from [email protected] does not infer types ...
Report hasn't been filed before. I have verified that the bug I'm about to report hasn't been filed before. What version of drizzle-orm are you using? 0.39.3 What version of drizzle-kit...
Mario564
Mario5642d ago
Will look into it. Thanks for creating the issue

Did you find this page helpful?