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

convert() — drizzle-orm Function Reference

Architecture documentation for the convert() function in sqlgenerator.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  a68c9525_35a2_06ea_47c5_2757768f9f03["convert()"]
  01959b95_70b4_ccae_6c93_53d172a9e0cc["CreateSqliteIndexConvertor"]
  a68c9525_35a2_06ea_47c5_2757768f9f03 -->|defined in| 01959b95_70b4_ccae_6c93_53d172a9e0cc
  style a68c9525_35a2_06ea_47c5_2757768f9f03 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/sqlgenerator.ts lines 3610–3628

	convert(statement: JsonCreateIndexStatement): string {
		// should be changed
		const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
			statement.data,
		);
		// // since postgresql 9.5
		const indexPart = isUnique ? 'UNIQUE INDEX' : 'INDEX';
		const whereStatement = where ? ` WHERE ${where}` : '';
		const uniqueString = columns
			.map((it) => {
				return statement.internal?.indexes
					? statement.internal?.indexes[name]?.columns[it]?.isExpression
						? it
						: `\`${it}\``
					: `\`${it}\``;
			})
			.join(',');
		return `CREATE ${indexPart} \`${name}\` ON \`${statement.tableName}\` (${uniqueString})${whereStatement};`;
	}

Domain

Subdomains

Frequently Asked Questions

What does convert() do?
convert() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/sqlgenerator.ts.
Where is convert() defined?
convert() is defined in drizzle-kit/src/sqlgenerator.ts at line 3610.

Analyze Your Own Codebase

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

Try Supermodel Free