stringColumnToSchema() — drizzle-orm Function Reference
Architecture documentation for the stringColumnToSchema() function in column.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 7ef23a38_3367_a4e9_510e_239e7cff2a71["stringColumnToSchema()"] 56015c82_287b_9f6e_abba_3d7f471c1e5c["column.ts"] 7ef23a38_3367_a4e9_510e_239e7cff2a71 -->|defined in| 56015c82_287b_9f6e_abba_3d7f471c1e5c 06e21ad5_4a79_38ca_ddc3_d0ed3cb1ab5c["columnToSchema()"] 06e21ad5_4a79_38ca_ddc3_d0ed3cb1ab5c -->|calls| 7ef23a38_3367_a4e9_510e_239e7cff2a71 style 7ef23a38_3367_a4e9_510e_239e7cff2a71 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-typebox/src/column.ts lines 261–314
function stringColumnToSchema(column: Column, t: typeof typebox): TSchema {
if (isColumnType<PgUUID<ColumnBaseConfig<'string', 'PgUUID'>>>(column, ['PgUUID'])) {
return t.String({ format: 'uuid' });
} else if (
isColumnType<PgBinaryVector<ColumnBaseConfig<'string', 'PgBinaryVector'> & { dimensions: number }>>(column, [
'PgBinaryVector',
])
) {
return t.RegExp(/^[01]+$/, column.dimensions ? { maxLength: column.dimensions } : undefined);
}
let max: number | undefined;
let fixed = false;
if (isColumnType<PgVarchar<any> | SQLiteText<any>>(column, ['PgVarchar', 'SQLiteText'])) {
max = column.length;
} else if (
isColumnType<MySqlVarChar<any> | SingleStoreVarChar<any>>(column, ['MySqlVarChar', 'SingleStoreVarChar'])
) {
max = column.length ?? CONSTANTS.INT16_UNSIGNED_MAX;
} else if (isColumnType<MySqlText<any> | SingleStoreText<any>>(column, ['MySqlText', 'SingleStoreText'])) {
if (column.textType === 'longtext') {
max = CONSTANTS.INT32_UNSIGNED_MAX;
} else if (column.textType === 'mediumtext') {
max = CONSTANTS.INT24_UNSIGNED_MAX;
} else if (column.textType === 'text') {
max = CONSTANTS.INT16_UNSIGNED_MAX;
} else {
max = CONSTANTS.INT8_UNSIGNED_MAX;
}
}
if (
isColumnType<PgChar<any> | MySqlChar<any> | SingleStoreChar<any>>(column, [
'PgChar',
'MySqlChar',
'SingleStoreChar',
])
) {
max = column.length;
fixed = true;
}
const options: Partial<StringOptions> = {};
if (max !== undefined && fixed) {
options.minLength = max;
options.maxLength = max;
} else if (max !== undefined) {
options.maxLength = max;
}
return t.String(Object.keys(options).length > 0 ? options : undefined);
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does stringColumnToSchema() do?
stringColumnToSchema() is a function in the drizzle-orm codebase, defined in drizzle-typebox/src/column.ts.
Where is stringColumnToSchema() defined?
stringColumnToSchema() is defined in drizzle-typebox/src/column.ts at line 261.
What calls stringColumnToSchema()?
stringColumnToSchema() is called by 1 function(s): columnToSchema.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free