column.types.ts — drizzle-orm Source File
Architecture documentation for column.types.ts, a typescript file in the drizzle-orm codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 2be77f5f_e94f_b91a_88e0_947351113ff1["column.types.ts"] 90807ef2_6e28_df2f_8c6b_9bcb1bab99ec["utils.ts"] 2be77f5f_e94f_b91a_88e0_947351113ff1 --> 90807ef2_6e28_df2f_8c6b_9bcb1bab99ec 690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"] 2be77f5f_e94f_b91a_88e0_947351113ff1 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031 2eba3e52_10ef_4b48_38fc_0e1540a5fc3e["v4"] 2be77f5f_e94f_b91a_88e0_947351113ff1 --> 2eba3e52_10ef_4b48_38fc_0e1540a5fc3e acfeaa81_8bd9_605a_74e7_52a36a49babb["schema.types.internal.ts"] acfeaa81_8bd9_605a_74e7_52a36a49babb --> 2be77f5f_e94f_b91a_88e0_947351113ff1 style 2be77f5f_e94f_b91a_88e0_947351113ff1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { Assume, Column } from 'drizzle-orm';
import type { z } from 'zod/v4';
import type { IsEnumDefined, IsNever, Json } from './utils.ts';
type HasBaseColumn<TColumn> = TColumn extends { _: { baseColumn: Column | undefined } }
? IsNever<TColumn['_']['baseColumn']> extends false ? true
: false
: false;
export type GetZodType<
TColumn extends Column,
TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined,
> = HasBaseColumn<TColumn> extends true ? z.ZodArray<
GetZodType<Assume<TColumn['_']['baseColumn'], Column>, TCoerce>
>
: TColumn['_']['columnType'] extends 'PgUUID' ? z.ZodUUID
: IsEnumDefined<TColumn['_']['enumValues']> extends true
? z.ZodEnum<{ [K in Assume<TColumn['_']['enumValues'], [string, ...string[]]>[number]]: K }>
: TColumn['_']['columnType'] extends 'PgGeometry' | 'PgPointTuple' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>
: TColumn['_']['columnType'] extends 'PgLine' ? z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>
: TColumn['_']['data'] extends Date ? CanCoerce<TCoerce, 'date'> extends true ? z.coerce.ZodCoercedDate : z.ZodDate
: TColumn['_']['data'] extends Buffer ? z.ZodType<Buffer>
: TColumn['_']['dataType'] extends 'array'
? z.ZodArray<GetZodPrimitiveType<Assume<TColumn['_']['data'], any[]>[number], '', TCoerce>>
: TColumn['_']['data'] extends Record<string, any>
? TColumn['_']['columnType'] extends
'PgJson' | 'PgJsonb' | 'MySqlJson' | 'SingleStoreJson' | 'SQLiteTextJson' | 'SQLiteBlobJson'
? z.ZodType<TColumn['_']['data'], TColumn['_']['data']>
: z.ZodObject<
{ [K in keyof TColumn['_']['data']]: GetZodPrimitiveType<TColumn['_']['data'][K], '', TCoerce> },
{ out: {}; in: {} }
>
: TColumn['_']['dataType'] extends 'json' ? z.ZodType<Json>
: GetZodPrimitiveType<TColumn['_']['data'], TColumn['_']['columnType'], TCoerce>;
type CanCoerce<
TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined,
TTo extends 'bigint' | 'boolean' | 'date' | 'number' | 'string',
> = TCoerce extends true ? true
: TCoerce extends Record<string, any> ? TCoerce[TTo] extends true ? true
: false
: false;
type GetZodPrimitiveType<
TData,
TColumnType,
TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined,
> = TColumnType extends
| 'MySqlTinyInt'
| 'SingleStoreTinyInt'
| 'PgSmallInt'
| 'PgSmallSerial'
| 'MySqlSmallInt'
| 'MySqlMediumInt'
| 'SingleStoreSmallInt'
| 'SingleStoreMediumInt'
| 'PgInteger'
| 'PgSerial'
| 'MySqlInt'
| 'SingleStoreInt'
| 'PgBigInt53'
| 'PgBigSerial53'
| 'MySqlBigInt53'
| 'MySqlSerial'
| 'SingleStoreBigInt53'
| 'SingleStoreSerial'
| 'SQLiteInteger'
| 'MySqlYear'
| 'SingleStoreYear' ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodInt
: TData extends number ? CanCoerce<TCoerce, 'number'> extends true ? z.coerce.ZodCoercedNumber : z.ZodNumber
: TData extends bigint ? CanCoerce<TCoerce, 'bigint'> extends true ? z.coerce.ZodCoercedBigInt : z.ZodBigInt
: TData extends boolean ? CanCoerce<TCoerce, 'boolean'> extends true ? z.coerce.ZodCoercedBoolean : z.ZodBoolean
: TData extends string ? CanCoerce<TCoerce, 'string'> extends true ? z.coerce.ZodCoercedString : z.ZodString
: z.ZodType;
type HandleSelectColumn<
TSchema extends z.ZodType,
TColumn extends Column,
> = TColumn['_']['notNull'] extends true ? TSchema
: z.ZodNullable<TSchema>;
type HandleInsertColumn<
TSchema extends z.ZodType,
TColumn extends Column,
> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? z.ZodOptional<TSchema>
: TSchema
: z.ZodOptional<z.ZodNullable<TSchema>>;
type HandleUpdateColumn<
TSchema extends z.ZodType,
TColumn extends Column,
> = TColumn['_']['notNull'] extends true ? z.ZodOptional<TSchema>
: z.ZodOptional<z.ZodNullable<TSchema>>;
export type HandleColumn<
TType extends 'select' | 'insert' | 'update',
TColumn extends Column,
TCoerce extends Partial<Record<'bigint' | 'boolean' | 'date' | 'number' | 'string', true>> | true | undefined,
> = TType extends 'select' ? HandleSelectColumn<GetZodType<TColumn, TCoerce>, TColumn>
: TType extends 'insert' ? HandleInsertColumn<GetZodType<TColumn, TCoerce>, TColumn>
: TType extends 'update' ? HandleUpdateColumn<GetZodType<TColumn, TCoerce>, TColumn>
: GetZodType<TColumn, TCoerce>;
Domain
Types
Dependencies
- drizzle-orm
- utils.ts
- v4
Imported By
Source
Frequently Asked Questions
What does column.types.ts do?
column.types.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the ValidationAdapters domain.
What does column.types.ts depend on?
column.types.ts imports 3 module(s): drizzle-orm, utils.ts, v4.
What files import column.types.ts?
column.types.ts is imported by 1 file(s): schema.types.internal.ts.
Where is column.types.ts in the architecture?
column.types.ts is located at drizzle-zod/src/column.types.ts (domain: ValidationAdapters, directory: drizzle-zod/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free