Open cellulosa opened 1 month ago
drizzle-orm
0.30.10
drizzle-kit
0.21.2
I defined a numeric field:
import { pgTable, text, timestamp, numeric } from 'drizzle-orm/pg-core'; import { createInsertSchema, createSelectSchema } from 'drizzle-zod'; export const user = pgTable('user', { id: text('id').primaryKey(), githubId: numeric('github_id').unique() }); export const insertUserSchema = createInsertSchema(user); export const selectUserSchema = createSelectSchema(user);
The types generated with createInsertSchema / createSelectSchema result in:
const insertUserSchema: ZodObject<{ id: ZodString; githubId: ZodOptional<ZodNullable<ZodString>>; },
therefore the parsing fails:
insertUserSchema.parse({ id: generateId(15), githubId: 0123456789 })
numeric() should be converted to ZodNumber
drizzle-zod 0.5.1
for the moment this issue can be circumnavigated by overriding insertUserSchema:
insertUserSchema
export const insertUserSchema = createInsertSchema(user, { githubId: z.number() });
What version of
drizzle-orm
are you using?0.30.10
What version of
drizzle-kit
are you using?0.21.2
Describe the Bug
I defined a numeric field:
The types generated with createInsertSchema / createSelectSchema result in:
therefore the parsing fails:
Expected behavior
numeric() should be converted to ZodNumber
Environment & setup
drizzle-zod 0.5.1