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

mapSqlToSqliteType() — drizzle-orm Function Reference

Architecture documentation for the mapSqlToSqliteType() function in sqliteSerializer.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  282d78ed_ea0e_1e4d_d10d_b7b8473abb46["mapSqlToSqliteType()"]
  8e6879a2_2b61_04aa_8765_25bc6cfe77be["sqliteSerializer.ts"]
  282d78ed_ea0e_1e4d_d10d_b7b8473abb46 -->|defined in| 8e6879a2_2b61_04aa_8765_25bc6cfe77be
  31460848_0b68_376e_2389_5130b321a073["fromDatabase()"]
  31460848_0b68_376e_2389_5130b321a073 -->|calls| 282d78ed_ea0e_1e4d_d10d_b7b8473abb46
  style 282d78ed_ea0e_1e4d_d10d_b7b8473abb46 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/serializer/sqliteSerializer.ts lines 413–459

function mapSqlToSqliteType(sqlType: string): string {
	const lowered = sqlType.toLowerCase();
	if (
		[
			'int',
			'integer',
			'integer auto_increment',
			'tinyint',
			'smallint',
			'mediumint',
			'bigint',
			'unsigned big int',
			'int2',
			'int8',
		].some((it) => lowered.startsWith(it))
	) {
		return 'integer';
	} else if (
		[
			'character',
			'varchar',
			'varying character',
			'national varying character',
			'nchar',
			'native character',
			'nvarchar',
			'text',
			'clob',
		].some((it) => lowered.startsWith(it))
	) {
		const match = lowered.match(/\d+/);

		if (match) {
			return `text(${match[0]})`;
		}

		return 'text';
	} else if (lowered.startsWith('blob')) {
		return 'blob';
	} else if (
		['real', 'double', 'double precision', 'float'].some((it) => lowered.startsWith(it))
	) {
		return 'real';
	} else {
		return 'numeric';
	}
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does mapSqlToSqliteType() do?
mapSqlToSqliteType() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/serializer/sqliteSerializer.ts.
Where is mapSqlToSqliteType() defined?
mapSqlToSqliteType() is defined in drizzle-kit/src/serializer/sqliteSerializer.ts at line 413.
What calls mapSqlToSqliteType()?
mapSqlToSqliteType() is called by 1 function(s): fromDatabase.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free