Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed mysql to singlestore in singlestore-core #2

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions drizzle-orm/src/column-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { entityKind } from '~/entity.ts';
import type { Column } from './column.ts';
import type { MySqlColumn } from './mysql-core/index.ts';
import type { ExtraConfigColumn, PgColumn, PgSequenceOptions } from './pg-core/index.ts';
import type { SingleStoreColumn } from './singlestore-core/index.ts';
import type { SQL } from './sql/sql.ts';
import type { SQLiteColumn } from './sqlite-core/index.ts';
import type { Simplify } from './utils.ts';
import { SingleStoreColumn } from './singlestore-core/index.ts';

export type ColumnDataType =
| 'string'
Expand All @@ -18,7 +18,7 @@ export type ColumnDataType =
| 'custom'
| 'buffer';

export type Dialect = 'singlestore' | 'pg' | 'mysql' | 'sqlite' | 'common';
export type Dialect = 'pg' | 'mysql' | 'sqlite' | 'singlestore' | 'common';

export type GeneratedStorageMode = 'virtual' | 'stored';

Expand Down Expand Up @@ -300,7 +300,7 @@ export type BuildColumn<
TTableName extends string,
TBuilder extends ColumnBuilderBase,
TDialect extends Dialect,
> = TDialect extends 'singlestore' ? SingleStoreColumn<MakeColumnConfig<TBuilder['_'], TTableName>>
> = TDialect extends 'singlestore' ? SingleStoreColumn<MakeColumnConfig<TBuilder['_'], TTableName>>
: TDialect extends 'pg' ? PgColumn<MakeColumnConfig<TBuilder['_'], TTableName>>
: TDialect extends 'mysql' ? MySqlColumn<MakeColumnConfig<TBuilder['_'], TTableName>>
: TDialect extends 'sqlite' ? SQLiteColumn<MakeColumnConfig<TBuilder['_'], TTableName>>
Expand Down
6 changes: 3 additions & 3 deletions drizzle-orm/src/singlestore-core/alias.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TableAliasProxyHandler } from '~/alias.ts';
import type { BuildAliasTable } from './query-builders/select.types.ts';
import type { MySqlTable } from './table.ts';
import type { MySqlViewBase } from './view-base.ts';
import type { SingleStoreTable } from './table.ts';
import type { SingleStoreViewBase } from './view-base.ts';

