Home / File/ char.ts — drizzle-orm Source File

char.ts — drizzle-orm Source File

Architecture documentation for char.ts, a typescript file in the drizzle-orm codebase. 7 imports, 1 dependents.

File typescript DrizzleORM SQLDialects 7 imports 1 dependents 1 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91["char.ts"]
  83c65ad5_22a0_d33f_47b8_c2ed1c8d8bbb["common.ts"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> 83c65ad5_22a0_d33f_47b8_c2ed1c8d8bbb
  8da43de9_1be1_48fb_1db1_a6bc59f5b306["MySqlColumn"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> 8da43de9_1be1_48fb_1db1_a6bc59f5b306
  2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  70e1783e_f575_ccd4_36bd_5f0978c2172c["table.ts"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> 70e1783e_f575_ccd4_36bd_5f0978c2172c
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  6dd15b44_b15c_62ef_81b2_e72b28299be9["all.ts"]
  6dd15b44_b15c_62ef_81b2_e72b28299be9 --> a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91
  style a7fee2a9_bf3d_8f79_4c9d_9c28e429bc91 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';
import type { ColumnBaseConfig } from '~/column.ts';
import { entityKind } from '~/entity.ts';
import type { AnyMySqlTable } from '~/mysql-core/table.ts';
import { getColumnNameAndConfig, type Writable } from '~/utils.ts';
import { MySqlColumn, MySqlColumnBuilder } from './common.ts';

export type MySqlCharBuilderInitial<
	TName extends string,
	TEnum extends [string, ...string[]],
	TLength extends number | undefined,
> = MySqlCharBuilder<{
	name: TName;
	dataType: 'string';
	columnType: 'MySqlChar';
	data: TEnum[number];
	driverParam: number | string;
	enumValues: TEnum;
	length: TLength;
}>;

export class MySqlCharBuilder<
	T extends ColumnBuilderBaseConfig<'string', 'MySqlChar'> & { length?: number | undefined },
> extends MySqlColumnBuilder<
	T,
	MySqlCharConfig<T['enumValues'], T['length']>,
	{ length: T['length'] }
> {
	static override readonly [entityKind]: string = 'MySqlCharBuilder';

	constructor(name: T['name'], config: MySqlCharConfig<T['enumValues'], T['length']>) {
		super(name, 'string', 'MySqlChar');
		this.config.length = config.length;
		this.config.enum = config.enum;
	}

	/** @internal */
	override build<TTableName extends string>(
		table: AnyMySqlTable<{ name: TTableName }>,
	): MySqlChar<MakeColumnConfig<T, TTableName> & { length: T['length']; enumValues: T['enumValues'] }> {
		return new MySqlChar<MakeColumnConfig<T, TTableName> & { length: T['length']; enumValues: T['enumValues'] }>(
			table,
			this.config as ColumnBuilderRuntimeConfig<any, any>,
		);
	}
}

export class MySqlChar<T extends ColumnBaseConfig<'string', 'MySqlChar'> & { length?: number | undefined }>
	extends MySqlColumn<T, MySqlCharConfig<T['enumValues'], T['length']>, { length: T['length'] }>
{
	static override readonly [entityKind]: string = 'MySqlChar';

	readonly length: T['length'] = this.config.length;
	override readonly enumValues = this.config.enum;

	getSQLType(): string {
		return this.length === undefined ? `char` : `char(${this.length})`;
	}
}

export interface MySqlCharConfig<
	TEnum extends readonly string[] | string[] | undefined = readonly string[] | string[] | undefined,
	TLength extends number | undefined = number | undefined,
> {
	enum?: TEnum;
	length?: TLength;
}

export function char(): MySqlCharBuilderInitial<'', [string, ...string[]], undefined>;
export function char<U extends string, T extends Readonly<[U, ...U[]]>, L extends number | undefined>(
	config?: MySqlCharConfig<T | Writable<T>, L>,
): MySqlCharBuilderInitial<'', Writable<T>, L>;
export function char<
	TName extends string,
	U extends string,
	T extends Readonly<[U, ...U[]]>,
	L extends number | undefined,
>(
	name: TName,
	config?: MySqlCharConfig<T | Writable<T>, L>,
): MySqlCharBuilderInitial<TName, Writable<T>, L>;
export function char(a?: string | MySqlCharConfig, b: MySqlCharConfig = {}): any {
	const { name, config } = getColumnNameAndConfig<MySqlCharConfig>(a, b);
	return new MySqlCharBuilder(name, config as any);
}

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does char.ts do?
char.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What functions are defined in char.ts?
char.ts defines 1 function(s): char.
What does char.ts depend on?
char.ts imports 7 module(s): MySqlColumn, column-builder.ts, column.ts, common.ts, entity.ts, table.ts, utils.ts.
What files import char.ts?
char.ts is imported by 1 file(s): all.ts.
Where is char.ts in the architecture?
char.ts is located at drizzle-orm/src/mysql-core/columns/char.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/mysql-core/columns).

Analyze Your Own Codebase

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

Try Supermodel Free