Home / File/ mysql-views.test.ts — drizzle-orm Source File

mysql-views.test.ts — drizzle-orm Source File

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

Entity Profile

Dependency Diagram

graph LR
  cfc22212_ba10_d89e_c47e_261271abf862["mysql-views.test.ts"]
  fb6b4a65_030b_ce6b_df0d_2be21adcd2b3["schemaDiffer.ts"]
  cfc22212_ba10_d89e_c47e_261271abf862 --> fb6b4a65_030b_ce6b_df0d_2be21adcd2b3
  c773074f_07b6_08cd_c3ec_75126530b1c5["diffTestSchemasMysql"]
  cfc22212_ba10_d89e_c47e_261271abf862 --> c773074f_07b6_08cd_c3ec_75126530b1c5
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  cfc22212_ba10_d89e_c47e_261271abf862 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  93ed9350_daa0_6c21_81a6_ed6b2a48bbdf["mysql-core"]
  cfc22212_ba10_d89e_c47e_261271abf862 --> 93ed9350_daa0_6c21_81a6_ed6b2a48bbdf
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  cfc22212_ba10_d89e_c47e_261271abf862 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  style cfc22212_ba10_d89e_c47e_261271abf862 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { sql } from 'drizzle-orm';
import { int, mysqlTable, mysqlView } from 'drizzle-orm/mysql-core';
import { expect, test } from 'vitest';
import { diffTestSchemasMysql } from './schemaDiffer';

test('create view #1', async () => {
	const users = mysqlTable('users', {
		id: int('id').primaryKey().notNull(),
	});

	const from = {
		users: users,
	};
	const to = {
		users: users,
		view: mysqlView('some_view').as((qb) => qb.select().from(users)),
	};

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

	expect(statements.length).toBe(1);
	expect(statements[0]).toStrictEqual({
		type: 'mysql_create_view',
		name: 'some_view',
		algorithm: 'undefined',
		replace: false,
		definition: 'select `id` from `users`',
		withCheckOption: undefined,
		sqlSecurity: 'definer',
	});

	expect(sqlStatements.length).toBe(1);
	expect(sqlStatements[0]).toBe(`CREATE ALGORITHM = undefined
SQL SECURITY definer
VIEW \`some_view\` AS (select \`id\` from \`users\`);`);
});

test('create view #2', async () => {
	const users = mysqlTable('users', {
		id: int('id').primaryKey().notNull(),
	});

	const from = {
		users: users,
	};
	const to = {
		users: users,
		view: mysqlView('some_view', {}).algorithm('merge').sqlSecurity('definer')
			.withCheckOption('cascaded').as(sql`SELECT * FROM ${users}`),
	};

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

	expect(statements.length).toBe(1);
	expect(statements[0]).toStrictEqual({
		type: 'mysql_create_view',
		name: 'some_view',
		algorithm: 'merge',
		replace: false,
		definition: 'SELECT * FROM \`users\`',
// ... (494 more lines)

Domain

Dependencies

Frequently Asked Questions

What does mysql-views.test.ts do?
mysql-views.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does mysql-views.test.ts depend on?
mysql-views.test.ts imports 5 module(s): diffTestSchemasMysql, drizzle-orm, mysql-core, schemaDiffer.ts, vitest.
Where is mysql-views.test.ts in the architecture?
mysql-views.test.ts is located at drizzle-kit/tests/mysql-views.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