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

singlestore.test.ts — drizzle-orm Source File

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

Entity Profile

Dependency Diagram

graph LR
  514382cb_23aa_aec1_55c0_e372a6ec90ae["singlestore.test.ts"]
  9a709b88_1975_ab69_2cd7_cd36e1afa9d0["index.ts"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 9a709b88_1975_ab69_2cd7_cd36e1afa9d0
  220ae495_e2e6_9482_daa5_19553ac47578["utils.ts"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 220ae495_e2e6_9482_daa5_19553ac47578
  fd9e9430_de0a_4c07_8df0_2953155177d5["Expect"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> fd9e9430_de0a_4c07_8df0_2953155177d5
  f3b1a23b_bcee_46b1_e5f7_5df6441a824e["expectSchemaShape"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> f3b1a23b_bcee_46b1_e5f7_5df6441a824e
  26760edf_9a0c_0204_77e6_f8bffa96e354["typebox"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 26760edf_9a0c_0204_77e6_f8bffa96e354
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  b4539857_26bc_b042_0719_5e529c80f1b4["singlestore-core"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> b4539857_26bc_b042_0719_5e529c80f1b4
  e3330aa9_fee9_b340_1093_1c8a98953c05["json-rules-engine"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> e3330aa9_fee9_b340_1093_1c8a98953c05
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  45e26f9d_6717_943d_0371_5d349b8c9472["constants.ts"]
  514382cb_23aa_aec1_55c0_e372a6ec90ae --> 45e26f9d_6717_943d_0371_5d349b8c9472
  style 514382cb_23aa_aec1_55c0_e372a6ec90ae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { type Static, Type as t } from '@sinclair/typebox';
import { type Equal } from 'drizzle-orm';
import { customType, int, json, serial, singlestoreSchema, singlestoreTable, text } from 'drizzle-orm/singlestore-core';
import type { TopLevelCondition } from 'json-rules-engine';
import { test } from 'vitest';
import { jsonSchema } from '~/column.ts';
import { CONSTANTS } from '~/constants.ts';
import { createInsertSchema, createSelectSchema, createUpdateSchema, type GenericSchema } from '../src';
import { Expect, expectSchemaShape } from './utils.ts';

const intSchema = t.Integer({
	minimum: CONSTANTS.INT32_MIN,
	maximum: CONSTANTS.INT32_MAX,
});
const serialNumberModeSchema = t.Integer({
	minimum: 0,
	maximum: Number.MAX_SAFE_INTEGER,
});
const textSchema = t.String({ maxLength: CONSTANTS.INT16_UNSIGNED_MAX });

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

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

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

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

test('table - insert', (tc) => {
	const table = singlestoreTable('test', {
		id: serial().primaryKey(),
		name: text().notNull(),
		age: int(),
	});

	const result = createInsertSchema(table);
	const expected = t.Object({
		id: t.Optional(serialNumberModeSchema),
		name: textSchema,
		age: t.Optional(t.Union([intSchema, t.Null()])),
	});
	expectSchemaShape(tc, expected).from(result);
	Expect<Equal<typeof result, typeof expected>>();
// ... (451 more lines)

Dependencies

Frequently Asked Questions

What does singlestore.test.ts do?
singlestore.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the ValidationAdapters domain.
What does singlestore.test.ts depend on?
singlestore.test.ts imports 11 module(s): Expect, column.ts, constants.ts, drizzle-orm, expectSchemaShape, index.ts, json-rules-engine, singlestore-core, and 3 more.
Where is singlestore.test.ts in the architecture?
singlestore.test.ts is located at drizzle-typebox/tests/singlestore.test.ts (domain: ValidationAdapters, directory: drizzle-typebox/tests).

Analyze Your Own Codebase

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

Try Supermodel Free