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);


When using this in my API:
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'.


This is specifically a problem with the numeric and decimal data types. Other standard data types work fine.

Any ideas on a fix?
Was this page helpful?