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

parsePgNestedArray() — drizzle-orm Function Reference

Architecture documentation for the parsePgNestedArray() function in array.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  dc9d1f73_a2ff_12f4_b526_49befc681084["parsePgNestedArray()"]
  130b9d90_0857_a430_5925_31f66ac4c0f5["array.ts"]
  dc9d1f73_a2ff_12f4_b526_49befc681084 -->|defined in| 130b9d90_0857_a430_5925_31f66ac4c0f5
  3f520fc2_e8bc_729c_9692_d952ea93f7f8["parsePgArray()"]
  3f520fc2_e8bc_729c_9692_d952ea93f7f8 -->|calls| dc9d1f73_a2ff_12f4_b526_49befc681084
  9bd8f108_e790_68be_584f_9612a4ca6db5["parsePgArrayValue()"]
  dc9d1f73_a2ff_12f4_b526_49befc681084 -->|calls| 9bd8f108_e790_68be_584f_9612a4ca6db5
  style dc9d1f73_a2ff_12f4_b526_49befc681084 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/pg-core/utils/array.ts lines 26–74

export function parsePgNestedArray(arrayString: string, startFrom = 0): [any[], number] {
	const result: any[] = [];
	let i = startFrom;
	let lastCharIsComma = false;

	while (i < arrayString.length) {
		const char = arrayString[i];

		if (char === ',') {
			if (lastCharIsComma || i === startFrom) {
				result.push('');
			}
			lastCharIsComma = true;
			i++;
			continue;
		}

		lastCharIsComma = false;

		if (char === '\\') {
			i += 2;
			continue;
		}

		if (char === '"') {
			const [value, startFrom] = parsePgArrayValue(arrayString, i + 1, true);
			result.push(value);
			i = startFrom;
			continue;
		}

		if (char === '}') {
			return [result, i + 1];
		}

		if (char === '{') {
			const [value, startFrom] = parsePgNestedArray(arrayString, i + 1);
			result.push(value);
			i = startFrom;
			continue;
		}

		const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
		result.push(value);
		i = newStartFrom;
	}

	return [result, i];
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does parsePgNestedArray() do?
parsePgNestedArray() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/pg-core/utils/array.ts.
Where is parsePgNestedArray() defined?
parsePgNestedArray() is defined in drizzle-orm/src/pg-core/utils/array.ts at line 26.
What does parsePgNestedArray() call?
parsePgNestedArray() calls 1 function(s): parsePgArrayValue.
What calls parsePgNestedArray()?
parsePgNestedArray() is called by 1 function(s): parsePgArray.

Analyze Your Own Codebase

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

Try Supermodel Free