drizzle-orm 1.0.0-beta.1-00df263 → 1.0.0-beta.1-199e5ec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gel-core/dialect.cjs +8 -23
- package/gel-core/dialect.cjs.map +1 -1
- package/gel-core/dialect.d.cts +1 -0
- package/gel-core/dialect.d.ts +1 -0
- package/gel-core/dialect.js +8 -23
- package/gel-core/dialect.js.map +1 -1
- package/gel-core/query-builders/select.cjs +80 -14
- package/gel-core/query-builders/select.cjs.map +1 -1
- package/gel-core/query-builders/select.d.cts +78 -13
- package/gel-core/query-builders/select.d.ts +78 -13
- package/gel-core/query-builders/select.js +80 -14
- package/gel-core/query-builders/select.js.map +1 -1
- package/gel-core/query-builders/select.types.cjs.map +1 -1
- package/gel-core/query-builders/select.types.d.cts +1 -1
- package/gel-core/query-builders/select.types.d.ts +1 -1
- package/mysql-core/dialect.cjs +5 -4
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.js +5 -4
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/select.cjs +72 -34
- package/mysql-core/query-builders/select.cjs.map +1 -1
- package/mysql-core/query-builders/select.d.cts +66 -25
- package/mysql-core/query-builders/select.d.ts +66 -25
- package/mysql-core/query-builders/select.js +72 -34
- package/mysql-core/query-builders/select.js.map +1 -1
- package/mysql-core/query-builders/select.types.cjs.map +1 -1
- package/mysql-core/query-builders/select.types.d.cts +5 -4
- package/mysql-core/query-builders/select.types.d.ts +5 -4
- package/operations.cjs.map +1 -1
- package/operations.d.cts +5 -1
- package/operations.d.ts +5 -1
- package/package.json +1 -1
- package/pg-core/columns/text.cjs.map +1 -1
- package/pg-core/columns/text.d.cts +1 -2
- package/pg-core/columns/text.d.ts +1 -2
- package/pg-core/columns/text.js.map +1 -1
- package/pg-core/dialect.cjs +5 -4
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.js +5 -4
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/select.cjs +80 -14
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +78 -13
- package/pg-core/query-builders/select.d.ts +78 -13
- package/pg-core/query-builders/select.js +80 -14
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +1 -1
- package/pg-core/query-builders/select.types.d.ts +1 -1
- package/pg-core/schema.cjs +2 -2
- package/pg-core/schema.cjs.map +1 -1
- package/pg-core/schema.d.cts +4 -1
- package/pg-core/schema.d.ts +4 -1
- package/pg-core/schema.js +2 -2
- package/pg-core/schema.js.map +1 -1
- package/query-builders/select.types.cjs.map +1 -1
- package/query-builders/select.types.d.cts +3 -1
- package/query-builders/select.types.d.ts +3 -1
- package/singlestore/driver.cjs +24 -2
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +3 -5
- package/singlestore/driver.d.ts +3 -5
- package/singlestore/driver.js +24 -2
- package/singlestore/driver.js.map +1 -1
- package/singlestore-core/dialect.cjs +5 -4
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.js +5 -4
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/select.cjs +80 -14
- package/singlestore-core/query-builders/select.cjs.map +1 -1
- package/singlestore-core/query-builders/select.d.cts +78 -13
- package/singlestore-core/query-builders/select.d.ts +78 -13
- package/singlestore-core/query-builders/select.js +80 -14
- package/singlestore-core/query-builders/select.js.map +1 -1
- package/singlestore-core/query-builders/select.types.cjs.map +1 -1
- package/singlestore-core/query-builders/select.types.d.cts +1 -2
- package/singlestore-core/query-builders/select.types.d.ts +1 -2
- package/sqlite-core/dialect.cjs +3 -2
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.js +3 -2
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs +36 -8
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +40 -13
- package/sqlite-core/query-builders/select.d.ts +40 -13
- package/sqlite-core/query-builders/select.js +36 -8
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/select.types.cjs.map +1 -1
- package/sqlite-core/query-builders/select.types.d.cts +1 -1
- package/sqlite-core/query-builders/select.types.d.ts +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/pg-core/schema.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { entityKind } from "../entity.js";
|
|
2
2
|
import { SQL, type SQLWrapper } from "../sql/sql.js";
|
|
3
|
+
import type { NonArray, Writable } from "../utils.js";
|
|
4
|
+
import { type PgEnum, type PgEnumObject } from "./columns/enum.js";
|
|
3
5
|
import { type pgSequence } from "./sequence.js";
|
|
4
6
|
import { type PgTableFn } from "./table.js";
|
|
5
7
|
import { type pgMaterializedView, type pgView } from "./view.js";
|
|
@@ -10,7 +12,8 @@ export declare class PgSchema<TName extends string = string> implements SQLWrapp
|
|
|
10
12
|
table: PgTableFn<TName>;
|
|
11
13
|
view: typeof pgView;
|
|
12
14
|
materializedView: typeof pgMaterializedView;
|
|
13
|
-
enum:
|
|
15
|
+
enum<U extends string, T extends Readonly<[U, ...U[]]>>(enumName: string, values: T | Writable<T>): PgEnum<Writable<T>>;
|
|
16
|
+
enum<E extends Record<string, string>>(enumName: string, enumObj: NonArray<E>): PgEnumObject<E>;
|
|
14
17
|
sequence: typeof pgSequence;
|
|
15
18
|
getSQL(): SQL;
|
|
16
19
|
shouldOmitSQLParens(): boolean;
|
package/pg-core/schema.js
CHANGED
|
@@ -18,13 +18,13 @@ class PgSchema {
|
|
|
18
18
|
materializedView = (name, columns) => {
|
|
19
19
|
return pgMaterializedViewWithSchema(name, columns, this.schemaName);
|
|
20
20
|
};
|
|
21
|
-
enum
|
|
21
|
+
enum(enumName, input) {
|
|
22
22
|
return Array.isArray(input) ? pgEnumWithSchema(
|
|
23
23
|
enumName,
|
|
24
24
|
[...input],
|
|
25
25
|
this.schemaName
|
|
26
26
|
) : pgEnumObjectWithSchema(enumName, input, this.schemaName);
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
sequence = (name, options) => {
|
|
29
29
|
return pgSequenceWithSchema(name, options, this.schemaName);
|
|
30
30
|
};
|
package/pg-core/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pg-core/schema.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport { pgEnumObjectWithSchema, pgEnumWithSchema } from './columns/enum.ts';\nimport { type pgSequence, pgSequenceWithSchema } from './sequence.ts';\nimport { type PgTableFn, pgTableWithSchema } from './table.ts';\nimport { type pgMaterializedView, pgMaterializedViewWithSchema, type pgView, pgViewWithSchema } from './view.ts';\n\nexport class PgSchema<TName extends string = string> implements SQLWrapper {\n\tstatic readonly [entityKind]: string = 'PgSchema';\n\tconstructor(\n\t\tpublic readonly schemaName: TName,\n\t) {}\n\n\ttable: PgTableFn<TName> = ((name, columns, extraConfig) => {\n\t\treturn pgTableWithSchema(name, columns, extraConfig, this.schemaName);\n\t});\n\n\tview = ((name, columns) => {\n\t\treturn pgViewWithSchema(name, columns, this.schemaName);\n\t}) as typeof pgView;\n\n\tmaterializedView = ((name, columns) => {\n\t\treturn pgMaterializedViewWithSchema(name, columns, this.schemaName);\n\t}) as typeof pgMaterializedView;\n\n\tpublic enum
|
|
1
|
+
{"version":3,"sources":["../../src/pg-core/schema.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { NonArray, Writable } from '~/utils.ts';\nimport { type PgEnum, type PgEnumObject, pgEnumObjectWithSchema, pgEnumWithSchema } from './columns/enum.ts';\nimport { type pgSequence, pgSequenceWithSchema } from './sequence.ts';\nimport { type PgTableFn, pgTableWithSchema } from './table.ts';\nimport { type pgMaterializedView, pgMaterializedViewWithSchema, type pgView, pgViewWithSchema } from './view.ts';\n\nexport class PgSchema<TName extends string = string> implements SQLWrapper {\n\tstatic readonly [entityKind]: string = 'PgSchema';\n\tconstructor(\n\t\tpublic readonly schemaName: TName,\n\t) {}\n\n\ttable: PgTableFn<TName> = ((name, columns, extraConfig) => {\n\t\treturn pgTableWithSchema(name, columns, extraConfig, this.schemaName);\n\t});\n\n\tview = ((name, columns) => {\n\t\treturn pgViewWithSchema(name, columns, this.schemaName);\n\t}) as typeof pgView;\n\n\tmaterializedView = ((name, columns) => {\n\t\treturn pgMaterializedViewWithSchema(name, columns, this.schemaName);\n\t}) as typeof pgMaterializedView;\n\n\tpublic enum<U extends string, T extends Readonly<[U, ...U[]]>>(\n\t\tenumName: string,\n\t\tvalues: T | Writable<T>,\n\t): PgEnum<Writable<T>>;\n\n\tpublic enum<E extends Record<string, string>>(\n\t\tenumName: string,\n\t\tenumObj: NonArray<E>,\n\t): PgEnumObject<E>;\n\n\tpublic enum(enumName: any, input: any): any {\n\t\treturn Array.isArray(input)\n\t\t\t? pgEnumWithSchema(\n\t\t\t\tenumName,\n\t\t\t\t[...input] as [string, ...string[]],\n\t\t\t\tthis.schemaName,\n\t\t\t)\n\t\t\t: pgEnumObjectWithSchema(enumName, input, this.schemaName);\n\t}\n\n\tsequence: typeof pgSequence = ((name, options) => {\n\t\treturn pgSequenceWithSchema(name, options, this.schemaName);\n\t});\n\n\tgetSQL(): SQL {\n\t\treturn new SQL([sql.identifier(this.schemaName)]);\n\t}\n\n\tshouldOmitSQLParens(): boolean {\n\t\treturn true;\n\t}\n}\n\nexport function isPgSchema(obj: unknown): obj is PgSchema {\n\treturn is(obj, PgSchema);\n}\n\nexport function pgSchema<T extends string>(name: T) {\n\tif (name === 'public') {\n\t\tthrow new Error(\n\t\t\t`You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use pgTable() instead of creating a schema`,\n\t\t);\n\t}\n\n\treturn new PgSchema(name);\n}\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAC/B,SAAS,KAAK,WAA4B;AAE1C,SAAyC,wBAAwB,wBAAwB;AACzF,SAA0B,4BAA4B;AACtD,SAAyB,yBAAyB;AAClD,SAAkC,8BAA2C,wBAAwB;AAE9F,MAAM,SAA8D;AAAA,EAE1E,YACiB,YACf;AADe;AAAA,EACd;AAAA,EAHH,QAAiB,UAAU,IAAY;AAAA,EAKvC,QAA2B,CAAC,MAAM,SAAS,gBAAgB;AAC1D,WAAO,kBAAkB,MAAM,SAAS,aAAa,KAAK,UAAU;AAAA,EACrE;AAAA,EAEA,OAAQ,CAAC,MAAM,YAAY;AAC1B,WAAO,iBAAiB,MAAM,SAAS,KAAK,UAAU;AAAA,EACvD;AAAA,EAEA,mBAAoB,CAAC,MAAM,YAAY;AACtC,WAAO,6BAA6B,MAAM,SAAS,KAAK,UAAU;AAAA,EACnE;AAAA,EAYO,KAAK,UAAe,OAAiB;AAC3C,WAAO,MAAM,QAAQ,KAAK,IACvB;AAAA,MACD;AAAA,MACA,CAAC,GAAG,KAAK;AAAA,MACT,KAAK;AAAA,IACN,IACE,uBAAuB,UAAU,OAAO,KAAK,UAAU;AAAA,EAC3D;AAAA,EAEA,WAA+B,CAAC,MAAM,YAAY;AACjD,WAAO,qBAAqB,MAAM,SAAS,KAAK,UAAU;AAAA,EAC3D;AAAA,EAEA,SAAc;AACb,WAAO,IAAI,IAAI,CAAC,IAAI,WAAW,KAAK,UAAU,CAAC,CAAC;AAAA,EACjD;AAAA,EAEA,sBAA+B;AAC9B,WAAO;AAAA,EACR;AACD;AAEO,SAAS,WAAW,KAA+B;AACzD,SAAO,GAAG,KAAK,QAAQ;AACxB;AAEO,SAAS,SAA2B,MAAS;AACnD,MAAI,SAAS,UAAU;AACtB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,IAAI,SAAS,IAAI;AACzB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/query-builders/select.types.ts"],"sourcesContent":["import type { ChangeColumnTableName, ColumnDataType, Dialect } from '~/column-builder.ts';\nimport type { AnyColumn, Column, ColumnBaseConfig, GetColumnData, UpdateColConfig } from '~/column.ts';\nimport type { SelectedFields } from '~/operations.ts';\nimport type { ColumnsSelection, SQL, View } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport type { Table } from '~/table.ts';\nimport type { Assume, DrizzleTypeError, Equal, IsAny, Simplify } from '~/utils.ts';\n\nexport type JoinType = 'inner' | 'left' | 'right' | 'full';\n\nexport type JoinNullability = 'nullable' | 'not-null';\n\nexport type ApplyNullability<T, TNullability extends JoinNullability> = TNullability extends 'nullable' ? T | null\n\t: TNullability extends 'null' ? null\n\t: T;\n\nexport type ApplyNullabilityToColumn<TColumn extends Column, TNullability extends JoinNullability> =\n\tTNullability extends 'not-null' ? TColumn\n\t\t: Column<\n\t\t\tAssume<\n\t\t\t\tUpdateColConfig<TColumn['_'], {\n\t\t\t\t\tnotNull: TNullability extends 'nullable' ? false : TColumn['_']['notNull'];\n\t\t\t\t}>,\n\t\t\t\tColumnBaseConfig<ColumnDataType, string>\n\t\t\t>\n\t\t>;\n\nexport type ApplyNotNullMapToJoins<TResult, TNullabilityMap extends Record<string, JoinNullability>> =\n\t& {\n\t\t[TTableName in keyof TResult & keyof TNullabilityMap & string]: ApplyNullability<\n\t\t\tTResult[TTableName],\n\t\t\tTNullabilityMap[TTableName]\n\t\t>;\n\t}\n\t& {};\n\nexport type SelectMode = 'partial' | 'single' | 'multiple';\n\nexport type SelectResult<\n\tTResult,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability>,\n> = TSelectMode extends 'partial' ? SelectPartialResult<TResult, TNullabilityMap>\n\t: TSelectMode extends 'single' ? SelectResultFields<TResult>\n\t: ApplyNotNullMapToJoins<SelectResultFields<TResult>, TNullabilityMap>;\n\ntype IsUnion<T, U extends T = T> = (T extends any ? (U extends T ? false : true) : never) extends false ? false : true;\n\ntype Not<T extends boolean> = T extends true ? false : true;\n\ntype SelectPartialResult<TFields, TNullability extends Record<string, JoinNullability>> = TNullability extends\n\tTNullability ? {\n\t\t[Key in keyof TFields]: TFields[Key] extends infer TField\n\t\t\t? TField extends Table ? TField['_']['name'] extends keyof TNullability ? ApplyNullability<\n\t\t\t\t\t\tSelectResultFields<TField['_']['columns']>,\n\t\t\t\t\t\tTNullability[TField['_']['name']]\n\t\t\t\t\t>\n\t\t\t\t: never\n\t\t\t: TField extends Column\n\t\t\t\t? TField['_']['tableName'] extends keyof TNullability\n\t\t\t\t\t? ApplyNullability<SelectResultField<TField>, TNullability[TField['_']['tableName']]>\n\t\t\t\t: never\n\t\t\t: TField extends SQL | SQL.Aliased ? SelectResultField<TField>\n\t\t\t: TField extends Record<string, any>\n\t\t\t\t? TField[keyof TField] extends AnyColumn<{ tableName: infer TTableName extends string }> | SQL | SQL.Aliased\n\t\t\t\t\t? Not<IsUnion<TTableName>> extends true\n\t\t\t\t\t\t? ApplyNullability<SelectResultFields<TField>, TNullability[TTableName]>\n\t\t\t\t\t: SelectPartialResult<TField, TNullability>\n\t\t\t\t: never\n\t\t\t: never\n\t\t\t: never;\n\t}\n\t: never;\n\nexport type MapColumnsToTableAlias<\n\tTColumns extends ColumnsSelection,\n\tTAlias extends string,\n\tTDialect extends Dialect,\n> =\n\t& {\n\t\t[Key in keyof TColumns]: TColumns[Key] extends Column\n\t\t\t? ChangeColumnTableName<Assume<TColumns[Key], Column>, TAlias, TDialect>\n\t\t\t: TColumns[Key];\n\t}\n\t& {};\n\nexport type AddAliasToSelection<\n\tTSelection extends ColumnsSelection,\n\tTAlias extends string,\n\tTDialect extends Dialect,\n> = Simplify<\n\tIsAny<TSelection> extends true ? any\n\t\t: {\n\t\t\t[Key in keyof TSelection]: TSelection[Key] extends Column\n\t\t\t\t? ChangeColumnTableName<TSelection[Key], TAlias, TDialect>\n\t\t\t\t: TSelection[Key] extends Table ? AddAliasToSelection<TSelection[Key]['_']['columns'], TAlias, TDialect>\n\t\t\t\t: TSelection[Key] extends SQL | SQL.Aliased ? TSelection[Key]\n\t\t\t\t: TSelection[Key] extends ColumnsSelection ? MapColumnsToTableAlias<TSelection[Key], TAlias, TDialect>\n\t\t\t\t: never;\n\t\t}\n>;\n\nexport type AppendToResult<\n\tTTableName extends string | undefined,\n\tTResult,\n\tTJoinedName extends string | undefined,\n\tTSelectedFields extends SelectedFields<Column, Table>,\n\tTOldSelectMode extends SelectMode,\n> = TOldSelectMode extends 'partial' ? TResult\n\t: TOldSelectMode extends 'single' ?\n\t\t\t& (TTableName extends string ? Record<TTableName, TResult> : TResult)\n\t\t\t& (TJoinedName extends string ? Record<TJoinedName, TSelectedFields> : TSelectedFields)\n\t: TResult & (TJoinedName extends string ? Record<TJoinedName, TSelectedFields> : TSelectedFields);\n\nexport type BuildSubquerySelection<\n\tTSelection extends ColumnsSelection,\n\tTNullability extends Record<string, JoinNullability>,\n> = TSelection extends never ? any\n\t:\n\t\t& {\n\t\t\t[Key in keyof TSelection]: TSelection[Key] extends SQL\n\t\t\t\t? DrizzleTypeError<'You cannot reference this field without assigning it an alias first - use `.as(<alias>)`'>\n\t\t\t\t: TSelection[Key] extends SQL.Aliased ? TSelection[Key]\n\t\t\t\t: TSelection[Key] extends Table ? BuildSubquerySelection<TSelection[Key]['_']['columns'], TNullability>\n\t\t\t\t: TSelection[Key] extends Column\n\t\t\t\t\t? ApplyNullabilityToColumn<TSelection[Key], TNullability[TSelection[Key]['_']['tableName']]>\n\t\t\t\t: TSelection[Key] extends ColumnsSelection ? BuildSubquerySelection<TSelection[Key], TNullability>\n\t\t\t\t: never;\n\t\t}\n\t\t& {};\n\ntype SetJoinsNullability<TNullabilityMap extends Record<string, JoinNullability>, TValue extends JoinNullability> = {\n\t[Key in keyof TNullabilityMap]: TValue;\n};\n\nexport type AppendToNullabilityMap<\n\tTJoinsNotNull extends Record<string, JoinNullability>,\n\tTJoinedName extends string | undefined,\n\tTJoinType extends JoinType,\n> = TJoinedName extends string ? 'left' extends TJoinType ? TJoinsNotNull & { [name in TJoinedName]: 'nullable' }\n\t: 'right' extends TJoinType ? SetJoinsNullability<TJoinsNotNull, 'nullable'> & { [name in TJoinedName]: 'not-null' }\n\t: 'inner' extends TJoinType ? TJoinsNotNull & { [name in TJoinedName]: 'not-null' }\n\t: 'full' extends TJoinType ? SetJoinsNullability<TJoinsNotNull, 'nullable'> & { [name in TJoinedName]: 'nullable' }\n\t: never\n\t: TJoinsNotNull;\n\nexport type TableLike = Table | Subquery | View | SQL;\n\nexport type GetSelectTableName<TTable extends TableLike> = TTable extends Table ? TTable['_']['name']\n\t: TTable extends Subquery ? TTable['_']['alias']\n\t: TTable extends View ? TTable['_']['name']\n\t: TTable extends SQL ? undefined\n\t: never;\n\nexport type GetSelectTableSelection<TTable extends TableLike> = TTable extends Table ? TTable['_']['columns']\n\t: TTable extends Subquery | View ? Assume<TTable['_']['selectedFields'], ColumnsSelection>\n\t: TTable extends SQL ? {}\n\t: never;\n\nexport type SelectResultField<T, TDeep extends boolean = true> = T extends DrizzleTypeError<any> ? T\n\t: T extends Table ? Equal<TDeep, true> extends true ? SelectResultField<T['_']['columns'], false> : never\n\t: T extends Column<any> ? GetColumnData<T>\n\t: T extends SQL | SQL.Aliased ? T['_']['type']\n\t: T extends Record<string, any> ? SelectResultFields<T, true>\n\t: never;\n\nexport type SelectResultFields<TSelectedFields, TDeep extends boolean = true> = Simplify<\n\t{\n\t\t[Key in keyof TSelectedFields]: SelectResultField<TSelectedFields[Key], TDeep>;\n\t}\n>;\n\nexport type SetOperator = 'union' | 'intersect' | 'except';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/query-builders/select.types.ts"],"sourcesContent":["import type { ChangeColumnTableName, ColumnDataType, Dialect } from '~/column-builder.ts';\nimport type { AnyColumn, Column, ColumnBaseConfig, GetColumnData, UpdateColConfig } from '~/column.ts';\nimport type { SelectedFields } from '~/operations.ts';\nimport type { ColumnsSelection, SQL, View } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport type { Table } from '~/table.ts';\nimport type { Assume, DrizzleTypeError, Equal, IsAny, Simplify } from '~/utils.ts';\n\nexport type JoinType = 'inner' | 'left' | 'right' | 'full' | 'cross';\n\nexport type JoinNullability = 'nullable' | 'not-null';\n\nexport type ApplyNullability<T, TNullability extends JoinNullability> = TNullability extends 'nullable' ? T | null\n\t: TNullability extends 'null' ? null\n\t: T;\n\nexport type ApplyNullabilityToColumn<TColumn extends Column, TNullability extends JoinNullability> =\n\tTNullability extends 'not-null' ? TColumn\n\t\t: Column<\n\t\t\tAssume<\n\t\t\t\tUpdateColConfig<TColumn['_'], {\n\t\t\t\t\tnotNull: TNullability extends 'nullable' ? false : TColumn['_']['notNull'];\n\t\t\t\t}>,\n\t\t\t\tColumnBaseConfig<ColumnDataType, string>\n\t\t\t>\n\t\t>;\n\nexport type ApplyNotNullMapToJoins<TResult, TNullabilityMap extends Record<string, JoinNullability>> =\n\t& {\n\t\t[TTableName in keyof TResult & keyof TNullabilityMap & string]: ApplyNullability<\n\t\t\tTResult[TTableName],\n\t\t\tTNullabilityMap[TTableName]\n\t\t>;\n\t}\n\t& {};\n\nexport type SelectMode = 'partial' | 'single' | 'multiple';\n\nexport type SelectResult<\n\tTResult,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability>,\n> = TSelectMode extends 'partial' ? SelectPartialResult<TResult, TNullabilityMap>\n\t: TSelectMode extends 'single' ? SelectResultFields<TResult>\n\t: ApplyNotNullMapToJoins<SelectResultFields<TResult>, TNullabilityMap>;\n\ntype IsUnion<T, U extends T = T> = (T extends any ? (U extends T ? false : true) : never) extends false ? false : true;\n\ntype Not<T extends boolean> = T extends true ? false : true;\n\ntype SelectPartialResult<TFields, TNullability extends Record<string, JoinNullability>> = TNullability extends\n\tTNullability ? {\n\t\t[Key in keyof TFields]: TFields[Key] extends infer TField\n\t\t\t? TField extends Table ? TField['_']['name'] extends keyof TNullability ? ApplyNullability<\n\t\t\t\t\t\tSelectResultFields<TField['_']['columns']>,\n\t\t\t\t\t\tTNullability[TField['_']['name']]\n\t\t\t\t\t>\n\t\t\t\t: never\n\t\t\t: TField extends Column\n\t\t\t\t? TField['_']['tableName'] extends keyof TNullability\n\t\t\t\t\t? ApplyNullability<SelectResultField<TField>, TNullability[TField['_']['tableName']]>\n\t\t\t\t: never\n\t\t\t: TField extends SQL | SQL.Aliased ? SelectResultField<TField>\n\t\t\t: TField extends Record<string, any>\n\t\t\t\t? TField[keyof TField] extends AnyColumn<{ tableName: infer TTableName extends string }> | SQL | SQL.Aliased\n\t\t\t\t\t? Not<IsUnion<TTableName>> extends true\n\t\t\t\t\t\t? ApplyNullability<SelectResultFields<TField>, TNullability[TTableName]>\n\t\t\t\t\t: SelectPartialResult<TField, TNullability>\n\t\t\t\t: never\n\t\t\t: never\n\t\t\t: never;\n\t}\n\t: never;\n\nexport type MapColumnsToTableAlias<\n\tTColumns extends ColumnsSelection,\n\tTAlias extends string,\n\tTDialect extends Dialect,\n> =\n\t& {\n\t\t[Key in keyof TColumns]: TColumns[Key] extends Column\n\t\t\t? ChangeColumnTableName<Assume<TColumns[Key], Column>, TAlias, TDialect>\n\t\t\t: TColumns[Key];\n\t}\n\t& {};\n\nexport type AddAliasToSelection<\n\tTSelection extends ColumnsSelection,\n\tTAlias extends string,\n\tTDialect extends Dialect,\n> = Simplify<\n\tIsAny<TSelection> extends true ? any\n\t\t: {\n\t\t\t[Key in keyof TSelection]: TSelection[Key] extends Column\n\t\t\t\t? ChangeColumnTableName<TSelection[Key], TAlias, TDialect>\n\t\t\t\t: TSelection[Key] extends Table ? AddAliasToSelection<TSelection[Key]['_']['columns'], TAlias, TDialect>\n\t\t\t\t: TSelection[Key] extends SQL | SQL.Aliased ? TSelection[Key]\n\t\t\t\t: TSelection[Key] extends ColumnsSelection ? MapColumnsToTableAlias<TSelection[Key], TAlias, TDialect>\n\t\t\t\t: never;\n\t\t}\n>;\n\nexport type AppendToResult<\n\tTTableName extends string | undefined,\n\tTResult,\n\tTJoinedName extends string | undefined,\n\tTSelectedFields extends SelectedFields<Column, Table>,\n\tTOldSelectMode extends SelectMode,\n> = TOldSelectMode extends 'partial' ? TResult\n\t: TOldSelectMode extends 'single' ?\n\t\t\t& (TTableName extends string ? Record<TTableName, TResult> : TResult)\n\t\t\t& (TJoinedName extends string ? Record<TJoinedName, TSelectedFields> : TSelectedFields)\n\t: TResult & (TJoinedName extends string ? Record<TJoinedName, TSelectedFields> : TSelectedFields);\n\nexport type BuildSubquerySelection<\n\tTSelection extends ColumnsSelection,\n\tTNullability extends Record<string, JoinNullability>,\n> = TSelection extends never ? any\n\t:\n\t\t& {\n\t\t\t[Key in keyof TSelection]: TSelection[Key] extends SQL\n\t\t\t\t? DrizzleTypeError<'You cannot reference this field without assigning it an alias first - use `.as(<alias>)`'>\n\t\t\t\t: TSelection[Key] extends SQL.Aliased ? TSelection[Key]\n\t\t\t\t: TSelection[Key] extends Table ? BuildSubquerySelection<TSelection[Key]['_']['columns'], TNullability>\n\t\t\t\t: TSelection[Key] extends Column\n\t\t\t\t\t? ApplyNullabilityToColumn<TSelection[Key], TNullability[TSelection[Key]['_']['tableName']]>\n\t\t\t\t: TSelection[Key] extends ColumnsSelection ? BuildSubquerySelection<TSelection[Key], TNullability>\n\t\t\t\t: never;\n\t\t}\n\t\t& {};\n\ntype SetJoinsNullability<TNullabilityMap extends Record<string, JoinNullability>, TValue extends JoinNullability> = {\n\t[Key in keyof TNullabilityMap]: TValue;\n};\n\nexport type AppendToNullabilityMap<\n\tTJoinsNotNull extends Record<string, JoinNullability>,\n\tTJoinedName extends string | undefined,\n\tTJoinType extends JoinType,\n> = TJoinedName extends string ? 'left' extends TJoinType ? TJoinsNotNull & { [name in TJoinedName]: 'nullable' }\n\t: 'right' extends TJoinType ? SetJoinsNullability<TJoinsNotNull, 'nullable'> & { [name in TJoinedName]: 'not-null' }\n\t: 'inner' extends TJoinType ? TJoinsNotNull & { [name in TJoinedName]: 'not-null' }\n\t: 'cross' extends TJoinType ? TJoinsNotNull & { [name in TJoinedName]: 'not-null' }\n\t: 'full' extends TJoinType ? SetJoinsNullability<TJoinsNotNull, 'nullable'> & { [name in TJoinedName]: 'nullable' }\n\t: never\n\t: TJoinsNotNull;\n\nexport type TableLike = Table | Subquery | View | SQL;\n\nexport type GetSelectTableName<TTable extends TableLike> = TTable extends Table ? TTable['_']['name']\n\t: TTable extends Subquery ? TTable['_']['alias']\n\t: TTable extends View ? TTable['_']['name']\n\t: TTable extends SQL ? undefined\n\t: never;\n\nexport type GetSelectTableSelection<TTable extends TableLike> = TTable extends Table ? TTable['_']['columns']\n\t: TTable extends Subquery | View ? Assume<TTable['_']['selectedFields'], ColumnsSelection>\n\t: TTable extends SQL ? {}\n\t: never;\n\nexport type SelectResultField<T, TDeep extends boolean = true> = T extends DrizzleTypeError<any> ? T\n\t: T extends Table ? Equal<TDeep, true> extends true ? SelectResultField<T['_']['columns'], false> : never\n\t: T extends Column<any> ? GetColumnData<T>\n\t: T extends SQL | SQL.Aliased ? T['_']['type']\n\t: T extends Record<string, any> ? SelectResultFields<T, true>\n\t: never;\n\nexport type SelectResultFields<TSelectedFields, TDeep extends boolean = true> = Simplify<\n\t{\n\t\t[Key in keyof TSelectedFields]: SelectResultField<TSelectedFields[Key], TDeep>;\n\t}\n>;\n\nexport type SetOperator = 'union' | 'intersect' | 'except';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -5,7 +5,7 @@ import type { ColumnsSelection, SQL, View } from "../sql/sql.cjs";
|
|
|
5
5
|
import type { Subquery } from "../subquery.cjs";
|
|
6
6
|
import type { Table } from "../table.cjs";
|
|
7
7
|
import type { Assume, DrizzleTypeError, Equal, IsAny, Simplify } from "../utils.cjs";
|
|
8
|
-
export type JoinType = 'inner' | 'left' | 'right' | 'full';
|
|
8
|
+
export type JoinType = 'inner' | 'left' | 'right' | 'full' | 'cross';
|
|
9
9
|
export type JoinNullability = 'nullable' | 'not-null';
|
|
10
10
|
export type ApplyNullability<T, TNullability extends JoinNullability> = TNullability extends 'nullable' ? T | null : TNullability extends 'null' ? null : T;
|
|
11
11
|
export type ApplyNullabilityToColumn<TColumn extends Column, TNullability extends JoinNullability> = TNullability extends 'not-null' ? TColumn : Column<Assume<UpdateColConfig<TColumn['_'], {
|
|
@@ -42,6 +42,8 @@ export type AppendToNullabilityMap<TJoinsNotNull extends Record<string, JoinNull
|
|
|
42
42
|
[name in TJoinedName]: 'not-null';
|
|
43
43
|
} : 'inner' extends TJoinType ? TJoinsNotNull & {
|
|
44
44
|
[name in TJoinedName]: 'not-null';
|
|
45
|
+
} : 'cross' extends TJoinType ? TJoinsNotNull & {
|
|
46
|
+
[name in TJoinedName]: 'not-null';
|
|
45
47
|
} : 'full' extends TJoinType ? SetJoinsNullability<TJoinsNotNull, 'nullable'> & {
|
|
46
48
|
[name in TJoinedName]: 'nullable';
|
|
47
49
|
} : never : TJoinsNotNull;
|
|
@@ -5,7 +5,7 @@ import type { ColumnsSelection, SQL, View } from "../sql/sql.js";
|
|
|
5
5
|
import type { Subquery } from "../subquery.js";
|
|
6
6
|
import type { Table } from "../table.js";
|
|
7
7
|
import type { Assume, DrizzleTypeError, Equal, IsAny, Simplify } from "../utils.js";
|
|
8
|
-
export type JoinType = 'inner' | 'left' | 'right' | 'full';
|
|
8
|
+
export type JoinType = 'inner' | 'left' | 'right' | 'full' | 'cross';
|
|
9
9
|
export type JoinNullability = 'nullable' | 'not-null';
|
|
10
10
|
export type ApplyNullability<T, TNullability extends JoinNullability> = TNullability extends 'nullable' ? T | null : TNullability extends 'null' ? null : T;
|
|
11
11
|
export type ApplyNullabilityToColumn<TColumn extends Column, TNullability extends JoinNullability> = TNullability extends 'not-null' ? TColumn : Column<Assume<UpdateColConfig<TColumn['_'], {
|
|
@@ -42,6 +42,8 @@ export type AppendToNullabilityMap<TJoinsNotNull extends Record<string, JoinNull
|
|
|
42
42
|
[name in TJoinedName]: 'not-null';
|
|
43
43
|
} : 'inner' extends TJoinType ? TJoinsNotNull & {
|
|
44
44
|
[name in TJoinedName]: 'not-null';
|
|
45
|
+
} : 'cross' extends TJoinType ? TJoinsNotNull & {
|
|
46
|
+
[name in TJoinedName]: 'not-null';
|
|
45
47
|
} : 'full' extends TJoinType ? SetJoinsNullability<TJoinsNotNull, 'nullable'> & {
|
|
46
48
|
[name in TJoinedName]: 'nullable';
|
|
47
49
|
} : never : TJoinsNotNull;
|
package/singlestore/driver.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var import_logger = require("../logger.cjs");
|
|
|
31
31
|
var import_db = require("../singlestore-core/db.cjs");
|
|
32
32
|
var import_dialect = require("../singlestore-core/dialect.cjs");
|
|
33
33
|
var import_utils = require("../utils.cjs");
|
|
34
|
+
var import_version = require("../version.cjs");
|
|
34
35
|
var import_session = require("./session.cjs");
|
|
35
36
|
var import_db2 = require("../singlestore-core/db.cjs");
|
|
36
37
|
class SingleStoreDriverDriver {
|
|
@@ -77,11 +78,16 @@ function construct(client, config = {}) {
|
|
|
77
78
|
function isCallbackClient(client) {
|
|
78
79
|
return typeof client.promise === "function";
|
|
79
80
|
}
|
|
81
|
+
const CONNECTION_ATTRS = {
|
|
82
|
+
_connector_name: "SingleStore Drizzle ORM Driver",
|
|
83
|
+
_connector_version: import_version.npmVersion
|
|
84
|
+
};
|
|
80
85
|
function drizzle(...params) {
|
|
81
86
|
if (typeof params[0] === "string") {
|
|
82
87
|
const connectionString = params[0];
|
|
83
88
|
const instance = (0, import_mysql2.createPool)({
|
|
84
|
-
uri: connectionString
|
|
89
|
+
uri: connectionString,
|
|
90
|
+
connectAttributes: CONNECTION_ATTRS
|
|
85
91
|
});
|
|
86
92
|
return construct(instance, params[1]);
|
|
87
93
|
}
|
|
@@ -89,7 +95,23 @@ function drizzle(...params) {
|
|
|
89
95
|
const { connection, client, ...drizzleConfig } = params[0];
|
|
90
96
|
if (client)
|
|
91
97
|
return construct(client, drizzleConfig);
|
|
92
|
-
|
|
98
|
+
let opts = {};
|
|
99
|
+
if (typeof connection === "string") {
|
|
100
|
+
opts = {
|
|
101
|
+
uri: connection,
|
|
102
|
+
supportBigNumbers: true,
|
|
103
|
+
connectAttributes: CONNECTION_ATTRS
|
|
104
|
+
};
|
|
105
|
+
} else {
|
|
106
|
+
opts = {
|
|
107
|
+
...connection,
|
|
108
|
+
connectAttributes: {
|
|
109
|
+
...connection.connectAttributes,
|
|
110
|
+
...CONNECTION_ATTRS
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const instance = (0, import_mysql2.createPool)(opts);
|
|
93
115
|
const db = construct(instance, drizzleConfig);
|
|
94
116
|
return db;
|
|
95
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/singlestore/driver.ts"],"sourcesContent":["import { type Connection as CallbackConnection, createPool, type Pool as CallbackPool, type PoolOptions } from 'mysql2';\nimport type { Connection, Pool } from 'mysql2/promise';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { SingleStoreDatabase } from '~/singlestore-core/db.ts';\nimport { SingleStoreDialect } from '~/singlestore-core/dialect.ts';\nimport { type DrizzleConfig,
|
|
1
|
+
{"version":3,"sources":["../../src/singlestore/driver.ts"],"sourcesContent":["import { type Connection as CallbackConnection, createPool, type Pool as CallbackPool, type PoolOptions } from 'mysql2';\nimport type { Connection, Pool } from 'mysql2/promise';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { SingleStoreDatabase } from '~/singlestore-core/db.ts';\nimport { SingleStoreDialect } from '~/singlestore-core/dialect.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { npmVersion } from '~/version.ts';\nimport type {\n\tSingleStoreDriverClient,\n\tSingleStoreDriverPreparedQueryHKT,\n\tSingleStoreDriverQueryResultHKT,\n} from './session.ts';\nimport { SingleStoreDriverSession } from './session.ts';\n\nexport interface SingleStoreDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class SingleStoreDriverDriver {\n\tstatic readonly [entityKind]: string = 'SingleStoreDriverDriver';\n\n\tconstructor(\n\t\tprivate client: SingleStoreDriverClient,\n\t\tprivate dialect: SingleStoreDialect,\n\t\tprivate options: SingleStoreDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): SingleStoreDriverSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new SingleStoreDriverSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport { SingleStoreDatabase } from '~/singlestore-core/db.ts';\n\nexport class SingleStoreDriverDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends SingleStoreDatabase<SingleStoreDriverQueryResultHKT, SingleStoreDriverPreparedQueryHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SingleStoreDriverDatabase';\n}\n\nexport type SingleStoreDriverDrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> =\n\t& Omit<DrizzleConfig<TSchema>, 'schema'>\n\t& ({ schema: TSchema } | { schema?: undefined });\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends Pool | Connection | CallbackPool | CallbackConnection = CallbackPool,\n>(\n\tclient: TClient,\n\tconfig: SingleStoreDriverDrizzleConfig<TSchema> = {},\n): SingleStoreDriverDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tconst dialect = new SingleStoreDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tconst clientForInstance = isCallbackClient(client) ? client.promise() : client;\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst driver = new SingleStoreDriverDriver(clientForInstance as SingleStoreDriverClient, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new SingleStoreDriverDatabase(dialect, session, schema as any) as SingleStoreDriverDatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\ninterface CallbackClient {\n\tpromise(): SingleStoreDriverClient;\n}\n\nfunction isCallbackClient(client: any): client is CallbackClient {\n\treturn typeof client.promise === 'function';\n}\n\nexport type AnySingleStoreDriverConnection = Pool | Connection | CallbackPool | CallbackConnection;\n\nconst CONNECTION_ATTRS: PoolOptions['connectAttributes'] = {\n\t_connector_name: 'SingleStore Drizzle ORM Driver',\n\t_connector_version: npmVersion,\n};\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends AnySingleStoreDriverConnection = CallbackPool,\n>(\n\t...params: [\n\t\tTClient | string,\n\t] | [\n\t\tTClient | string,\n\t\tSingleStoreDriverDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& SingleStoreDriverDrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tconnection: string | PoolOptions;\n\t\t\t} | {\n\t\t\t\tclient: TClient;\n\t\t\t})\n\t\t),\n\t]\n): SingleStoreDriverDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (typeof params[0] === 'string') {\n\t\tconst connectionString = params[0]!;\n\t\tconst instance = createPool({\n\t\t\turi: connectionString,\n\t\t\tconnectAttributes: CONNECTION_ATTRS,\n\t\t});\n\n\t\treturn construct(instance, params[1]) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as\n\t\t\t& { connection?: PoolOptions | string; client?: TClient }\n\t\t\t& SingleStoreDriverDrizzleConfig<TSchema>;\n\n\t\tif (client) return construct(client, drizzleConfig) as any;\n\n\t\tlet opts: PoolOptions = {};\n\t\tif (typeof connection === 'string') {\n\t\t\topts = {\n\t\t\t\turi: connection,\n\t\t\t\tsupportBigNumbers: true,\n\t\t\t\tconnectAttributes: CONNECTION_ATTRS,\n\t\t\t};\n\t\t} else {\n\t\t\topts = {\n\t\t\t\t...connection,\n\t\t\t\tconnectAttributes: {\n\t\t\t\t\t...connection!.connectAttributes,\n\t\t\t\t\t...CONNECTION_ATTRS,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst instance = createPool(opts);\n\t\tconst db = construct(instance, drizzleConfig);\n\n\t\treturn db as any;\n\t}\n\n\treturn construct(params[0] as TClient, params[1] as SingleStoreDriverDrizzleConfig<TSchema> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<TSchema extends Record<string, unknown> = Record<string, never>>(\n\t\tconfig?: SingleStoreDriverDrizzleConfig<TSchema>,\n\t): SingleStoreDriverDatabase<TSchema> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+G;AAE/G,uBAKO;AACP,oBAA2B;AAE3B,oBAA8B;AAC9B,gBAAoC;AACpC,qBAAmC;AACnC,mBAA6C;AAC7C,qBAA2B;AAM3B,qBAAyC;AAuBzC,IAAAA,aAAoC;AAjB7B,MAAM,wBAAwB;AAAA,EAGpC,YACS,QACA,SACA,UAAoC,CAAC,GAC5C;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,wBAAU,IAAY;AAAA,EASvC,cACC,QAC4E;AAC5E,WAAO,IAAI,wCAAyB,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,EACvG;AACD;AAIO,MAAM,kCAEH,8BAAiG;AAAA,EAC1G,QAA0B,wBAAU,IAAY;AACjD;AAMA,SAAS,UAIR,QACA,SAAkD,CAAC,GAGlD;AACD,QAAM,UAAU,IAAI,kCAAmB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAChE,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,QAAM,oBAAoB,iBAAiB,MAAM,IAAI,OAAO,QAAQ,IAAI;AAExE,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,SAAS,IAAI,wBAAwB,mBAA8C,SAAS,EAAE,OAAO,CAAC;AAC5G,QAAM,UAAU,OAAO,cAAc,MAAM;AAC3C,QAAM,KAAK,IAAI,0BAA0B,SAAS,SAAS,MAAa;AACxE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAMA,SAAS,iBAAiB,QAAuC;AAChE,SAAO,OAAO,OAAO,YAAY;AAClC;AAIA,MAAM,mBAAqD;AAAA,EAC1D,iBAAiB;AAAA,EACjB,oBAAoB;AACrB;AAEO,SAAS,WAIZ,QAiBF;AACD,MAAI,OAAO,OAAO,CAAC,MAAM,UAAU;AAClC,UAAM,mBAAmB,OAAO,CAAC;AACjC,UAAM,eAAW,0BAAW;AAAA,MAC3B,KAAK;AAAA,MACL,mBAAmB;AAAA,IACpB,CAAC;AAED,WAAO,UAAU,UAAU,OAAO,CAAC,CAAC;AAAA,EACrC;AAEA,UAAI,uBAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,YAAY,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAIzD,QAAI;AAAQ,aAAO,UAAU,QAAQ,aAAa;AAElD,QAAI,OAAoB,CAAC;AACzB,QAAI,OAAO,eAAe,UAAU;AACnC,aAAO;AAAA,QACN,KAAK;AAAA,QACL,mBAAmB;AAAA,QACnB,mBAAmB;AAAA,MACpB;AAAA,IACD,OAAO;AACN,aAAO;AAAA,QACN,GAAG;AAAA,QACH,mBAAmB;AAAA,UAClB,GAAG,WAAY;AAAA,UACf,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAEA,UAAM,eAAW,0BAAW,IAAI;AAChC,UAAM,KAAK,UAAU,UAAU,aAAa;AAE5C,WAAO;AAAA,EACR;AAEA,SAAO,UAAU,OAAO,CAAC,GAAc,OAAO,CAAC,CAAwD;AACxG;AAAA,CAEO,CAAUC,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["import_db","drizzle"]}
|
package/singlestore/driver.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { entityKind } from "../entity.cjs";
|
|
|
5
5
|
import type { Logger } from "../logger.cjs";
|
|
6
6
|
import { SingleStoreDatabase } from "../singlestore-core/db.cjs";
|
|
7
7
|
import { SingleStoreDialect } from "../singlestore-core/dialect.cjs";
|
|
8
|
-
import { type DrizzleConfig
|
|
8
|
+
import { type DrizzleConfig } from "../utils.cjs";
|
|
9
9
|
import type { SingleStoreDriverClient, SingleStoreDriverPreparedQueryHKT, SingleStoreDriverQueryResultHKT } from "./session.cjs";
|
|
10
10
|
import { SingleStoreDriverSession } from "./session.cjs";
|
|
11
11
|
export interface SingleStoreDriverOptions {
|
|
@@ -29,9 +29,7 @@ export type SingleStoreDriverDrizzleConfig<TSchema extends Record<string, unknow
|
|
|
29
29
|
schema?: undefined;
|
|
30
30
|
});
|
|
31
31
|
export type AnySingleStoreDriverConnection = Pool | Connection | CallbackPool | CallbackConnection;
|
|
32
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends AnySingleStoreDriverConnection = CallbackPool>(...params:
|
|
33
|
-
ImportTypeError<'singlestore'>
|
|
34
|
-
], [
|
|
32
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends AnySingleStoreDriverConnection = CallbackPool>(...params: [
|
|
35
33
|
TClient | string
|
|
36
34
|
] | [
|
|
37
35
|
TClient | string,
|
|
@@ -42,7 +40,7 @@ export declare function drizzle<TSchema extends Record<string, unknown> = Record
|
|
|
42
40
|
} | {
|
|
43
41
|
client: TClient;
|
|
44
42
|
}))
|
|
45
|
-
]
|
|
43
|
+
]): SingleStoreDriverDatabase<TSchema> & {
|
|
46
44
|
$client: TClient;
|
|
47
45
|
};
|
|
48
46
|
export declare namespace drizzle {
|
package/singlestore/driver.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { entityKind } from "../entity.js";
|
|
|
5
5
|
import type { Logger } from "../logger.js";
|
|
6
6
|
import { SingleStoreDatabase } from "../singlestore-core/db.js";
|
|
7
7
|
import { SingleStoreDialect } from "../singlestore-core/dialect.js";
|
|
8
|
-
import { type DrizzleConfig
|
|
8
|
+
import { type DrizzleConfig } from "../utils.js";
|
|
9
9
|
import type { SingleStoreDriverClient, SingleStoreDriverPreparedQueryHKT, SingleStoreDriverQueryResultHKT } from "./session.js";
|
|
10
10
|
import { SingleStoreDriverSession } from "./session.js";
|
|
11
11
|
export interface SingleStoreDriverOptions {
|
|
@@ -29,9 +29,7 @@ export type SingleStoreDriverDrizzleConfig<TSchema extends Record<string, unknow
|
|
|
29
29
|
schema?: undefined;
|
|
30
30
|
});
|
|
31
31
|
export type AnySingleStoreDriverConnection = Pool | Connection | CallbackPool | CallbackConnection;
|
|
32
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends AnySingleStoreDriverConnection = CallbackPool>(...params:
|
|
33
|
-
ImportTypeError<'singlestore'>
|
|
34
|
-
], [
|
|
32
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends AnySingleStoreDriverConnection = CallbackPool>(...params: [
|
|
35
33
|
TClient | string
|
|
36
34
|
] | [
|
|
37
35
|
TClient | string,
|
|
@@ -42,7 +40,7 @@ export declare function drizzle<TSchema extends Record<string, unknown> = Record
|
|
|
42
40
|
} | {
|
|
43
41
|
client: TClient;
|
|
44
42
|
}))
|
|
45
|
-
]
|
|
43
|
+
]): SingleStoreDriverDatabase<TSchema> & {
|
|
46
44
|
$client: TClient;
|
|
47
45
|
};
|
|
48
46
|
export declare namespace drizzle {
|
package/singlestore/driver.js
CHANGED
|
@@ -8,6 +8,7 @@ import { DefaultLogger } from "../logger.js";
|
|
|
8
8
|
import { SingleStoreDatabase } from "../singlestore-core/db.js";
|
|
9
9
|
import { SingleStoreDialect } from "../singlestore-core/dialect.js";
|
|
10
10
|
import { isConfig } from "../utils.js";
|
|
11
|
+
import { npmVersion } from "../version.js";
|
|
11
12
|
import { SingleStoreDriverSession } from "./session.js";
|
|
12
13
|
class SingleStoreDriverDriver {
|
|
13
14
|
constructor(client, dialect, options = {}) {
|
|
@@ -54,11 +55,16 @@ function construct(client, config = {}) {
|
|
|
54
55
|
function isCallbackClient(client) {
|
|
55
56
|
return typeof client.promise === "function";
|
|
56
57
|
}
|
|
58
|
+
const CONNECTION_ATTRS = {
|
|
59
|
+
_connector_name: "SingleStore Drizzle ORM Driver",
|
|
60
|
+
_connector_version: npmVersion
|
|
61
|
+
};
|
|
57
62
|
function drizzle(...params) {
|
|
58
63
|
if (typeof params[0] === "string") {
|
|
59
64
|
const connectionString = params[0];
|
|
60
65
|
const instance = createPool({
|
|
61
|
-
uri: connectionString
|
|
66
|
+
uri: connectionString,
|
|
67
|
+
connectAttributes: CONNECTION_ATTRS
|
|
62
68
|
});
|
|
63
69
|
return construct(instance, params[1]);
|
|
64
70
|
}
|
|
@@ -66,7 +72,23 @@ function drizzle(...params) {
|
|
|
66
72
|
const { connection, client, ...drizzleConfig } = params[0];
|
|
67
73
|
if (client)
|
|
68
74
|
return construct(client, drizzleConfig);
|
|
69
|
-
|
|
75
|
+
let opts = {};
|
|
76
|
+
if (typeof connection === "string") {
|
|
77
|
+
opts = {
|
|
78
|
+
uri: connection,
|
|
79
|
+
supportBigNumbers: true,
|
|
80
|
+
connectAttributes: CONNECTION_ATTRS
|
|
81
|
+
};
|
|
82
|
+
} else {
|
|
83
|
+
opts = {
|
|
84
|
+
...connection,
|
|
85
|
+
connectAttributes: {
|
|
86
|
+
...connection.connectAttributes,
|
|
87
|
+
...CONNECTION_ATTRS
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const instance = createPool(opts);
|
|
70
92
|
const db = construct(instance, drizzleConfig);
|
|
71
93
|
return db;
|
|
72
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/singlestore/driver.ts"],"sourcesContent":["import { type Connection as CallbackConnection, createPool, type Pool as CallbackPool, type PoolOptions } from 'mysql2';\nimport type { Connection, Pool } from 'mysql2/promise';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { SingleStoreDatabase } from '~/singlestore-core/db.ts';\nimport { SingleStoreDialect } from '~/singlestore-core/dialect.ts';\nimport { type DrizzleConfig,
|
|
1
|
+
{"version":3,"sources":["../../src/singlestore/driver.ts"],"sourcesContent":["import { type Connection as CallbackConnection, createPool, type Pool as CallbackPool, type PoolOptions } from 'mysql2';\nimport type { Connection, Pool } from 'mysql2/promise';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { SingleStoreDatabase } from '~/singlestore-core/db.ts';\nimport { SingleStoreDialect } from '~/singlestore-core/dialect.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport { npmVersion } from '~/version.ts';\nimport type {\n\tSingleStoreDriverClient,\n\tSingleStoreDriverPreparedQueryHKT,\n\tSingleStoreDriverQueryResultHKT,\n} from './session.ts';\nimport { SingleStoreDriverSession } from './session.ts';\n\nexport interface SingleStoreDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class SingleStoreDriverDriver {\n\tstatic readonly [entityKind]: string = 'SingleStoreDriverDriver';\n\n\tconstructor(\n\t\tprivate client: SingleStoreDriverClient,\n\t\tprivate dialect: SingleStoreDialect,\n\t\tprivate options: SingleStoreDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): SingleStoreDriverSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new SingleStoreDriverSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport { SingleStoreDatabase } from '~/singlestore-core/db.ts';\n\nexport class SingleStoreDriverDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends SingleStoreDatabase<SingleStoreDriverQueryResultHKT, SingleStoreDriverPreparedQueryHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SingleStoreDriverDatabase';\n}\n\nexport type SingleStoreDriverDrizzleConfig<TSchema extends Record<string, unknown> = Record<string, never>> =\n\t& Omit<DrizzleConfig<TSchema>, 'schema'>\n\t& ({ schema: TSchema } | { schema?: undefined });\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends Pool | Connection | CallbackPool | CallbackConnection = CallbackPool,\n>(\n\tclient: TClient,\n\tconfig: SingleStoreDriverDrizzleConfig<TSchema> = {},\n): SingleStoreDriverDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tconst dialect = new SingleStoreDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tconst clientForInstance = isCallbackClient(client) ? client.promise() : client;\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst driver = new SingleStoreDriverDriver(clientForInstance as SingleStoreDriverClient, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new SingleStoreDriverDatabase(dialect, session, schema as any) as SingleStoreDriverDatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\ninterface CallbackClient {\n\tpromise(): SingleStoreDriverClient;\n}\n\nfunction isCallbackClient(client: any): client is CallbackClient {\n\treturn typeof client.promise === 'function';\n}\n\nexport type AnySingleStoreDriverConnection = Pool | Connection | CallbackPool | CallbackConnection;\n\nconst CONNECTION_ATTRS: PoolOptions['connectAttributes'] = {\n\t_connector_name: 'SingleStore Drizzle ORM Driver',\n\t_connector_version: npmVersion,\n};\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends AnySingleStoreDriverConnection = CallbackPool,\n>(\n\t...params: [\n\t\tTClient | string,\n\t] | [\n\t\tTClient | string,\n\t\tSingleStoreDriverDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& SingleStoreDriverDrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tconnection: string | PoolOptions;\n\t\t\t} | {\n\t\t\t\tclient: TClient;\n\t\t\t})\n\t\t),\n\t]\n): SingleStoreDriverDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (typeof params[0] === 'string') {\n\t\tconst connectionString = params[0]!;\n\t\tconst instance = createPool({\n\t\t\turi: connectionString,\n\t\t\tconnectAttributes: CONNECTION_ATTRS,\n\t\t});\n\n\t\treturn construct(instance, params[1]) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as\n\t\t\t& { connection?: PoolOptions | string; client?: TClient }\n\t\t\t& SingleStoreDriverDrizzleConfig<TSchema>;\n\n\t\tif (client) return construct(client, drizzleConfig) as any;\n\n\t\tlet opts: PoolOptions = {};\n\t\tif (typeof connection === 'string') {\n\t\t\topts = {\n\t\t\t\turi: connection,\n\t\t\t\tsupportBigNumbers: true,\n\t\t\t\tconnectAttributes: CONNECTION_ATTRS,\n\t\t\t};\n\t\t} else {\n\t\t\topts = {\n\t\t\t\t...connection,\n\t\t\t\tconnectAttributes: {\n\t\t\t\t\t...connection!.connectAttributes,\n\t\t\t\t\t...CONNECTION_ATTRS,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst instance = createPool(opts);\n\t\tconst db = construct(instance, drizzleConfig);\n\n\t\treturn db as any;\n\t}\n\n\treturn construct(params[0] as TClient, params[1] as SingleStoreDriverDrizzleConfig<TSchema> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<TSchema extends Record<string, unknown> = Record<string, never>>(\n\t\tconfig?: SingleStoreDriverDrizzleConfig<TSchema>,\n\t): SingleStoreDriverDatabase<TSchema> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":"AAAA,SAAgD,kBAA+D;AAE/G;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAA6B,gBAAgB;AAC7C,SAAS,kBAAkB;AAM3B,SAAS,gCAAgC;AAMlC,MAAM,wBAAwB;AAAA,EAGpC,YACS,QACA,SACA,UAAoC,CAAC,GAC5C;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,UAAU,IAAY;AAAA,EASvC,cACC,QAC4E;AAC5E,WAAO,IAAI,yBAAyB,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,EACvG;AACD;AAEA,SAAS,uBAAAA,4BAA2B;AAE7B,MAAM,kCAEH,oBAAiG;AAAA,EAC1G,QAA0B,UAAU,IAAY;AACjD;AAMA,SAAS,UAIR,QACA,SAAkD,CAAC,GAGlD;AACD,QAAM,UAAU,IAAI,mBAAmB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAChE,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,QAAM,oBAAoB,iBAAiB,MAAM,IAAI,OAAO,QAAQ,IAAI;AAExE,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,SAAS,IAAI,wBAAwB,mBAA8C,SAAS,EAAE,OAAO,CAAC;AAC5G,QAAM,UAAU,OAAO,cAAc,MAAM;AAC3C,QAAM,KAAK,IAAI,0BAA0B,SAAS,SAAS,MAAa;AACxE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAMA,SAAS,iBAAiB,QAAuC;AAChE,SAAO,OAAO,OAAO,YAAY;AAClC;AAIA,MAAM,mBAAqD;AAAA,EAC1D,iBAAiB;AAAA,EACjB,oBAAoB;AACrB;AAEO,SAAS,WAIZ,QAiBF;AACD,MAAI,OAAO,OAAO,CAAC,MAAM,UAAU;AAClC,UAAM,mBAAmB,OAAO,CAAC;AACjC,UAAM,WAAW,WAAW;AAAA,MAC3B,KAAK;AAAA,MACL,mBAAmB;AAAA,IACpB,CAAC;AAED,WAAO,UAAU,UAAU,OAAO,CAAC,CAAC;AAAA,EACrC;AAEA,MAAI,SAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,YAAY,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAIzD,QAAI;AAAQ,aAAO,UAAU,QAAQ,aAAa;AAElD,QAAI,OAAoB,CAAC;AACzB,QAAI,OAAO,eAAe,UAAU;AACnC,aAAO;AAAA,QACN,KAAK;AAAA,QACL,mBAAmB;AAAA,QACnB,mBAAmB;AAAA,MACpB;AAAA,IACD,OAAO;AACN,aAAO;AAAA,QACN,GAAG;AAAA,QACH,mBAAmB;AAAA,UAClB,GAAG,WAAY;AAAA,UACf,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAEA,UAAM,WAAW,WAAW,IAAI;AAChC,UAAM,KAAK,UAAU,UAAU,aAAa;AAE5C,WAAO;AAAA,EACR;AAEA,SAAO,UAAU,OAAO,CAAC,GAAc,OAAO,CAAC,CAAwD;AACxG;AAAA,CAEO,CAAUC,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["SingleStoreDatabase","drizzle"]}
|
|
@@ -235,13 +235,14 @@ class SingleStoreDialect {
|
|
|
235
235
|
}
|
|
236
236
|
const table2 = joinMeta.table;
|
|
237
237
|
const lateralSql = joinMeta.lateral ? import_sql.sql` lateral` : void 0;
|
|
238
|
+
const onSql = joinMeta.on ? import_sql.sql` on ${joinMeta.on}` : void 0;
|
|
238
239
|
if ((0, import_entity.is)(table2, import_table2.SingleStoreTable)) {
|
|
239
240
|
const tableName = table2[import_table2.SingleStoreTable.Symbol.Name];
|
|
240
241
|
const tableSchema = table2[import_table2.SingleStoreTable.Symbol.Schema];
|
|
241
242
|
const origTableName = table2[import_table2.SingleStoreTable.Symbol.OriginalName];
|
|
242
243
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
243
244
|
joinsArray.push(
|
|
244
|
-
import_sql.sql`${import_sql.sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? import_sql.sql`${import_sql.sql.identifier(tableSchema)}.` : void 0}${import_sql.sql.identifier(origTableName)}${alias && import_sql.sql` ${import_sql.sql.identifier(alias)}`}
|
|
245
|
+
import_sql.sql`${import_sql.sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? import_sql.sql`${import_sql.sql.identifier(tableSchema)}.` : void 0}${import_sql.sql.identifier(origTableName)}${alias && import_sql.sql` ${import_sql.sql.identifier(alias)}`}${onSql}`
|
|
245
246
|
);
|
|
246
247
|
} else if ((0, import_entity.is)(table2, import_sql.View)) {
|
|
247
248
|
const viewName = table2[import_view_common.ViewBaseConfig].name;
|
|
@@ -249,11 +250,11 @@ class SingleStoreDialect {
|
|
|
249
250
|
const origViewName = table2[import_view_common.ViewBaseConfig].originalName;
|
|
250
251
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
|
251
252
|
joinsArray.push(
|
|
252
|
-
import_sql.sql`${import_sql.sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? import_sql.sql`${import_sql.sql.identifier(viewSchema)}.` : void 0}${import_sql.sql.identifier(origViewName)}${alias && import_sql.sql` ${import_sql.sql.identifier(alias)}`}
|
|
253
|
+
import_sql.sql`${import_sql.sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? import_sql.sql`${import_sql.sql.identifier(viewSchema)}.` : void 0}${import_sql.sql.identifier(origViewName)}${alias && import_sql.sql` ${import_sql.sql.identifier(alias)}`}${onSql}`
|
|
253
254
|
);
|
|
254
255
|
} else {
|
|
255
256
|
joinsArray.push(
|
|
256
|
-
import_sql.sql`${import_sql.sql.raw(joinMeta.joinType)} join${lateralSql} ${table2}
|
|
257
|
+
import_sql.sql`${import_sql.sql.raw(joinMeta.joinType)} join${lateralSql} ${table2}${onSql}`
|
|
257
258
|
);
|
|
258
259
|
}
|
|
259
260
|
if (index < joins.length - 1) {
|
|
@@ -273,7 +274,7 @@ class SingleStoreDialect {
|
|
|
273
274
|
const { config, strength } = lockingClause;
|
|
274
275
|
lockingClausesSql = import_sql.sql` for ${import_sql.sql.raw(strength)}`;
|
|
275
276
|
if (config.noWait) {
|
|
276
|
-
lockingClausesSql.append(import_sql.sql`
|
|
277
|
+
lockingClausesSql.append(import_sql.sql` nowait`);
|
|
277
278
|
} else if (config.skipLocked) {
|
|
278
279
|
lockingClausesSql.append(import_sql.sql` skip locked`);
|
|
279
280
|
}
|