export function alias<TTable extends MySqlTable | MySqlViewBase, TAlias extends string>(
export function alias<TTable extends SingleStoreTable | SingleStoreViewBase, TAlias extends string>(
table: TTable,
alias: TAlias,
): BuildAliasTable<TTable, TAlias> {
Expand Down
12 changes: 6 additions & 6 deletions drizzle-orm/src/singlestore-core/checks.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { entityKind } from '~/entity.ts';
import type { SQL } from '~/sql/sql.ts';
import type { MySqlTable } from './table.ts';
import type { SingleStoreTable } from './table.ts';

export class CheckBuilder {
static readonly [entityKind]: string = 'MySqlCheckBuilder';
static readonly [entityKind]: string = 'SingleStoreCheckBuilder';

protected brand!: 'MySqlConstraintBuilder';
protected brand!: 'SingleStoreConstraintBuilder';

constructor(public name: string, public value: SQL) {}

/** @internal */
build(table: MySqlTable): Check {
build(table: SingleStoreTable): Check {
return new Check(table, this);
}
}

export class Check {
static readonly [entityKind]: string = 'MySqlCheck';
static readonly [entityKind]: string = 'SingleStoreCheck';

readonly name: string;
readonly value: SQL;

constructor(public table: MySqlTable, builder: CheckBuilder) {
constructor(public table: SingleStoreTable, builder: CheckBuilder) {
this.name = builder.name;
this.value = builder.value;
}
Expand Down
66 changes: 33 additions & 33 deletions drizzle-orm/src/singlestore-core/columns/bigint.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
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 { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';
import type { AnySingleStoreTable } from '~/singlestore-core/table.ts';
import { SingleStoreColumnBuilderWithAutoIncrement, SingleStoreColumnWithAutoIncrement } from './common.ts';

export type MySqlBigInt53BuilderInitial<TName extends string> = MySqlBigInt53Builder<{
export type SingleStoreBigInt53BuilderInitial<TName extends string> = SingleStoreBigInt53Builder<{
name: TName;
dataType: 'number';
columnType: 'MySqlBigInt53';
columnType: 'SingleStoreBigInt53';
data: number;
driverParam: number | string;
enumValues: undefined;
generated: undefined;
}>;

export class MySqlBigInt53Builder<T extends ColumnBuilderBaseConfig<'number', 'MySqlBigInt53'>>
extends MySqlColumnBuilderWithAutoIncrement<T, { unsigned: boolean }>
export class SingleStoreBigInt53Builder<T extends ColumnBuilderBaseConfig<'number', 'SingleStoreBigInt53'>>
extends SingleStoreColumnBuilderWithAutoIncrement<T, { unsigned: boolean }>
{
static readonly [entityKind]: string = 'MySqlBigInt53Builder';
static readonly [entityKind]: string = 'SingleStoreBigInt53Builder';

constructor(name: T['name'], unsigned: boolean = false) {
super(name, 'number', 'MySqlBigInt53');
super(name, 'number', 'SingleStoreBigInt53');
this.config.unsigned = unsigned;
}

/** @internal */
override build<TTableName extends string>(
table: AnyMySqlTable<{ name: TTableName }>,
): MySqlBigInt53<MakeColumnConfig<T, TTableName>> {
return new MySqlBigInt53<MakeColumnConfig<T, TTableName>>(
table: AnySingleStoreTable<{ name: TTableName }>,
): SingleStoreBigInt53<MakeColumnConfig<T, TTableName>> {
return new SingleStoreBigInt53<MakeColumnConfig<T, TTableName>>(
table,
this.config as ColumnBuilderRuntimeConfig<any, any>,
);
}
}

export class MySqlBigInt53<T extends ColumnBaseConfig<'number', 'MySqlBigInt53'>>
extends MySqlColumnWithAutoIncrement<T, { unsigned: boolean }>
export class SingleStoreBigInt53<T extends ColumnBaseConfig<'number', 'SingleStoreBigInt53'>>
extends SingleStoreColumnWithAutoIncrement<T, { unsigned: boolean }>
{
static readonly [entityKind]: string = 'MySqlBigInt53';
static readonly [entityKind]: string = 'SingleStoreBigInt53';

getSQLType(): string {
return `bigint${this.config.unsigned ? ' unsigned' : ''}`;
Expand All @@ -52,41 +52,41 @@ export class MySqlBigInt53<T extends ColumnBaseConfig<'number', 'MySqlBigInt53'>
}
}

export type MySqlBigInt64BuilderInitial<TName extends string> = MySqlBigInt64Builder<{
export type SingleStoreBigInt64BuilderInitial<TName extends string> = SingleStoreBigInt64Builder<{
name: TName;
dataType: 'bigint';
columnType: 'MySqlBigInt64';
columnType: 'SingleStoreBigInt64';
data: bigint;
driverParam: string;
enumValues: undefined;
generated: undefined;
}>;

export class MySqlBigInt64Builder<T extends ColumnBuilderBaseConfig<'bigint', 'MySqlBigInt64'>>
extends MySqlColumnBuilderWithAutoIncrement<T, { unsigned: boolean }>
export class SingleStoreBigInt64Builder<T extends ColumnBuilderBaseConfig<'bigint', 'SingleStoreBigInt64'>>
extends SingleStoreColumnBuilderWithAutoIncrement<T, { unsigned: boolean }>
{
static readonly [entityKind]: string = 'MySqlBigInt64Builder';
static readonly [entityKind]: string = 'SingleStoreBigInt64Builder';

constructor(name: T['name'], unsigned: boolean = false) {
super(name, 'bigint', 'MySqlBigInt64');
super(name, 'bigint', 'SingleStoreBigInt64');
this.config.unsigned = unsigned;
}

/** @internal */
override build<TTableName extends string>(
table: AnyMySqlTable<{ name: TTableName }>,
): MySqlBigInt64<MakeColumnConfig<T, TTableName>> {
return new MySqlBigInt64<MakeColumnConfig<T, TTableName>>(
table: AnySingleStoreTable<{ name: TTableName }>,
): SingleStoreBigInt64<MakeColumnConfig<T, TTableName>> {
return new SingleStoreBigInt64<MakeColumnConfig<T, TTableName>>(
table,
this.config as ColumnBuilderRuntimeConfig<any, any>,
);
}
}

export class MySqlBigInt64<T extends ColumnBaseConfig<'bigint', 'MySqlBigInt64'>>
extends MySqlColumnWithAutoIncrement<T, { unsigned: boolean }>
export class SingleStoreBigInt64<T extends ColumnBaseConfig<'bigint', 'SingleStoreBigInt64'>>
extends SingleStoreColumnWithAutoIncrement<T, { unsigned: boolean }>
{
static readonly [entityKind]: string = 'MySqlBigInt64';
static readonly [entityKind]: string = 'SingleStoreBigInt64';

getSQLType(): string {
return `bigint${this.config.unsigned ? ' unsigned' : ''}`;
Expand All @@ -98,18 +98,18 @@ export class MySqlBigInt64<T extends ColumnBaseConfig<'bigint', 'MySqlBigInt64'>
}
}

interface MySqlBigIntConfig<T extends 'number' | 'bigint' = 'number' | 'bigint'> {
interface SingleStoreBigIntConfig<T extends 'number' | 'bigint' = 'number' | 'bigint'> {
mode: T;
unsigned?: boolean;
}

export function bigint<TName extends string, TMode extends MySqlBigIntConfig['mode']>(
export function bigint<TName extends string, TMode extends SingleStoreBigIntConfig['mode']>(
name: TName,
config: MySqlBigIntConfig<TMode>,
): TMode extends 'number' ? MySqlBigInt53BuilderInitial<TName> : MySqlBigInt64BuilderInitial<TName>;
export function bigint(name: string, config: MySqlBigIntConfig) {
config: SingleStoreBigIntConfig<TMode>,
): TMode extends 'number' ? SingleStoreBigInt53BuilderInitial<TName> : SingleStoreBigInt64BuilderInitial<TName>;
export function bigint(name: string, config: SingleStoreBigIntConfig) {
if (config.mode === 'number') {
return new MySqlBigInt53Builder(name, config.unsigned);
return new SingleStoreBigInt53Builder(name, config.unsigned);
}
return new MySqlBigInt64Builder(name, config.unsigned);
return new SingleStoreBigInt64Builder(name, config.unsigned);
}
45 changes: 25 additions & 20 deletions drizzle-orm/src/singlestore-core/columns/binary.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
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 { MySqlColumn, MySqlColumnBuilder } from './common.ts';
import type { AnySingleStoreTable } from '~/singlestore-core/table.ts';
import { SingleStoreColumn, SingleStoreColumnBuilder } from './common.ts';

export type MySqlBinaryBuilderInitial<TName extends string> = MySqlBinaryBuilder<{
export type SingleStoreBinaryBuilderInitial<TName extends string> = SingleStoreBinaryBuilder<{
name: TName;
dataType: 'string';
columnType: 'MySqlBinary';
columnType: 'SingleStoreBinary';
data: string;
driverParam: string;
enumValues: undefined;
generated: undefined;
}>;

export class MySqlBinaryBuilder<T extends ColumnBuilderBaseConfig<'string', 'MySqlBinary'>> extends MySqlColumnBuilder<
T,
MySqlBinaryConfig
> {
static readonly [entityKind]: string = 'MySqlBinaryBuilder';
export class SingleStoreBinaryBuilder<T extends ColumnBuilderBaseConfig<'string', 'SingleStoreBinary'>>
extends SingleStoreColumnBuilder<
T,
SingleStoreBinaryConfig
>
{
static readonly [entityKind]: string = 'SingleStoreBinaryBuilder';

constructor(name: T['name'], length: number | undefined) {
super(name, 'string', 'MySqlBinary');
super(name, 'string', 'SingleStoreBinary');
this.config.length = length;
}

/** @internal */
override build<TTableName extends string>(
table: AnyMySqlTable<{ name: TTableName }>,
): MySqlBinary<MakeColumnConfig<T, TTableName>> {
return new MySqlBinary<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);
table: AnySingleStoreTable<{ name: TTableName }>,
): SingleStoreBinary<MakeColumnConfig<T, TTableName>> {
return new SingleStoreBinary<MakeColumnConfig<T, TTableName>>(
table,
this.config as ColumnBuilderRuntimeConfig<any, any>,
);
}
}

export class MySqlBinary<T extends ColumnBaseConfig<'string', 'MySqlBinary'>> extends MySqlColumn<
export class SingleStoreBinary<T extends ColumnBaseConfig<'string', 'SingleStoreBinary'>> extends SingleStoreColumn<
T,
MySqlBinaryConfig
SingleStoreBinaryConfig
> {
static readonly [entityKind]: string = 'MySqlBinary';
static readonly [entityKind]: string = 'SingleStoreBinary';

length: number | undefined = this.config.length;

Expand All @@ -46,13 +51,13 @@ export class MySqlBinary<T extends ColumnBaseConfig<'string', 'MySqlBinary'>> ex
}
}

export interface MySqlBinaryConfig {
export interface SingleStoreBinaryConfig {
length?: number;
}

export function binary<TName extends string>(
name: TName,
config: MySqlBinaryConfig = {},
): MySqlBinaryBuilderInitial<TName> {
return new MySqlBinaryBuilder(name, config.length);
config: SingleStoreBinaryConfig = {},
): SingleStoreBinaryBuilderInitial<TName> {
return new SingleStoreBinaryBuilder(name, config.length);
}
32 changes: 17 additions & 15 deletions drizzle-orm/src/singlestore-core/columns/boolean.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
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 { MySqlColumn, MySqlColumnBuilder } from './common.ts';
import type { AnySingleStoreTable } from '~/singlestore-core/table.ts';
import { SingleStoreColumn, SingleStoreColumnBuilder } from './common.ts';

export type MySqlBooleanBuilderInitial<TName extends string> = MySqlBooleanBuilder<{
export type SingleStoreBooleanBuilderInitial<TName extends string> = SingleStoreBooleanBuilder<{
name: TName;
dataType: 'boolean';
columnType: 'MySqlBoolean';
columnType: 'SingleStoreBoolean';
data: boolean;
driverParam: number | boolean;
enumValues: undefined;
generated: undefined;
}>;

export class MySqlBooleanBuilder<T extends ColumnBuilderBaseConfig<'boolean', 'MySqlBoolean'>>
extends MySqlColumnBuilder<T>
export class SingleStoreBooleanBuilder<T extends ColumnBuilderBaseConfig<'boolean', 'SingleStoreBoolean'>>
extends SingleStoreColumnBuilder<T>
{
static readonly [entityKind]: string = 'MySqlBooleanBuilder';
static readonly [entityKind]: string = 'SingleStoreBooleanBuilder';

constructor(name: T['name']) {
super(name, 'boolean', 'MySqlBoolean');
super(name, 'boolean', 'SingleStoreBoolean');
}

/** @internal */
override build<TTableName extends string>(
table: AnyMySqlTable<{ name: TTableName }>,
): MySqlBoolean<MakeColumnConfig<T, TTableName>> {
return new MySqlBoolean<MakeColumnConfig<T, TTableName>>(
table: AnySingleStoreTable<{ name: TTableName }>,
): SingleStoreBoolean<MakeColumnConfig<T, TTableName>> {
return new SingleStoreBoolean<MakeColumnConfig<T, TTableName>>(
table,
this.config as ColumnBuilderRuntimeConfig<any, any>,
);
}
}

export class MySqlBoolean<T extends ColumnBaseConfig<'boolean', 'MySqlBoolean'>> extends MySqlColumn<T> {
static readonly [entityKind]: string = 'MySqlBoolean';
export class SingleStoreBoolean<T extends ColumnBaseConfig<'boolean', 'SingleStoreBoolean'>>
extends SingleStoreColumn<T>
{
static readonly [entityKind]: string = 'SingleStoreBoolean';

getSQLType(): string {
return 'boolean';
Expand All @@ -49,6 +51,6 @@ export class MySqlBoolean<T extends ColumnBaseConfig<'boolean', 'MySqlBoolean'>>
}
}

export function boolean<TName extends string>(name: TName): MySqlBooleanBuilderInitial<TName> {
return new MySqlBooleanBuilder(name);
export function boolean<TName extends string>(name: TName): SingleStoreBooleanBuilderInitial<TName> {
return new SingleStoreBooleanBuilder(name);
}
Loading