Home / File/ pg.test.ts — drizzle-orm Source File

pg.test.ts — drizzle-orm Source File

Architecture documentation for pg.test.ts, a typescript file in the drizzle-orm codebase. 12 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060["pg.test.ts"]
  d598d354_5597_b2a3_e5c1_d26e5e904917["index.ts"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> d598d354_5597_b2a3_e5c1_d26e5e904917
  b6483f8f_39d9_6c02_34b8_9a3df7d428eb["utils.ts"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> b6483f8f_39d9_6c02_34b8_9a3df7d428eb
  351303ed_bdd3_50f4_eb38_e21ac19bc263["Expect"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 351303ed_bdd3_50f4_eb38_e21ac19bc263
  fcac7d98_f9df_bed2_a286_025bcede47fc["expectEnumValues"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> fcac7d98_f9df_bed2_a286_025bcede47fc
  2a85cab2_0338_353c_a5f7_46964a1b85f9["expectSchemaShape"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 2a85cab2_0338_353c_a5f7_46964a1b85f9
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  53497908_16e7_977d_e97d_7414884a88a6["pg-core"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 53497908_16e7_977d_e97d_7414884a88a6
  e3330aa9_fee9_b340_1093_1c8a98953c05["json-rules-engine"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> e3330aa9_fee9_b340_1093_1c8a98953c05
  a9e31838_d52b_02c1_2b9d_c4354b2ad2fa["valibot"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> a9e31838_d52b_02c1_2b9d_c4354b2ad2fa
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  45e26f9d_6717_943d_0371_5d349b8c9472["constants.ts"]
  f5bdd4a8_7392_24f0_b17c_d98d0b1db060 --> 45e26f9d_6717_943d_0371_5d349b8c9472
  style f5bdd4a8_7392_24f0_b17c_d98d0b1db060 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { type Equal, sql } from 'drizzle-orm';
import {
	customType,
	integer,
	json,
	jsonb,
	pgEnum,
	pgMaterializedView,
	pgSchema,
	pgTable,
	pgView,
	serial,
	text,
} from 'drizzle-orm/pg-core';
import type { TopLevelCondition } from 'json-rules-engine';
import * as v from 'valibot';
import { test } from 'vitest';
import { jsonSchema } from '~/column.ts';
import { CONSTANTS } from '~/constants.ts';
import { createInsertSchema, createSelectSchema, createUpdateSchema } from '../src';
import { Expect, expectEnumValues, expectSchemaShape } from './utils.ts';

const integerSchema = v.pipe(v.number(), v.minValue(CONSTANTS.INT32_MIN), v.maxValue(CONSTANTS.INT32_MAX), v.integer());
const textSchema = v.string();

test('table - select', (t) => {
	const table = pgTable('test', {
		id: serial().primaryKey(),
		name: text().notNull(),
	});

	const result = createSelectSchema(table);
	const expected = v.object({ id: integerSchema, name: textSchema });
	expectSchemaShape(t, expected).from(result);
	Expect<Equal<typeof result, typeof expected>>();
});

test('table in schema - select', (tc) => {
	const schema = pgSchema('test');
	const table = schema.table('test', {
		id: serial().primaryKey(),
		name: text().notNull(),
	});

	const result = createSelectSchema(table);
	const expected = v.object({ id: integerSchema, name: textSchema });
	expectSchemaShape(tc, expected).from(result);
	Expect<Equal<typeof result, typeof expected>>();
});

test('table - insert', (t) => {
	const table = pgTable('test', {
		id: integer().generatedAlwaysAsIdentity().primaryKey(),
		name: text().notNull(),
		age: integer(),
	});

	const result = createInsertSchema(table);
	const expected = v.object({ name: textSchema, age: v.optional(v.nullable(integerSchema)) });
	expectSchemaShape(t, expected).from(result);
// ... (504 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does pg.test.ts do?
pg.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the ValidationAdapters domain, TypeMapping subdomain.
What functions are defined in pg.test.ts?
pg.test.ts defines 4 function(s): TopLevelCondition, mView, nestedSelect, view.
What does pg.test.ts depend on?
pg.test.ts imports 12 module(s): Expect, column.ts, constants.ts, drizzle-orm, expectEnumValues, expectSchemaShape, index.ts, json-rules-engine, and 4 more.
Where is pg.test.ts in the architecture?
pg.test.ts is located at drizzle-valibot/tests/pg.test.ts (domain: ValidationAdapters, subdomain: TypeMapping, directory: drizzle-valibot/tests).

Analyze Your Own Codebase

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

Try Supermodel Free