Simon
Simon
DTDrizzle Team
Created by Simon on 6/11/2024 in #help
Drizzle with Zod throws type errors with simple `numeric` example
For example, I define a PostgreSQL table with an input schema:
export const Foo = pgTable('foo', {
bar: numeric('bar'),
});
export const CreateFooSchema = createInsertSchema(Foo);
export const Foo = pgTable('foo', {
bar: numeric('bar'),
});
export const CreateFooSchema = createInsertSchema(Foo);
When using this in my API:
create: protectedProcedure
.input(CreateFooSchema)
.mutation(({ ctx, input }) => {
return ctx.db.insert(Foo).values(input);
}),
create: protectedProcedure
.input(CreateFooSchema)
.mutation(({ ctx, input }) => {
return ctx.db.insert(Foo).values(input);
}),
I get a type error thrown:
Types of property 'bar' are incompatible.
Type 'string | null | undefined' is not assignable to type 'string | SQL<unknown> | Placeholder<string, any> | null'.
Types of property 'bar' are incompatible.
Type 'string | null | undefined' is not assignable to type 'string | SQL<unknown> | Placeholder<string, any> | null'.
This is specifically a problem with the numeric and decimal data types. Other standard data types work fine. Any ideas on a fix?
1 replies