-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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?
What version of drizzle-kit
are you using?
Other packages
drizzle-zod@0.8.3, zod@4.1.9
Describe the Bug
Types aren't being inferred correctly from nested jsonb objects and jsonb arrays. This was working in non beta releases. With only 1 level deep it works, any deeper and its inferred as unknown.
// Array
export const ArraySchema = z.array(z.object({
key: z.string(),
}));
export type ArraySchemaValues = z.infer<typeof ArraySchema>;
array: jsonb()
.$type<ArraySchemaValues>()
.default(sql`'[]'::jsonb`)
const TableSchema = createInsertSchema(table)
type TableSchemaValues = z.infer<typeof TableSchema>
type Array = TableSchemaValues["array"]
// type inferred
type Array = {
[x: number]: unknown;
length: number;
toString: unknown;
toLocaleString: unknown;
pop: unknown;
push: unknown;
concat: unknown;
join: unknown;
reverse: unknown;
shift: unknown;
slice: unknown;
sort: unknown;
splice: unknown;
unshift: unknown;
indexOf: unknown;
lastIndexOf: unknown;
every: unknown;
some: unknown;
forEach: unknown;
map: unknown;
filter: unknown;
reduce: unknown;
reduceRight: unknown;
find: unknown;
findIndex: unknown;
fill: unknown;
copyWithin: unknown;
entries: unknown;
keys: unknown;
values: unknown;
includes: unknown;
flatMap: unknown;
flat: unknown;
at: unknown;
findLast: unknown;
findLastIndex: unknown;
toReversed: unknown;
toSorted: unknown;
toSpliced: unknown;
with: unknown;
[Symbol.iterator]: unknown;
[Symbol.unscopables]: unknown;
} | undefined
// Nested
export const NestedSchema = z.object({
level1: z.object({
level2: z.object({
level3: z.string(),
}),
}),
});
export type NestedSchemaValues = z.infer<typeof NestedSchema>;
nested: jsonb()
.$type<NestedSchemaValues>()
.default(sql`'[]'::jsonb`)
const TableSchema = createInsertSchema(table)
type TableSchemaValues = z.infer<typeof TableSchema>
type Nested = TestSchemaValues["nested"];
// type inferred
type Nested = {
level1: unknown;
} | undefined
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working