parsePgArray.test.ts — drizzle-orm Source File
Architecture documentation for parsePgArray.test.ts, a typescript file in the drizzle-orm codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4aa7ac89_99e8_bc85_6ac5_7f9126f21142["parsePgArray.test.ts"] 8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"] 4aa7ac89_99e8_bc85_6ac5_7f9126f21142 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686 fa14e9c0_b73d_4bcb_463b_adf18df8a285["index.ts"] 4aa7ac89_99e8_bc85_6ac5_7f9126f21142 --> fa14e9c0_b73d_4bcb_463b_adf18df8a285 style 4aa7ac89_99e8_bc85_6ac5_7f9126f21142 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { describe, it } from 'vitest';
import { customType, pgTable } from '~/pg-core/index.ts';
const anyColumn = customType<{ data: any }>({
dataType() {
return 'any';
},
});
const table = pgTable('test', {
a: anyColumn('a').array(),
b: anyColumn('a').array().array(),
});
describe.concurrent('parsePgArray', () => {
it('parses simple 1D array', ({ expect }) => {
const input = '{1,2,3}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['1', '2', '3']);
});
it('parses simple 2D array', ({ expect }) => {
const input = '{{1,2,3},{4,5,6},{7,8,9}}';
const output = table.b.mapFromDriverValue(input);
expect(output).toEqual([
['1', '2', '3'],
['4', '5', '6'],
['7', '8', '9'],
]);
});
it('parses array with quoted values', ({ expect }) => {
const input = '{1,"2,3",4}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['1', '2,3', '4']);
});
it('parses array with nested quoted values', ({ expect }) => {
const input = '{{1,"2,3",4},{5,"6,7",8}}';
const output = table.b.mapFromDriverValue(input);
expect(output).toEqual([
['1', '2,3', '4'],
['5', '6,7', '8'],
]);
});
it('parses array with empty values', ({ expect }) => {
const input = '{1,"",3}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['1', '', '3']);
});
it('parses array with empty nested values', ({ expect }) => {
const input = '{{1,2,3},{,5,6},{7,8,9}}';
const output = table.b.mapFromDriverValue(input);
expect(output).toEqual([
['1', '2', '3'],
['', '5', '6'],
['7', '8', '9'],
]);
});
it('parses empty array', ({ expect }) => {
const input = '{}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual([]);
});
it('parses empty nested array', ({ expect }) => {
const input = '{{}}';
const output = table.b.mapFromDriverValue(input);
expect(output).toEqual([[]]);
});
it('parses single-level array with strings', ({ expect }) => {
const input = '{"one","two","three"}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['one', 'two', 'three']);
});
it('parses single-level array with mixed values', ({ expect }) => {
const input = '{1,"two",3}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['1', 'two', '3']);
});
it('parses single-level array with commas inside quotes', ({ expect }) => {
const input = '{1,"two, three",4}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['1', 'two, three', '4']);
});
it('parses single-level array with escaped quotes inside quotes', ({ expect }) => {
const input = '{1,"two \\"three\\", four",5}';
const output = table.a.mapFromDriverValue(input);
expect(output).toEqual(['1', 'two "three", four', '5']);
});
it('parses two-dimensional array with strings', ({ expect }) => {
const input = '{{"one","two",three},{"four",five,"six"},{seven,eight,"nine"}}';
const output = table.b.mapFromDriverValue(input);
expect(output).toEqual([
['one', 'two', 'three'],
['four', 'five', 'six'],
['seven', 'eight', 'nine'],
]);
});
it('parses two-dimensional array with mixed values and escaped quotes', ({ expect }) => {
const input =
'{{1,"two \\"and a half\\", three",3},{"four","five \\"and a half\\", six",6},{"seven","eight","nine"}}';
const output = table.b.mapFromDriverValue(input);
expect(output).toEqual([
['1', 'two "and a half", three', '3'],
['four', 'five "and a half", six', '6'],
['seven', 'eight', 'nine'],
]);
});
});
Domain
Subdomains
Functions
Dependencies
- index.ts
- vitest
Source
Frequently Asked Questions
What does parsePgArray.test.ts do?
parsePgArray.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, RelationalQuery subdomain.
What functions are defined in parsePgArray.test.ts?
parsePgArray.test.ts defines 1 function(s): anyColumn.dataType.
What does parsePgArray.test.ts depend on?
parsePgArray.test.ts imports 2 module(s): index.ts, vitest.
Where is parsePgArray.test.ts in the architecture?
parsePgArray.test.ts is located at drizzle-orm/tests/parsePgArray.test.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: drizzle-orm/tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free