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
  81e6cc0b_4b4d_b95d_8ebc_52116ecb0fd0["convert()"]
  edb57f7c_c768_0b48_d2bc_7220861f9727["PgCreateIndPolicyConvertor"]
  81e6cc0b_4b4d_b95d_8ebc_52116ecb0fd0 -->|defined in| edb57f7c_c768_0b48_d2bc_7220861f9727
  style 81e6cc0b_4b4d_b95d_8ebc_52116ecb0fd0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/sqlgenerator.ts lines 298–310

	override convert(statement: JsonCreateIndPolicyStatement): string | string[] {
		const policy = statement.data;

		const usingPart = policy.using ? ` USING (${policy.using})` : '';

		const withCheckPart = policy.withCheck ? ` WITH CHECK (${policy.withCheck})` : '';

		const policyToPart = policy.to?.map((v) =>
			['current_user', 'current_role', 'session_user', 'public'].includes(v) ? v : `"${v}"`
		).join(', ');

		return `CREATE POLICY "${policy.name}" ON ${policy.on} AS ${policy.as?.toUpperCase()} FOR ${policy.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
	}

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 298.

Analyze Your Own Codebase

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

Try Supermodel Free