column() — drizzle-orm Function Reference
Architecture documentation for the column() function in introspect-pg.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 7e9ab2b5_7980_e5af_4e4d_69d8d084e595["column()"] 71516551_23e3_bf30_27c9_000fb046ef71["introspect-pg.ts"] 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 -->|defined in| 71516551_23e3_bf30_27c9_000fb046ef71 d060c9b2_d1df_37e7_df71_422307a42ed6["createTableColumns()"] d060c9b2_d1df_37e7_df71_422307a42ed6 -->|calls| 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 968467a1_c4a6_11cb_5fbc_8854071f9af4["withCasing()"] 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 -->|calls| 968467a1_c4a6_11cb_5fbc_8854071f9af4 9033c8cf_1cd9_c420_437a_01e7a84a9869["paramNameFor()"] 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 -->|calls| 9033c8cf_1cd9_c420_437a_01e7a84a9869 54ebb7a1_9ae1_841a_2a01_cd541465c33b["dbColumnName()"] 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 -->|calls| 54ebb7a1_9ae1_841a_2a01_cd541465c33b 61ec562c_fa8e_dd0d_c7c0_f887731d9753["timeConfig()"] 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 -->|calls| 61ec562c_fa8e_dd0d_c7c0_f887731d9753 0ac6ca12_fe1f_7133_5329_f66feb39896f["intervalConfig()"] 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 -->|calls| 0ac6ca12_fe1f_7133_5329_f66feb39896f style 7e9ab2b5_7980_e5af_4e4d_69d8d084e595 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/introspect-pg.ts lines 838–1101
const column = (
tableName: string,
type: string,
name: string,
enumTypes: Set<string>,
typeSchema: string,
casing: Casing,
defaultValue?: any,
internals?: PgKitInternals,
) => {
const isExpression = internals?.tables[tableName]?.columns[name]?.isDefaultAnExpression ?? false;
const lowered = type.toLowerCase().replace('[]', '');
if (enumTypes.has(`${typeSchema}.${type.replace('[]', '')}`)) {
let out = `${withCasing(name, casing)}: ${withCasing(paramNameFor(type.replace('[]', ''), typeSchema), casing)}(${
dbColumnName({ name, casing })
})`;
return out;
}
if (lowered.startsWith('serial')) {
return `${withCasing(name, casing)}: serial(${dbColumnName({ name, casing })})`;
}
if (lowered.startsWith('smallserial')) {
return `${withCasing(name, casing)}: smallserial(${dbColumnName({ name, casing })})`;
}
if (lowered.startsWith('bigserial')) {
return `${withCasing(name, casing)}: bigserial(${
dbColumnName({ name, casing, withMode: true })
}{ mode: "bigint" })`;
}
if (lowered.startsWith('integer')) {
let out = `${withCasing(name, casing)}: integer(${dbColumnName({ name, casing })})`;
return out;
}
if (lowered.startsWith('smallint')) {
let out = `${withCasing(name, casing)}: smallint(${dbColumnName({ name, casing })})`;
return out;
}
if (lowered.startsWith('bigint')) {
let out = `// You can use { mode: "bigint" } if numbers are exceeding js number limitations\n\t`;
out += `${withCasing(name, casing)}: bigint(${dbColumnName({ name, casing, withMode: true })}{ mode: "number" })`;
return out;
}
if (lowered.startsWith('boolean')) {
let out = `${withCasing(name, casing)}: boolean(${dbColumnName({ name, casing })})`;
return out;
}
if (lowered.startsWith('double precision')) {
let out = `${withCasing(name, casing)}: doublePrecision(${dbColumnName({ name, casing })})`;
return out;
}
if (lowered.startsWith('real')) {
let out = `${withCasing(name, casing)}: real(${dbColumnName({ name, casing })})`;
return out;
}
if (lowered.startsWith('uuid')) {
let out = `${withCasing(name, casing)}: uuid(${dbColumnName({ name, casing })})`;
return out;
}
if (lowered.startsWith('numeric')) {
let params: { precision: string | undefined; scale: string | undefined } | undefined;
if (lowered.length > 7) {
const [precision, scale] = lowered.slice(8, lowered.length - 1).split(',');
params = { precision, scale };
}
let out = params
? `${withCasing(name, casing)}: numeric(${dbColumnName({ name, casing, withMode: true })}${timeConfig(params)})`
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does column() do?
column() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/introspect-pg.ts.
Where is column() defined?
column() is defined in drizzle-kit/src/introspect-pg.ts at line 838.
What does column() call?
column() calls 5 function(s): dbColumnName, intervalConfig, paramNameFor, timeConfig, withCasing.
What calls column()?
column() is called by 1 function(s): createTableColumns.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free