Home / File/ sql-js.test.ts — drizzle-orm Source File

sql-js.test.ts — drizzle-orm Source File

Architecture documentation for sql-js.test.ts, a typescript file in the drizzle-orm codebase. 8 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea["sql-js.test.ts"]
  46ce8b0c_dd54_2020_c1e8_2865e4c5e575["sqlite-common.ts"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 46ce8b0c_dd54_2020_c1e8_2865e4c5e575
  3418d3a3_df7d_8999_e21a_2b4339e5aa45["tests"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 3418d3a3_df7d_8999_e21a_2b4339e5aa45
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  03eb9759_42d1_d2fe_6b77_c094f3680fda["sql-js"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 03eb9759_42d1_d2fe_6b77_c094f3680fda
  840927d5_734b_0e12_c562_3a6d411e7902["migrator"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 840927d5_734b_0e12_c562_3a6d411e7902
  e3b6939f_7479_645e_3a63_79763ad4c27c["sql.js"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> e3b6939f_7479_645e_3a63_79763ad4c27c
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  5536e6a8_02de_67a7_6eaf_0fd73c9c2d92["common"]
  a2acbf1e_1d06_57c2_ff79_b03d0ef348ea --> 5536e6a8_02de_67a7_6eaf_0fd73c9c2d92
  style a2acbf1e_1d06_57c2_ff79_b03d0ef348ea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { sql } from 'drizzle-orm';
import type { SQLJsDatabase } from 'drizzle-orm/sql-js';
import { drizzle } from 'drizzle-orm/sql-js';
import { migrate } from 'drizzle-orm/sql-js/migrator';
import type { Database } from 'sql.js';
import initSqlJs from 'sql.js';
import { afterAll, beforeAll, beforeEach, expect, test } from 'vitest';
import { skipTests } from '~/common';
import { anotherUsersMigratorTable, tests, usersMigratorTable } from './sqlite-common';

const ENABLE_LOGGING = false;

let db: SQLJsDatabase;
let client: Database;

beforeAll(async () => {
	const SQL = await initSqlJs();
	client = new SQL.Database();
	db = drizzle(client, { logger: ENABLE_LOGGING });
});

beforeEach((ctx) => {
	ctx.sqlite = {
		db,
	};
});

afterAll(async () => {
	client?.close();
});

test('migrator', async () => {
	db.run(sql`drop table if exists another_users`);
	db.run(sql`drop table if exists users12`);
	db.run(sql`drop table if exists __drizzle_migrations`);

	migrate(db, { migrationsFolder: './drizzle2/sqlite' });

	db.insert(usersMigratorTable).values({ name: 'John', email: 'email' }).run();
	const result = db.select().from(usersMigratorTable).all();

	db.insert(anotherUsersMigratorTable).values({ name: 'John', email: 'email' }).run();
	const result2 = db.select().from(anotherUsersMigratorTable).all();

	expect(result).toEqual([{ id: 1, name: 'John', email: 'email' }]);
	expect(result2).toEqual([{ id: 1, name: 'John', email: 'email' }]);

	db.run(sql`drop table another_users`);
	db.run(sql`drop table users12`);
	db.run(sql`drop table __drizzle_migrations`);
});

skipTests([
	/**
	 * doesn't work properly:
	 * 	Expect: should rollback transaction and don't insert/ update data
	 * 	Received: data inserted/ updated
	 */
	'transaction rollback',
	'nested transaction rollback',
	'delete with limit and order by',
	'update with limit and order by',
]);
tests();

Domain

Dependencies

Frequently Asked Questions

What does sql-js.test.ts do?
sql-js.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does sql-js.test.ts depend on?
sql-js.test.ts imports 8 module(s): common, drizzle-orm, migrator, sql-js, sql.js, sqlite-common.ts, tests, vitest.
Where is sql-js.test.ts in the architecture?
sql-js.test.ts is located at integration-tests/tests/sqlite/sql-js.test.ts (domain: DrizzleORM, directory: integration-tests/tests/sqlite).

Analyze Your Own Codebase

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

Try Supermodel Free