handleColumns() — drizzle-orm Function Reference
Architecture documentation for the handleColumns() function in schema.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD af586672_33cc_3a35_8f1d_b940b9fbdc63["handleColumns()"] 91122f81_e9f3_fa04_26c5_a8235e0646d0["schema.ts"] af586672_33cc_3a35_8f1d_b940b9fbdc63 -->|defined in| 91122f81_e9f3_fa04_26c5_a8235e0646d0 a727e62e_da76_c9e6_c82a_6a3c16dd685b["createSelectSchema()"] a727e62e_da76_c9e6_c82a_6a3c16dd685b -->|calls| af586672_33cc_3a35_8f1d_b940b9fbdc63 8972d21e_d0c5_e6ac_93de_abc36d237d78["createInsertSchema()"] 8972d21e_d0c5_e6ac_93de_abc36d237d78 -->|calls| af586672_33cc_3a35_8f1d_b940b9fbdc63 67035096_5922_dd11_cd15_32f5e22e7598["createUpdateSchema()"] 67035096_5922_dd11_cd15_32f5e22e7598 -->|calls| af586672_33cc_3a35_8f1d_b940b9fbdc63 d2723733_6712_bbee_d681_bb39a01d2185["createSchemaFactory()"] d2723733_6712_bbee_d681_bb39a01d2185 -->|calls| af586672_33cc_3a35_8f1d_b940b9fbdc63 3c88ca67_abce_f09c_3f03_3fda2893c4c6["getColumns()"] af586672_33cc_3a35_8f1d_b940b9fbdc63 -->|calls| 3c88ca67_abce_f09c_3f03_3fda2893c4c6 85adcc4b_0e8e_a2e6_a538_afbe19c96304["columnToSchema()"] af586672_33cc_3a35_8f1d_b940b9fbdc63 -->|calls| 85adcc4b_0e8e_a2e6_a538_afbe19c96304 style af586672_33cc_3a35_8f1d_b940b9fbdc63 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-zod/src/schema.ts lines 19–64
function handleColumns(
columns: Record<string, any>,
refinements: Record<string, any>,
conditions: Conditions,
factory?: CreateSchemaFactoryOptions<
Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined
>,
): z.ZodType {
const columnSchemas: Record<string, z.ZodType> = {};
for (const [key, selected] of Object.entries(columns)) {
if (!is(selected, Column) && !is(selected, SQL) && !is(selected, SQL.Aliased) && typeof selected === 'object') {
const columns = isTable(selected) || isView(selected) ? getColumns(selected) : selected;
columnSchemas[key] = handleColumns(columns, refinements[key] ?? {}, conditions, factory);
continue;
}
const refinement = refinements[key];
if (refinement !== undefined && typeof refinement !== 'function') {
columnSchemas[key] = refinement;
continue;
}
const column = is(selected, Column) ? selected : undefined;
const schema = column ? columnToSchema(column, factory) : z.any();
const refined = typeof refinement === 'function' ? refinement(schema) : schema;
if (conditions.never(column)) {
continue;
} else {
columnSchemas[key] = refined;
}
if (column) {
if (conditions.nullable(column)) {
columnSchemas[key] = columnSchemas[key]!.nullable();
}
if (conditions.optional(column)) {
columnSchemas[key] = columnSchemas[key]!.optional();
}
}
}
return z.object(columnSchemas) as any;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does handleColumns() do?
handleColumns() is a function in the drizzle-orm codebase, defined in drizzle-zod/src/schema.ts.
Where is handleColumns() defined?
handleColumns() is defined in drizzle-zod/src/schema.ts at line 19.
What does handleColumns() call?
handleColumns() calls 2 function(s): columnToSchema, getColumns.
What calls handleColumns()?
handleColumns() is called by 4 function(s): createInsertSchema, createSchemaFactory, createSelectSchema, createUpdateSchema.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free