Home / Function/ numberColumnToSchema() — drizzle-orm Function Reference

numberColumnToSchema() — drizzle-orm Function Reference

Architecture documentation for the numberColumnToSchema() function in column.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  265f5c6f_fc43_a51c_a5cf_4949fb963824["numberColumnToSchema()"]
  04df2f9f_a1ec_55a9_5392_86b92a0e6555["column.ts"]
  265f5c6f_fc43_a51c_a5cf_4949fb963824 -->|defined in| 04df2f9f_a1ec_55a9_5392_86b92a0e6555
  c3d8e5a3_48ae_8877_650c_206534a04c0c["columnToSchema()"]
  c3d8e5a3_48ae_8877_650c_206534a04c0c -->|calls| 265f5c6f_fc43_a51c_a5cf_4949fb963824
  bec23d78_9767_fc31_6ba3_e733cef6b3a1["isColumnType()"]
  265f5c6f_fc43_a51c_a5cf_4949fb963824 -->|calls| bec23d78_9767_fc31_6ba3_e733cef6b3a1
  style 265f5c6f_fc43_a51c_a5cf_4949fb963824 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-valibot/src/column.ts lines 128–233

function numberColumnToSchema(column: Column): v.GenericSchema {
	let unsigned = column.getSQLType().includes('unsigned');
	let min!: number;
	let max!: number;
	let integer = false;

	if (isColumnType<MySqlTinyInt<any> | SingleStoreTinyInt<any>>(column, ['MySqlTinyInt', 'SingleStoreTinyInt'])) {
		min = unsigned ? 0 : CONSTANTS.INT8_MIN;
		max = unsigned ? CONSTANTS.INT8_UNSIGNED_MAX : CONSTANTS.INT8_MAX;
		integer = true;
	} else if (
		isColumnType<PgSmallInt<any> | PgSmallSerial<any> | MySqlSmallInt<any> | SingleStoreSmallInt<any>>(column, [
			'PgSmallInt',
			'PgSmallSerial',
			'MySqlSmallInt',
			'SingleStoreSmallInt',
		])
	) {
		min = unsigned ? 0 : CONSTANTS.INT16_MIN;
		max = unsigned ? CONSTANTS.INT16_UNSIGNED_MAX : CONSTANTS.INT16_MAX;
		integer = true;
	} else if (
		isColumnType<
			PgReal<any> | MySqlFloat<any> | MySqlMediumInt<any> | SingleStoreFloat<any> | SingleStoreMediumInt<any>
		>(column, [
			'PgReal',
			'MySqlFloat',
			'MySqlMediumInt',
			'SingleStoreFloat',
			'SingleStoreMediumInt',
		])
	) {
		min = unsigned ? 0 : CONSTANTS.INT24_MIN;
		max = unsigned ? CONSTANTS.INT24_UNSIGNED_MAX : CONSTANTS.INT24_MAX;
		integer = isColumnType(column, ['MySqlMediumInt', 'SingleStoreMediumInt']);
	} else if (
		isColumnType<PgInteger<any> | PgSerial<any> | MySqlInt<any> | SingleStoreInt<any>>(column, [
			'PgInteger',
			'PgSerial',
			'MySqlInt',
			'SingleStoreInt',
		])
	) {
		min = unsigned ? 0 : CONSTANTS.INT32_MIN;
		max = unsigned ? CONSTANTS.INT32_UNSIGNED_MAX : CONSTANTS.INT32_MAX;
		integer = true;
	} else if (
		isColumnType<
			| PgDoublePrecision<any>
			| MySqlReal<any>
			| MySqlDouble<any>
			| SingleStoreReal<any>
			| SingleStoreDouble<any>
			| SQLiteReal<any>
		>(column, [
			'PgDoublePrecision',
			'MySqlReal',
			'MySqlDouble',
			'SingleStoreReal',
			'SingleStoreDouble',
			'SQLiteReal',
		])
	) {
		min = unsigned ? 0 : CONSTANTS.INT48_MIN;
		max = unsigned ? CONSTANTS.INT48_UNSIGNED_MAX : CONSTANTS.INT48_MAX;
	} else if (
		isColumnType<
			| PgBigInt53<any>
			| PgBigSerial53<any>
			| MySqlBigInt53<any>
			| MySqlSerial<any>
			| SingleStoreBigInt53<any>
			| SingleStoreSerial<any>
			| SQLiteInteger<any>
		>(
			column,
			[
				'PgBigInt53',
				'PgBigSerial53',
				'MySqlBigInt53',
				'MySqlSerial',

Subdomains

Called By

Frequently Asked Questions

What does numberColumnToSchema() do?
numberColumnToSchema() is a function in the drizzle-orm codebase, defined in drizzle-valibot/src/column.ts.
Where is numberColumnToSchema() defined?
numberColumnToSchema() is defined in drizzle-valibot/src/column.ts at line 128.
What does numberColumnToSchema() call?
numberColumnToSchema() calls 1 function(s): isColumnType.
What calls numberColumnToSchema()?
numberColumnToSchema() 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