Home / File/ sqlite-checks.test.ts — drizzle-orm Source File

sqlite-checks.test.ts — drizzle-orm Source File

Architecture documentation for sqlite-checks.test.ts, a typescript file in the drizzle-orm codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  2d5655a2_303e_106f_a058_d16af55e902f["sqlite-checks.test.ts"]
  fb6b4a65_030b_ce6b_df0d_2be21adcd2b3["schemaDiffer.ts"]
  2d5655a2_303e_106f_a058_d16af55e902f --> fb6b4a65_030b_ce6b_df0d_2be21adcd2b3
  843d184b_68ea_28e0_a4e7_11ed8d0a221a["diffTestSchemasSqlite"]
  2d5655a2_303e_106f_a058_d16af55e902f --> 843d184b_68ea_28e0_a4e7_11ed8d0a221a
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  2d5655a2_303e_106f_a058_d16af55e902f --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  25248a9d_ba06_2b33_4421_8575da2f9c34["sqlite-core"]
  2d5655a2_303e_106f_a058_d16af55e902f --> 25248a9d_ba06_2b33_4421_8575da2f9c34
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  2d5655a2_303e_106f_a058_d16af55e902f --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  style 2d5655a2_303e_106f_a058_d16af55e902f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { sql } from 'drizzle-orm';
import { check, int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { expect, test } from 'vitest';
import { diffTestSchemasSqlite } from './schemaDiffer';

test('create table with check', async (t) => {
	const to = {
		users: sqliteTable('users', {
			id: int('id').primaryKey(),
			age: int('age'),
		}, (table) => ({
			checkConstraint: check('some_check_name', sql`${table.age} > 21`),
		})),
	};

	const { sqlStatements, statements } = await diffTestSchemasSqlite({}, to, []);

	expect(statements.length).toBe(1);
	expect(statements[0]).toStrictEqual({
		type: 'sqlite_create_table',
		tableName: 'users',
		columns: [
			{
				name: 'id',
				type: 'integer',
				notNull: true,
				primaryKey: true,
				autoincrement: false,
			},
			{
				name: 'age',
				type: 'integer',
				notNull: false,
				primaryKey: false,
				autoincrement: false,
			},
		],
		compositePKs: [],
		checkConstraints: ['some_check_name;"users"."age" > 21'],
		referenceData: [],
		uniqueConstraints: [],
	});

	expect(sqlStatements.length).toBe(1);
	expect(sqlStatements[0]).toBe(`CREATE TABLE \`users\` (
\t\`id\` integer PRIMARY KEY NOT NULL,
\t\`age\` integer,
\tCONSTRAINT "some_check_name" CHECK("users"."age" > 21)
);\n`);
});

test('add check contraint to existing table', async (t) => {
	const to = {
		users: sqliteTable('users', {
			id: int('id').primaryKey(),
			age: int('age'),
		}, (table) => ({
			checkConstraint: check('some_check_name', sql`${table.age} > 21`),
		})),
	};
// ... (249 more lines)

Domain

Dependencies

Frequently Asked Questions

What does sqlite-checks.test.ts do?
sqlite-checks.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does sqlite-checks.test.ts depend on?
sqlite-checks.test.ts imports 5 module(s): diffTestSchemasSqlite, drizzle-orm, schemaDiffer.ts, sqlite-core, vitest.
Where is sqlite-checks.test.ts in the architecture?
sqlite-checks.test.ts is located at drizzle-kit/tests/sqlite-checks.test.ts (domain: DrizzleORM, directory: drizzle-kit/tests).

Analyze Your Own Codebase

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

Try Supermodel Free