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

buildArrayDefault() — drizzle-orm Function Reference

Architecture documentation for the buildArrayDefault() function in introspect-pg.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  b87c196f_7e95_6fa2_a5ef_339aa1ab6107["buildArrayDefault()"]
  71516551_23e3_bf30_27c9_000fb046ef71["introspect-pg.ts"]
  b87c196f_7e95_6fa2_a5ef_339aa1ab6107 -->|defined in| 71516551_23e3_bf30_27c9_000fb046ef71
  f3c4f27e_519e_55a5_f4bc_bca97865abec["mapDefault()"]
  f3c4f27e_519e_55a5_f4bc_bca97865abec -->|calls| b87c196f_7e95_6fa2_a5ef_339aa1ab6107
  style b87c196f_7e95_6fa2_a5ef_339aa1ab6107 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-kit/src/introspect-pg.ts lines 648–671

const buildArrayDefault = (defaultValue: string, typeName: string): string => {
	if (typeof defaultValue === 'string' && !(defaultValue.startsWith('{') || defaultValue.startsWith("'{"))) {
		return `sql\`${defaultValue}\``;
	}
	defaultValue = defaultValue.substring(2, defaultValue.length - 2);
	return `[${
		defaultValue
			.split(/\s*,\s*/g)
			.map((value) => {
				// 	if (['integer', 'smallint', 'bigint', 'double precision', 'real'].includes(typeName)) {
				// 		return value;
				// 	} else if (typeName === 'interval') {
				// 		return value.replaceAll('"', "'");
				// 	} else if (typeName === 'boolean') {
				// 		return value === 't' ? 'true' : 'false';
				if (typeName === 'json' || typeName === 'jsonb') {
					return value.substring(1, value.length - 1).replaceAll('\\', '');
				}
				return value;
				// 	}
			})
			.join(', ')
	}]`;
};

Domain

Subdomains

Called By

Frequently Asked Questions

What does buildArrayDefault() do?
buildArrayDefault() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/introspect-pg.ts.
Where is buildArrayDefault() defined?
buildArrayDefault() is defined in drizzle-kit/src/introspect-pg.ts at line 648.
What calls buildArrayDefault()?
buildArrayDefault() is called by 1 function(s): mapDefault.

Analyze Your Own Codebase

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

Try Supermodel Free