© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
1 reply
dion

drizzle-zod not infering jsonb type properly

I have the following table
export const dataQueryRun = pgTable('data_query_run', {
    ...
    parameters: jsonb('parameters').notNull().$type<Record<string, unknown>>(),
        ...
});
export const dataQueryRun = pgTable('data_query_run', {
    ...
    parameters: jsonb('parameters').notNull().$type<Record<string, unknown>>(),
        ...
});

And i use drizzle-zod to do the following types:
const selectDataQueryRunSchema = createSelectSchema(dataQueryRun, {
    logs: z.array(z.string())
});
export type TDataQueryRun = z.infer<typeof selectDataQueryRunSchema>;
const selectDataQueryRunSchema = createSelectSchema(dataQueryRun, {
    logs: z.array(z.string())
});
export type TDataQueryRun = z.infer<typeof selectDataQueryRunSchema>;

I get this:
type TDataQueryRun = {
   ...
    parameters: ((string | number | boolean | {
        [key: string]: Json;
    } | Json[]) & (string | ... 4 more ... | undefined)) | null;
}
type TDataQueryRun = {
   ...
    parameters: ((string | number | boolean | {
        [key: string]: Json;
    } | Json[]) & (string | ... 4 more ... | undefined)) | null;
}


instead of this:
type TDataQueryRun = {
   ...
    parameters: Record<string,unknown>
}
type TDataQueryRun = {
   ...
    parameters: Record<string,unknown>
}


Does anybody know why and how to fix this?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

drizzle-zod type infer
Drizzle TeamDTDrizzle Team / help
3y ago
help with drizzle-zod with jsonb column
Drizzle TeamDTDrizzle Team / help
3y ago
Problem with infering json type in zod schema
Drizzle TeamDTDrizzle Team / help
3y ago
Drizzle zod infer wrong type
Drizzle TeamDTDrizzle Team / help
12mo ago