drizzle-orm 0.45.1 → 0.45.2
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/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.js.map +1 -1
- package/mysql-core/dialect.cjs +169 -71
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +3 -3
- package/mysql-core/dialect.d.ts +3 -3
- package/mysql-core/dialect.js +169 -71
- package/mysql-core/dialect.js.map +1 -1
- package/package.json +133 -133
- package/pg-core/dialect.cjs +1 -1
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.js +1 -1
- package/pg-core/dialect.js.map +1 -1
- package/singlestore-core/dialect.cjs +103 -42
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +3 -3
- package/singlestore-core/dialect.d.ts +3 -3
- package/singlestore-core/dialect.js +103 -42
- package/singlestore-core/dialect.js.map +1 -1
- package/sqlite-core/dialect.cjs +97 -35
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +3 -3
- package/sqlite-core/dialect.d.ts +3 -3
- package/sqlite-core/dialect.js +97 -35
- package/sqlite-core/dialect.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -63,14 +63,16 @@ class SingleStoreDialect {
|
|
|
63
63
|
await tx.execute(import_sql.sql.raw(stmt));
|
|
64
64
|
}
|
|
65
65
|
await tx.execute(
|
|
66
|
-
import_sql.sql`insert into ${import_sql.sql.identifier(
|
|
66
|
+
import_sql.sql`insert into ${import_sql.sql.identifier(
|
|
67
|
+
migrationsTable
|
|
68
|
+
)} (\`hash\`, \`created_at\`) values(${migration.hash}, ${migration.folderMillis})`
|
|
67
69
|
);
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
74
|
escapeName(name) {
|
|
73
|
-
return `\`${name}\``;
|
|
75
|
+
return `\`${name.replace(/`/g, "``")}\``;
|
|
74
76
|
}
|
|
75
77
|
escapeParam(_num) {
|
|
76
78
|
return `?`;
|
|
@@ -90,7 +92,14 @@ class SingleStoreDialect {
|
|
|
90
92
|
withSqlChunks.push(import_sql.sql` `);
|
|
91
93
|
return import_sql.sql.join(withSqlChunks);
|
|
92
94
|
}
|
|
93
|
-
buildDeleteQuery({
|
|
95
|
+
buildDeleteQuery({
|
|
96
|
+
table,
|
|
97
|
+
where,
|
|
98
|
+
returning,
|
|
99
|
+
withList,
|
|
100
|
+
limit,
|
|
101
|
+
orderBy
|
|
102
|
+
}) {
|
|
94
103
|
const withSql = this.buildWithCTE(withList);
|
|
95
104
|
const returningSql = returning ? import_sql.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
96
105
|
const whereSql = where ? import_sql.sql` where ${where}` : void 0;
|
|
@@ -104,18 +113,28 @@ class SingleStoreDialect {
|
|
|
104
113
|
(colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0
|
|
105
114
|
);
|
|
106
115
|
const setSize = columnNames.length;
|
|
107
|
-
return import_sql.sql.join(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
return import_sql.sql.join(
|
|
117
|
+
columnNames.flatMap((colName, i) => {
|
|
118
|
+
const col = tableColumns[colName];
|
|
119
|
+
const onUpdateFnResult = col.onUpdateFn?.();
|
|
120
|
+
const value = set[colName] ?? ((0, import_entity.is)(onUpdateFnResult, import_sql.SQL) ? onUpdateFnResult : import_sql.sql.param(onUpdateFnResult, col));
|
|
121
|
+
const res = import_sql.sql`${import_sql.sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
|
|
122
|
+
if (i < setSize - 1) {
|
|
123
|
+
return [res, import_sql.sql.raw(", ")];
|
|
124
|
+
}
|
|
125
|
+
return [res];
|
|
126
|
+
})
|
|
127
|
+
);
|
|
117
128
|
}
|
|
118
|
-
buildUpdateQuery({
|
|
129
|
+
buildUpdateQuery({
|
|
130
|
+
table,
|
|
131
|
+
set,
|
|
132
|
+
where,
|
|
133
|
+
returning,
|
|
134
|
+
withList,
|
|
135
|
+
limit,
|
|
136
|
+
orderBy
|
|
137
|
+
}) {
|
|
119
138
|
const withSql = this.buildWithCTE(withList);
|
|
120
139
|
const setSql = this.buildUpdateSet(table, set);
|
|
121
140
|
const returningSql = returning ? import_sql.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
@@ -213,7 +232,9 @@ class SingleStoreDialect {
|
|
|
213
232
|
))(f.field.table)) {
|
|
214
233
|
const tableName = (0, import_table.getTableName)(f.field.table);
|
|
215
234
|
throw new Error(
|
|
216
|
-
`Your "${f.path.join(
|
|
235
|
+
`Your "${f.path.join(
|
|
236
|
+
"->"
|
|
237
|
+
)}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`
|
|
217
238
|
);
|
|
218
239
|
}
|
|
219
240
|
}
|
|
@@ -223,7 +244,9 @@ class SingleStoreDialect {
|
|
|
223
244
|
const selection = this.buildSelection(fieldsList, { isSingleTable });
|
|
224
245
|
const tableSql = (() => {
|
|
225
246
|
if ((0, import_entity.is)(table, import_table.Table) && table[import_table.Table.Symbol.IsAlias]) {
|
|
226
|
-
return import_sql.sql`${import_sql.sql`${import_sql.sql.identifier(table[import_table.Table.Symbol.Schema] ?? "")}.`.if(table[import_table.Table.Symbol.Schema])}${import_sql.sql.identifier(
|
|
247
|
+
return import_sql.sql`${import_sql.sql`${import_sql.sql.identifier(table[import_table.Table.Symbol.Schema] ?? "")}.`.if(table[import_table.Table.Symbol.Schema])}${import_sql.sql.identifier(
|
|
248
|
+
table[import_table.Table.Symbol.OriginalName]
|
|
249
|
+
)} ${import_sql.sql.identifier(table[import_table.Table.Symbol.Name])}`;
|
|
227
250
|
}
|
|
228
251
|
return table;
|
|
229
252
|
})();
|
|
@@ -309,12 +332,16 @@ class SingleStoreDialect {
|
|
|
309
332
|
const orderByValues = [];
|
|
310
333
|
for (const orderByUnit of orderBy) {
|
|
311
334
|
if ((0, import_entity.is)(orderByUnit, import_common.SingleStoreColumn)) {
|
|
312
|
-
orderByValues.push(
|
|
335
|
+
orderByValues.push(
|
|
336
|
+
import_sql.sql.identifier(this.casing.getColumnCasing(orderByUnit))
|
|
337
|
+
);
|
|
313
338
|
} else if ((0, import_entity.is)(orderByUnit, import_sql.SQL)) {
|
|
314
339
|
for (let i = 0; i < orderByUnit.queryChunks.length; i++) {
|
|
315
340
|
const chunk = orderByUnit.queryChunks[i];
|
|
316
341
|
if ((0, import_entity.is)(chunk, import_common.SingleStoreColumn)) {
|
|
317
|
-
orderByUnit.queryChunks[i] = import_sql.sql.identifier(
|
|
342
|
+
orderByUnit.queryChunks[i] = import_sql.sql.identifier(
|
|
343
|
+
this.casing.getColumnCasing(chunk)
|
|
344
|
+
);
|
|
318
345
|
}
|
|
319
346
|
}
|
|
320
347
|
orderByValues.push(import_sql.sql`${orderByUnit}`);
|
|
@@ -329,12 +356,17 @@ class SingleStoreDialect {
|
|
|
329
356
|
const offsetSql = offset ? import_sql.sql` offset ${offset}` : void 0;
|
|
330
357
|
return import_sql.sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
|
|
331
358
|
}
|
|
332
|
-
buildInsertQuery({
|
|
359
|
+
buildInsertQuery({
|
|
360
|
+
table,
|
|
361
|
+
values,
|
|
362
|
+
ignore,
|
|
363
|
+
onConflict
|
|
364
|
+
}) {
|
|
333
365
|
const valuesSqlList = [];
|
|
334
366
|
const columns = table[import_table.Table.Symbol.Columns];
|
|
335
|
-
const colEntries = Object.entries(
|
|
336
|
-
|
|
337
|
-
);
|
|
367
|
+
const colEntries = Object.entries(
|
|
368
|
+
columns
|
|
369
|
+
).filter(([_, col]) => !col.shouldDisableInsert());
|
|
338
370
|
const insertOrder = colEntries.map(([, column]) => import_sql.sql.identifier(this.casing.getColumnCasing(column)));
|
|
339
371
|
const generatedIdsResponse = [];
|
|
340
372
|
for (const [valueIndex, value] of values.entries()) {
|
|
@@ -411,7 +443,10 @@ class SingleStoreDialect {
|
|
|
411
443
|
}));
|
|
412
444
|
} else {
|
|
413
445
|
const aliasedColumns = Object.fromEntries(
|
|
414
|
-
Object.entries(tableConfig.columns).map(([key, value]) => [
|
|
446
|
+
Object.entries(tableConfig.columns).map(([key, value]) => [
|
|
447
|
+
key,
|
|
448
|
+
(0, import_alias.aliasedTableColumn)(value, tableAlias)
|
|
449
|
+
])
|
|
415
450
|
);
|
|
416
451
|
if (config.where) {
|
|
417
452
|
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0, import_relations.getOperators)()) : config.where;
|
|
@@ -433,7 +468,9 @@ class SingleStoreDialect {
|
|
|
433
468
|
}
|
|
434
469
|
}
|
|
435
470
|
if (selectedColumns.length > 0) {
|
|
436
|
-
selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter(
|
|
471
|
+
selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter(
|
|
472
|
+
(key) => !selectedColumns.includes(key)
|
|
473
|
+
);
|
|
437
474
|
}
|
|
438
475
|
} else {
|
|
439
476
|
selectedColumns = Object.keys(tableConfig.columns);
|
|
@@ -444,7 +481,13 @@ class SingleStoreDialect {
|
|
|
444
481
|
}
|
|
445
482
|
let selectedRelations = [];
|
|
446
483
|
if (config.with) {
|
|
447
|
-
selectedRelations = Object.entries(config.with).filter(
|
|
484
|
+
selectedRelations = Object.entries(config.with).filter(
|
|
485
|
+
(entry) => !!entry[1]
|
|
486
|
+
).map(([tsKey, queryConfig]) => ({
|
|
487
|
+
tsKey,
|
|
488
|
+
queryConfig,
|
|
489
|
+
relation: tableConfig.relations[tsKey]
|
|
490
|
+
}));
|
|
448
491
|
}
|
|
449
492
|
let extras;
|
|
450
493
|
if (config.extras) {
|
|
@@ -472,7 +515,10 @@ class SingleStoreDialect {
|
|
|
472
515
|
}
|
|
473
516
|
orderBy = orderByOrig.map((orderByValue) => {
|
|
474
517
|
if ((0, import_entity.is)(orderByValue, import_column.Column)) {
|
|
475
|
-
return (0, import_alias.aliasedTableColumn)(
|
|
518
|
+
return (0, import_alias.aliasedTableColumn)(
|
|
519
|
+
orderByValue,
|
|
520
|
+
tableAlias
|
|
521
|
+
);
|
|
476
522
|
}
|
|
477
523
|
return (0, import_alias.mapColumnsInSQLToAlias)(orderByValue, tableAlias);
|
|
478
524
|
});
|
|
@@ -483,14 +529,21 @@ class SingleStoreDialect {
|
|
|
483
529
|
queryConfig: selectedRelationConfigValue,
|
|
484
530
|
relation
|
|
485
531
|
} of selectedRelations) {
|
|
486
|
-
const normalizedRelation = (0, import_relations.normalizeRelation)(
|
|
532
|
+
const normalizedRelation = (0, import_relations.normalizeRelation)(
|
|
533
|
+
schema,
|
|
534
|
+
tableNamesMap,
|
|
535
|
+
relation
|
|
536
|
+
);
|
|
487
537
|
const relationTableName = (0, import_table.getTableUniqueName)(relation.referencedTable);
|
|
488
538
|
const relationTableTsName = tableNamesMap[relationTableName];
|
|
489
539
|
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
490
540
|
const joinOn2 = (0, import_expressions.and)(
|
|
491
541
|
...normalizedRelation.fields.map(
|
|
492
542
|
(field2, i) => (0, import_expressions.eq)(
|
|
493
|
-
(0, import_alias.aliasedTableColumn)(
|
|
543
|
+
(0, import_alias.aliasedTableColumn)(
|
|
544
|
+
normalizedRelation.references[i],
|
|
545
|
+
relationTableAlias
|
|
546
|
+
),
|
|
494
547
|
(0, import_alias.aliasedTableColumn)(field2, tableAlias)
|
|
495
548
|
)
|
|
496
549
|
)
|
|
@@ -506,7 +559,9 @@ class SingleStoreDialect {
|
|
|
506
559
|
joinOn: joinOn2,
|
|
507
560
|
nestedQueryRelation: relation
|
|
508
561
|
});
|
|
509
|
-
const field = import_sql.sql`${import_sql.sql.identifier(relationTableAlias)}.${import_sql.sql.identifier("data")}`.as(
|
|
562
|
+
const field = import_sql.sql`${import_sql.sql.identifier(relationTableAlias)}.${import_sql.sql.identifier("data")}`.as(
|
|
563
|
+
selectedRelationTsKey
|
|
564
|
+
);
|
|
510
565
|
joins.push({
|
|
511
566
|
on: import_sql.sql`true`,
|
|
512
567
|
table: new import_subquery.Subquery(builtRelation.sql, {}, relationTableAlias),
|
|
@@ -525,7 +580,9 @@ class SingleStoreDialect {
|
|
|
525
580
|
}
|
|
526
581
|
}
|
|
527
582
|
if (selection.length === 0) {
|
|
528
|
-
throw new import_errors.DrizzleError({
|
|
583
|
+
throw new import_errors.DrizzleError({
|
|
584
|
+
message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")`
|
|
585
|
+
});
|
|
529
586
|
}
|
|
530
587
|
let result;
|
|
531
588
|
where = (0, import_expressions.and)(joinOn, where);
|
|
@@ -539,14 +596,16 @@ class SingleStoreDialect {
|
|
|
539
596
|
if ((0, import_entity.is)(nestedQueryRelation, import_relations.Many)) {
|
|
540
597
|
field = import_sql.sql`json_agg(${field})`;
|
|
541
598
|
}
|
|
542
|
-
const nestedSelection = [
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
599
|
+
const nestedSelection = [
|
|
600
|
+
{
|
|
601
|
+
dbKey: "data",
|
|
602
|
+
tsKey: "data",
|
|
603
|
+
field: field.as("data"),
|
|
604
|
+
isJson: true,
|
|
605
|
+
relationTableTsKey: tableConfig.tsName,
|
|
606
|
+
selection
|
|
607
|
+
}
|
|
608
|
+
];
|
|
550
609
|
const needsSubquery = limit !== void 0 || offset !== void 0 || (orderBy?.length ?? 0) > 0;
|
|
551
610
|
if (needsSubquery) {
|
|
552
611
|
result = this.buildSelectQuery({
|
|
@@ -557,10 +616,12 @@ class SingleStoreDialect {
|
|
|
557
616
|
path: [],
|
|
558
617
|
field: import_sql.sql.raw("*")
|
|
559
618
|
},
|
|
560
|
-
...((orderBy?.length ?? 0) > 0 ? [
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
619
|
+
...((orderBy?.length ?? 0) > 0 ? [
|
|
620
|
+
{
|
|
621
|
+
path: [],
|
|
622
|
+
field: import_sql.sql`row_number() over (order by ${import_sql.sql.join(orderBy, import_sql.sql`, `)})`
|
|
623
|
+
}
|
|
624
|
+
] : [])
|
|
564
625
|
],
|
|
565
626
|
where,
|
|
566
627
|
limit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/singlestore-core/dialect.ts"],"sourcesContent":["import { aliasedTable, aliasedTableColumn, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias } from '~/alias.ts';\nimport { CasingCache } from '~/casing.ts';\nimport { Column } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { DrizzleError } from '~/errors.ts';\nimport type { MigrationConfig, MigrationMeta } from '~/migrator.ts';\nimport {\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tgetOperators,\n\tgetOrderByOperators,\n\tMany,\n\tnormalizeRelation,\n\tOne,\n\ttype Relation,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { and, eq } from '~/sql/expressions/index.ts';\nimport type { Name, Placeholder, QueryWithTypings, SQLChunk } from '~/sql/sql.ts';\nimport { Param, SQL, sql, View } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { getTableName, getTableUniqueName, Table } from '~/table.ts';\nimport { type Casing, orderSelectedFields, type UpdateSet } from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport { SingleStoreColumn } from './columns/common.ts';\nimport type { SingleStoreDeleteConfig } from './query-builders/delete.ts';\nimport type { SingleStoreInsertConfig } from './query-builders/insert.ts';\nimport type {\n\tSelectedFieldsOrdered,\n\tSingleStoreSelectConfig,\n\tSingleStoreSelectJoinConfig,\n} from './query-builders/select.types.ts';\nimport type { SingleStoreUpdateConfig } from './query-builders/update.ts';\nimport type { SingleStoreSession } from './session.ts';\nimport { SingleStoreTable } from './table.ts';\n/* import { SingleStoreViewBase } from './view-base.ts'; */\n\nexport interface SingleStoreDialectConfig {\n\tcasing?: Casing;\n}\n\nexport class SingleStoreDialect {\n\tstatic readonly [entityKind]: string = 'SingleStoreDialect';\n\n\t/** @internal */\n\treadonly casing: CasingCache;\n\n\tconstructor(config?: SingleStoreDialectConfig) {\n\t\tthis.casing = new CasingCache(config?.casing);\n\t}\n\n\tasync migrate(\n\t\tmigrations: MigrationMeta[],\n\t\tsession: SingleStoreSession,\n\t\tconfig: Omit<MigrationConfig, 'migrationsSchema'>,\n\t): Promise<void> {\n\t\tconst migrationsTable = config.migrationsTable ?? '__drizzle_migrations';\n\t\tconst migrationTableCreate = sql`\n\t\t\tcreate table if not exists ${sql.identifier(migrationsTable)} (\n\t\t\t\tid serial primary key,\n\t\t\t\thash text not null,\n\t\t\t\tcreated_at bigint\n\t\t\t)\n\t\t`;\n\t\tawait session.execute(migrationTableCreate);\n\n\t\tconst dbMigrations = await session.all<{ id: number; hash: string; created_at: string }>(\n\t\t\tsql`select id, hash, created_at from ${sql.identifier(migrationsTable)} order by created_at desc limit 1`,\n\t\t);\n\n\t\tconst lastDbMigration = dbMigrations[0];\n\n\t\tawait session.transaction(async (tx) => {\n\t\t\tfor (const migration of migrations) {\n\t\t\t\tif (\n\t\t\t\t\t!lastDbMigration\n\t\t\t\t\t|| Number(lastDbMigration.created_at) < migration.folderMillis\n\t\t\t\t) {\n\t\t\t\t\tfor (const stmt of migration.sql) {\n\t\t\t\t\t\tawait tx.execute(sql.raw(stmt));\n\t\t\t\t\t}\n\t\t\t\t\tawait tx.execute(\n\t\t\t\t\t\tsql`insert into ${\n\t\t\t\t\t\t\tsql.identifier(migrationsTable)\n\t\t\t\t\t\t} (\\`hash\\`, \\`created_at\\`) values(${migration.hash}, ${migration.folderMillis})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tescapeName(name: string): string {\n\t\treturn `\\`${name}\\``;\n\t}\n\n\tescapeParam(_num: number): string {\n\t\treturn `?`;\n\t}\n\n\tescapeString(str: string): string {\n\t\treturn `'${str.replace(/'/g, \"''\")}'`;\n\t}\n\n\tprivate buildWithCTE(queries: Subquery[] | undefined): SQL | undefined {\n\t\tif (!queries?.length) return undefined;\n\n\t\tconst withSqlChunks = [sql`with `];\n\t\tfor (const [i, w] of queries.entries()) {\n\t\t\twithSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);\n\t\t\tif (i < queries.length - 1) {\n\t\t\t\twithSqlChunks.push(sql`, `);\n\t\t\t}\n\t\t}\n\t\twithSqlChunks.push(sql` `);\n\t\treturn sql.join(withSqlChunks);\n\t}\n\n\tbuildDeleteQuery({ table, where, returning, withList, limit, orderBy }: SingleStoreDeleteConfig): SQL {\n\t\tconst withSql = this.buildWithCTE(withList);\n\n\t\tconst returningSql = returning\n\t\t\t? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}`\n\t\t\t: undefined;\n\n\t\tconst whereSql = where ? sql` where ${where}` : undefined;\n\n\t\tconst orderBySql = this.buildOrderBy(orderBy);\n\n\t\tconst limitSql = this.buildLimit(limit);\n\n\t\treturn sql`${withSql}delete from ${table}${whereSql}${orderBySql}${limitSql}${returningSql}`;\n\t}\n\n\tbuildUpdateSet(table: SingleStoreTable, set: UpdateSet): SQL {\n\t\tconst tableColumns = table[Table.Symbol.Columns];\n\n\t\tconst columnNames = Object.keys(tableColumns).filter((colName) =>\n\t\t\tset[colName] !== undefined || tableColumns[colName]?.onUpdateFn !== undefined\n\t\t);\n\n\t\tconst setSize = columnNames.length;\n\t\treturn sql.join(columnNames.flatMap((colName, i) => {\n\t\t\tconst col = tableColumns[colName]!;\n\n\t\t\tconst onUpdateFnResult = col.onUpdateFn?.();\n\t\t\tconst value = set[colName] ?? (is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col));\n\t\t\tconst res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;\n\n\t\t\tif (i < setSize - 1) {\n\t\t\t\treturn [res, sql.raw(', ')];\n\t\t\t}\n\t\t\treturn [res];\n\t\t}));\n\t}\n\n\tbuildUpdateQuery({ table, set, where, returning, withList, limit, orderBy }: SingleStoreUpdateConfig): SQL {\n\t\tconst withSql = this.buildWithCTE(withList);\n\n\t\tconst setSql = this.buildUpdateSet(table, set);\n\n\t\tconst returningSql = returning\n\t\t\t? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}`\n\t\t\t: undefined;\n\n\t\tconst whereSql = where ? sql` where ${where}` : undefined;\n\n\t\tconst orderBySql = this.buildOrderBy(orderBy);\n\n\t\tconst limitSql = this.buildLimit(limit);\n\n\t\treturn sql`${withSql}update ${table} set ${setSql}${whereSql}${orderBySql}${limitSql}${returningSql}`;\n\t}\n\n\t/**\n\t * Builds selection SQL with provided fields/expressions\n\t *\n\t * Examples:\n\t *\n\t * `select <selection> from`\n\t *\n\t * `insert ... returning <selection>`\n\t *\n\t * If `isSingleTable` is true, then columns won't be prefixed with table name\n\t */\n\tprivate buildSelection(\n\t\tfields: SelectedFieldsOrdered,\n\t\t{ isSingleTable = false }: { isSingleTable?: boolean } = {},\n\t): SQL {\n\t\tconst columnsLen = fields.length;\n\n\t\tconst chunks = fields\n\t\t\t.flatMap(({ field }, i) => {\n\t\t\t\tconst chunk: SQLChunk[] = [];\n\n\t\t\t\tif (is(field, SQL.Aliased) && field.isSelectionField) {\n\t\t\t\t\tchunk.push(sql.identifier(field.fieldAlias));\n\t\t\t\t} else if (is(field, SQL.Aliased) || is(field, SQL)) {\n\t\t\t\t\tconst query = is(field, SQL.Aliased) ? field.sql : field;\n\n\t\t\t\t\tif (isSingleTable) {\n\t\t\t\t\t\tchunk.push(\n\t\t\t\t\t\t\tnew SQL(\n\t\t\t\t\t\t\t\tquery.queryChunks.map((c) => {\n\t\t\t\t\t\t\t\t\tif (is(c, SingleStoreColumn)) {\n\t\t\t\t\t\t\t\t\t\treturn sql.identifier(this.casing.getColumnCasing(c));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn c;\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tchunk.push(query);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (is(field, SQL.Aliased)) {\n\t\t\t\t\t\tchunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);\n\t\t\t\t\t}\n\t\t\t\t} else if (is(field, Column)) {\n\t\t\t\t\tif (isSingleTable) {\n\t\t\t\t\t\tchunk.push(sql.identifier(this.casing.getColumnCasing(field)));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tchunk.push(field);\n\t\t\t\t\t}\n\t\t\t\t} else if (is(field, Subquery)) {\n\t\t\t\t\tconst entries = Object.entries(field._.selectedFields) as [string, SQL.Aliased | Column | SQL][];\n\n\t\t\t\t\tif (entries.length === 1) {\n\t\t\t\t\t\tconst entry = entries[0]![1];\n\n\t\t\t\t\t\tconst fieldDecoder = is(entry, SQL)\n\t\t\t\t\t\t\t? entry.decoder\n\t\t\t\t\t\t\t: is(entry, Column)\n\t\t\t\t\t\t\t? { mapFromDriverValue: (v: any) => entry.mapFromDriverValue(v) }\n\t\t\t\t\t\t\t: entry.sql.decoder;\n\n\t\t\t\t\t\tif (fieldDecoder) {\n\t\t\t\t\t\t\tfield._.sql.decoder = fieldDecoder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchunk.push(field);\n\t\t\t\t}\n\n\t\t\t\tif (i < columnsLen - 1) {\n\t\t\t\t\tchunk.push(sql`, `);\n\t\t\t\t}\n\n\t\t\t\treturn chunk;\n\t\t\t});\n\n\t\treturn sql.join(chunks);\n\t}\n\n\tprivate buildLimit(limit: number | Placeholder | undefined): SQL | undefined {\n\t\treturn typeof limit === 'object' || (typeof limit === 'number' && limit >= 0)\n\t\t\t? sql` limit ${limit}`\n\t\t\t: undefined;\n\t}\n\n\tprivate buildOrderBy(orderBy: (SingleStoreColumn | SQL | SQL.Aliased)[] | undefined): SQL | undefined {\n\t\treturn orderBy && orderBy.length > 0 ? sql` order by ${sql.join(orderBy, sql`, `)}` : undefined;\n\t}\n\n\tbuildSelectQuery(\n\t\t{\n\t\t\twithList,\n\t\t\tfields,\n\t\t\tfieldsFlat,\n\t\t\twhere,\n\t\t\thaving,\n\t\t\ttable,\n\t\t\tjoins,\n\t\t\torderBy,\n\t\t\tgroupBy,\n\t\t\tlimit,\n\t\t\toffset,\n\t\t\tlockingClause,\n\t\t\tdistinct,\n\t\t\tsetOperators,\n\t\t}: SingleStoreSelectConfig,\n\t): SQL {\n\t\tconst fieldsList = fieldsFlat ?? orderSelectedFields<SingleStoreColumn>(fields);\n\t\tfor (const f of fieldsList) {\n\t\t\tif (\n\t\t\t\tis(f.field, Column)\n\t\t\t\t&& getTableName(f.field.table)\n\t\t\t\t\t!== (is(table, Subquery)\n\t\t\t\t\t\t? table._.alias\n\t\t\t\t\t\t/* : is(table, SingleStoreViewBase)\n\t\t\t\t\t\t? table[ViewBaseConfig].name */\n\t\t\t\t\t\t: is(table, SQL)\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: getTableName(table))\n\t\t\t\t&& !((table) =>\n\t\t\t\t\tjoins?.some(({ alias }) =>\n\t\t\t\t\t\talias === (table[Table.Symbol.IsAlias] ? getTableName(table) : table[Table.Symbol.BaseName])\n\t\t\t\t\t))(f.field.table)\n\t\t\t) {\n\t\t\t\tconst tableName = getTableName(f.field.table);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Your \"${\n\t\t\t\t\t\tf.path.join('->')\n\t\t\t\t\t}\" field references a column \"${tableName}\".\"${f.field.name}\", but the table \"${tableName}\" is not part of the query! Did you forget to join it?`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst isSingleTable = !joins || joins.length === 0;\n\n\t\tconst withSql = this.buildWithCTE(withList);\n\n\t\tconst distinctSql = distinct ? sql` distinct` : undefined;\n\n\t\tconst selection = this.buildSelection(fieldsList, { isSingleTable });\n\n\t\tconst tableSql = (() => {\n\t\t\tif (is(table, Table) && table[Table.Symbol.IsAlias]) {\n\t\t\t\treturn sql`${sql`${sql.identifier(table[Table.Symbol.Schema] ?? '')}.`.if(table[Table.Symbol.Schema])}${\n\t\t\t\t\tsql.identifier(table[Table.Symbol.OriginalName])\n\t\t\t\t} ${sql.identifier(table[Table.Symbol.Name])}`;\n\t\t\t}\n\n\t\t\treturn table;\n\t\t})();\n\n\t\tconst joinsArray: SQL[] = [];\n\n\t\tif (joins) {\n\t\t\tfor (const [index, joinMeta] of joins.entries()) {\n\t\t\t\tif (index === 0) {\n\t\t\t\t\tjoinsArray.push(sql` `);\n\t\t\t\t}\n\t\t\t\tconst table = joinMeta.table;\n\t\t\t\tconst lateralSql = joinMeta.lateral ? sql` lateral` : undefined;\n\t\t\t\tconst onSql = joinMeta.on ? sql` on ${joinMeta.on}` : undefined;\n\n\t\t\t\tif (is(table, SingleStoreTable)) {\n\t\t\t\t\tconst tableName = table[SingleStoreTable.Symbol.Name];\n\t\t\t\t\tconst tableSchema = table[SingleStoreTable.Symbol.Schema];\n\t\t\t\t\tconst origTableName = table[SingleStoreTable.Symbol.OriginalName];\n\t\t\t\t\tconst alias = tableName === origTableName ? undefined : joinMeta.alias;\n\t\t\t\t\tjoinsArray.push(\n\t\t\t\t\t\tsql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${\n\t\t\t\t\t\t\ttableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined\n\t\t\t\t\t\t}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`,\n\t\t\t\t\t);\n\t\t\t\t} else if (is(table, View)) {\n\t\t\t\t\tconst viewName = table[ViewBaseConfig].name;\n\t\t\t\t\tconst viewSchema = table[ViewBaseConfig].schema;\n\t\t\t\t\tconst origViewName = table[ViewBaseConfig].originalName;\n\t\t\t\t\tconst alias = viewName === origViewName ? undefined : joinMeta.alias;\n\t\t\t\t\tjoinsArray.push(\n\t\t\t\t\t\tsql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${\n\t\t\t\t\t\t\tviewSchema ? sql`${sql.identifier(viewSchema)}.` : undefined\n\t\t\t\t\t\t}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tjoinsArray.push(\n\t\t\t\t\t\tsql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table}${onSql}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (index < joins.length - 1) {\n\t\t\t\t\tjoinsArray.push(sql` `);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst joinsSql = sql.join(joinsArray);\n\n\t\tconst whereSql = where ? sql` where ${where}` : undefined;\n\n\t\tconst havingSql = having ? sql` having ${having}` : undefined;\n\n\t\tconst orderBySql = this.buildOrderBy(orderBy);\n\n\t\tconst groupBySql = groupBy && groupBy.length > 0 ? sql` group by ${sql.join(groupBy, sql`, `)}` : undefined;\n\n\t\tconst limitSql = this.buildLimit(limit);\n\n\t\tconst offsetSql = offset ? sql` offset ${offset}` : undefined;\n\n\t\tlet lockingClausesSql;\n\t\tif (lockingClause) {\n\t\t\tconst { config, strength } = lockingClause;\n\t\t\tlockingClausesSql = sql` for ${sql.raw(strength)}`;\n\t\t\tif (config.noWait) {\n\t\t\t\tlockingClausesSql.append(sql` nowait`);\n\t\t\t} else if (config.skipLocked) {\n\t\t\t\tlockingClausesSql.append(sql` skip locked`);\n\t\t\t}\n\t\t}\n\n\t\tconst finalQuery =\n\t\t\tsql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClausesSql}`;\n\n\t\tif (setOperators.length > 0) {\n\t\t\treturn this.buildSetOperations(finalQuery, setOperators);\n\t\t}\n\n\t\treturn finalQuery;\n\t}\n\n\tbuildSetOperations(leftSelect: SQL, setOperators: SingleStoreSelectConfig['setOperators']): SQL {\n\t\tconst [setOperator, ...rest] = setOperators;\n\n\t\tif (!setOperator) {\n\t\t\tthrow new Error('Cannot pass undefined values to any set operator');\n\t\t}\n\n\t\tif (rest.length === 0) {\n\t\t\treturn this.buildSetOperationQuery({ leftSelect, setOperator });\n\t\t}\n\n\t\t// Some recursive magic here\n\t\treturn this.buildSetOperations(\n\t\t\tthis.buildSetOperationQuery({ leftSelect, setOperator }),\n\t\t\trest,\n\t\t);\n\t}\n\n\tbuildSetOperationQuery({\n\t\tleftSelect,\n\t\tsetOperator: { type, isAll, rightSelect, limit, orderBy, offset },\n\t}: { leftSelect: SQL; setOperator: SingleStoreSelectConfig['setOperators'][number] }): SQL {\n\t\tconst leftChunk = sql`(${leftSelect.getSQL()}) `;\n\t\tconst rightChunk = sql`(${rightSelect.getSQL()})`;\n\n\t\tlet orderBySql;\n\t\tif (orderBy && orderBy.length > 0) {\n\t\t\tconst orderByValues: (SQL<unknown> | Name)[] = [];\n\n\t\t\t// The next bit is necessary because the sql operator replaces ${table.column} with `table`.`column`\n\t\t\t// which is invalid SingleStore syntax, Table from one of the SELECTs cannot be used in global ORDER clause\n\t\t\tfor (const orderByUnit of orderBy) {\n\t\t\t\tif (is(orderByUnit, SingleStoreColumn)) {\n\t\t\t\t\torderByValues.push(sql.identifier(this.casing.getColumnCasing(orderByUnit)));\n\t\t\t\t} else if (is(orderByUnit, SQL)) {\n\t\t\t\t\tfor (let i = 0; i < orderByUnit.queryChunks.length; i++) {\n\t\t\t\t\t\tconst chunk = orderByUnit.queryChunks[i];\n\n\t\t\t\t\t\tif (is(chunk, SingleStoreColumn)) {\n\t\t\t\t\t\t\torderByUnit.queryChunks[i] = sql.identifier(this.casing.getColumnCasing(chunk));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\torderByValues.push(sql`${orderByUnit}`);\n\t\t\t\t} else {\n\t\t\t\t\torderByValues.push(sql`${orderByUnit}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\torderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;\n\t\t}\n\n\t\tconst limitSql = typeof limit === 'object' || (typeof limit === 'number' && limit >= 0)\n\t\t\t? sql` limit ${limit}`\n\t\t\t: undefined;\n\n\t\tconst operatorChunk = sql.raw(`${type} ${isAll ? 'all ' : ''}`);\n\n\t\tconst offsetSql = offset ? sql` offset ${offset}` : undefined;\n\n\t\treturn sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;\n\t}\n\n\tbuildInsertQuery(\n\t\t{ table, values, ignore, onConflict }: SingleStoreInsertConfig,\n\t): { sql: SQL; generatedIds: Record<string, unknown>[] } {\n\t\t// const isSingleValue = values.length === 1;\n\t\tconst valuesSqlList: ((SQLChunk | SQL)[] | SQL)[] = [];\n\t\tconst columns: Record<string, SingleStoreColumn> = table[Table.Symbol.Columns];\n\t\tconst colEntries: [string, SingleStoreColumn][] = Object.entries(columns).filter(([_, col]) =>\n\t\t\t!col.shouldDisableInsert()\n\t\t);\n\n\t\tconst insertOrder = colEntries.map(([, column]) => sql.identifier(this.casing.getColumnCasing(column)));\n\t\tconst generatedIdsResponse: Record<string, unknown>[] = [];\n\n\t\tfor (const [valueIndex, value] of values.entries()) {\n\t\t\tconst generatedIds: Record<string, unknown> = {};\n\n\t\t\tconst valueList: (SQLChunk | SQL)[] = [];\n\t\t\tfor (const [fieldName, col] of colEntries) {\n\t\t\t\tconst colValue = value[fieldName];\n\t\t\t\tif (colValue === undefined || (is(colValue, Param) && colValue.value === undefined)) {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t\t\t\tif (col.defaultFn !== undefined) {\n\t\t\t\t\t\tconst defaultFnResult = col.defaultFn();\n\t\t\t\t\t\tgeneratedIds[fieldName] = defaultFnResult;\n\t\t\t\t\t\tconst defaultValue = is(defaultFnResult, SQL) ? defaultFnResult : sql.param(defaultFnResult, col);\n\t\t\t\t\t\tvalueList.push(defaultValue);\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t\t\t\t} else if (!col.default && col.onUpdateFn !== undefined) {\n\t\t\t\t\t\tconst onUpdateFnResult = col.onUpdateFn();\n\t\t\t\t\t\tconst newValue = is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col);\n\t\t\t\t\t\tvalueList.push(newValue);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueList.push(sql`default`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (col.defaultFn && is(colValue, Param)) {\n\t\t\t\t\t\tgeneratedIds[fieldName] = colValue.value;\n\t\t\t\t\t}\n\t\t\t\t\tvalueList.push(colValue);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgeneratedIdsResponse.push(generatedIds);\n\t\t\tvaluesSqlList.push(valueList);\n\t\t\tif (valueIndex < values.length - 1) {\n\t\t\t\tvaluesSqlList.push(sql`, `);\n\t\t\t}\n\t\t}\n\n\t\tconst valuesSql = sql.join(valuesSqlList);\n\n\t\tconst ignoreSql = ignore ? sql` ignore` : undefined;\n\n\t\tconst onConflictSql = onConflict ? sql` on duplicate key ${onConflict}` : undefined;\n\n\t\treturn {\n\t\t\tsql: sql`insert${ignoreSql} into ${table} ${insertOrder} values ${valuesSql}${onConflictSql}`,\n\t\t\tgeneratedIds: generatedIdsResponse,\n\t\t};\n\t}\n\n\tsqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings {\n\t\treturn sql.toQuery({\n\t\t\tcasing: this.casing,\n\t\t\tescapeName: this.escapeName,\n\t\t\tescapeParam: this.escapeParam,\n\t\t\tescapeString: this.escapeString,\n\t\t\tinvokeSource,\n\t\t});\n\t}\n\n\tbuildRelationalQuery({\n\t\tfullSchema,\n\t\tschema,\n\t\ttableNamesMap,\n\t\ttable,\n\t\ttableConfig,\n\t\tqueryConfig: config,\n\t\ttableAlias,\n\t\tnestedQueryRelation,\n\t\tjoinOn,\n\t}: {\n\t\tfullSchema: Record<string, unknown>;\n\t\tschema: TablesRelationalConfig;\n\t\ttableNamesMap: Record<string, string>;\n\t\ttable: SingleStoreTable;\n\t\ttableConfig: TableRelationalConfig;\n\t\tqueryConfig: true | DBQueryConfig<'many', true>;\n\t\ttableAlias: string;\n\t\tnestedQueryRelation?: Relation;\n\t\tjoinOn?: SQL;\n\t}): BuildRelationalQueryResult<SingleStoreTable, SingleStoreColumn> {\n\t\tlet selection: BuildRelationalQueryResult<SingleStoreTable, SingleStoreColumn>['selection'] = [];\n\t\tlet limit, offset, orderBy: SingleStoreSelectConfig['orderBy'], where;\n\t\tconst joins: SingleStoreSelectJoinConfig[] = [];\n\n\t\tif (config === true) {\n\t\t\tconst selectionEntries = Object.entries(tableConfig.columns);\n\t\t\tselection = selectionEntries.map((\n\t\t\t\t[key, value],\n\t\t\t) => ({\n\t\t\t\tdbKey: value.name,\n\t\t\t\ttsKey: key,\n\t\t\t\tfield: aliasedTableColumn(value as SingleStoreColumn, tableAlias),\n\t\t\t\trelationTableTsKey: undefined,\n\t\t\t\tisJson: false,\n\t\t\t\tselection: [],\n\t\t\t}));\n\t\t} else {\n\t\t\tconst aliasedColumns = Object.fromEntries(\n\t\t\t\tObject.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)]),\n\t\t\t);\n\n\t\t\tif (config.where) {\n\t\t\t\tconst whereSql = typeof config.where === 'function'\n\t\t\t\t\t? config.where(aliasedColumns, getOperators())\n\t\t\t\t\t: config.where;\n\t\t\t\twhere = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);\n\t\t\t}\n\n\t\t\tconst fieldsSelection: { tsKey: string; value: SingleStoreColumn | SQL.Aliased }[] = [];\n\t\t\tlet selectedColumns: string[] = [];\n\n\t\t\t// Figure out which columns to select\n\t\t\tif (config.columns) {\n\t\t\t\tlet isIncludeMode = false;\n\n\t\t\t\tfor (const [field, value] of Object.entries(config.columns)) {\n\t\t\t\t\tif (value === undefined) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (field in tableConfig.columns) {\n\t\t\t\t\t\tif (!isIncludeMode && value === true) {\n\t\t\t\t\t\t\tisIncludeMode = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tselectedColumns.push(field);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (selectedColumns.length > 0) {\n\t\t\t\t\tselectedColumns = isIncludeMode\n\t\t\t\t\t\t? selectedColumns.filter((c) => config.columns?.[c] === true)\n\t\t\t\t\t\t: Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Select all columns if selection is not specified\n\t\t\t\tselectedColumns = Object.keys(tableConfig.columns);\n\t\t\t}\n\n\t\t\tfor (const field of selectedColumns) {\n\t\t\t\tconst column = tableConfig.columns[field]! as SingleStoreColumn;\n\t\t\t\tfieldsSelection.push({ tsKey: field, value: column });\n\t\t\t}\n\n\t\t\tlet selectedRelations: {\n\t\t\t\ttsKey: string;\n\t\t\t\tqueryConfig: true | DBQueryConfig<'many', false>;\n\t\t\t\trelation: Relation;\n\t\t\t}[] = [];\n\n\t\t\t// Figure out which relations to select\n\t\t\tif (config.with) {\n\t\t\t\tselectedRelations = Object.entries(config.with)\n\t\t\t\t\t.filter((entry): entry is [typeof entry[0], NonNullable<typeof entry[1]>] => !!entry[1])\n\t\t\t\t\t.map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey]! }));\n\t\t\t}\n\n\t\t\tlet extras;\n\n\t\t\t// Figure out which extras to select\n\t\t\tif (config.extras) {\n\t\t\t\textras = typeof config.extras === 'function'\n\t\t\t\t\t? config.extras(aliasedColumns, { sql })\n\t\t\t\t\t: config.extras;\n\t\t\t\tfor (const [tsKey, value] of Object.entries(extras)) {\n\t\t\t\t\tfieldsSelection.push({\n\t\t\t\t\t\ttsKey,\n\t\t\t\t\t\tvalue: mapColumnsInAliasedSQLToAlias(value, tableAlias),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Transform `fieldsSelection` into `selection`\n\t\t\t// `fieldsSelection` shouldn't be used after this point\n\t\t\tfor (const { tsKey, value } of fieldsSelection) {\n\t\t\t\tselection.push({\n\t\t\t\t\tdbKey: is(value, SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey]!.name,\n\t\t\t\t\ttsKey,\n\t\t\t\t\tfield: is(value, Column) ? aliasedTableColumn(value, tableAlias) : value,\n\t\t\t\t\trelationTableTsKey: undefined,\n\t\t\t\t\tisJson: false,\n\t\t\t\t\tselection: [],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet orderByOrig = typeof config.orderBy === 'function'\n\t\t\t\t? config.orderBy(aliasedColumns, getOrderByOperators())\n\t\t\t\t: config.orderBy ?? [];\n\t\t\tif (!Array.isArray(orderByOrig)) {\n\t\t\t\torderByOrig = [orderByOrig];\n\t\t\t}\n\t\t\torderBy = orderByOrig.map((orderByValue) => {\n\t\t\t\tif (is(orderByValue, Column)) {\n\t\t\t\t\treturn aliasedTableColumn(orderByValue, tableAlias) as SingleStoreColumn;\n\t\t\t\t}\n\t\t\t\treturn mapColumnsInSQLToAlias(orderByValue, tableAlias);\n\t\t\t});\n\n\t\t\tlimit = config.limit;\n\t\t\toffset = config.offset;\n\n\t\t\t// Process all relations\n\t\t\tfor (\n\t\t\t\tconst {\n\t\t\t\t\ttsKey: selectedRelationTsKey,\n\t\t\t\t\tqueryConfig: selectedRelationConfigValue,\n\t\t\t\t\trelation,\n\t\t\t\t} of selectedRelations\n\t\t\t) {\n\t\t\t\tconst normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);\n\t\t\t\tconst relationTableName = getTableUniqueName(relation.referencedTable);\n\t\t\t\tconst relationTableTsName = tableNamesMap[relationTableName]!;\n\t\t\t\tconst relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;\n\t\t\t\tconst joinOn = and(\n\t\t\t\t\t...normalizedRelation.fields.map((field, i) =>\n\t\t\t\t\t\teq(\n\t\t\t\t\t\t\taliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),\n\t\t\t\t\t\t\taliasedTableColumn(field, tableAlias),\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tconst builtRelation = this.buildRelationalQuery({\n\t\t\t\t\tfullSchema,\n\t\t\t\t\tschema,\n\t\t\t\t\ttableNamesMap,\n\t\t\t\t\ttable: fullSchema[relationTableTsName] as SingleStoreTable,\n\t\t\t\t\ttableConfig: schema[relationTableTsName]!,\n\t\t\t\t\tqueryConfig: is(relation, One)\n\t\t\t\t\t\t? (selectedRelationConfigValue === true\n\t\t\t\t\t\t\t? { limit: 1 }\n\t\t\t\t\t\t\t: { ...selectedRelationConfigValue, limit: 1 })\n\t\t\t\t\t\t: selectedRelationConfigValue,\n\t\t\t\t\ttableAlias: relationTableAlias,\n\t\t\t\t\tjoinOn,\n\t\t\t\t\tnestedQueryRelation: relation,\n\t\t\t\t});\n\t\t\t\tconst field = sql`${sql.identifier(relationTableAlias)}.${sql.identifier('data')}`.as(selectedRelationTsKey);\n\t\t\t\tjoins.push({\n\t\t\t\t\ton: sql`true`,\n\t\t\t\t\ttable: new Subquery(builtRelation.sql as SQL, {}, relationTableAlias),\n\t\t\t\t\talias: relationTableAlias,\n\t\t\t\t\tjoinType: 'left',\n\t\t\t\t\tlateral: true,\n\t\t\t\t});\n\t\t\t\tselection.push({\n\t\t\t\t\tdbKey: selectedRelationTsKey,\n\t\t\t\t\ttsKey: selectedRelationTsKey,\n\t\t\t\t\tfield,\n\t\t\t\t\trelationTableTsKey: relationTableTsName,\n\t\t\t\t\tisJson: true,\n\t\t\t\t\tselection: builtRelation.selection,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (selection.length === 0) {\n\t\t\tthrow new DrizzleError({ message: `No fields selected for table \"${tableConfig.tsName}\" (\"${tableAlias}\")` });\n\t\t}\n\n\t\tlet result;\n\n\t\twhere = and(joinOn, where);\n\n\t\tif (nestedQueryRelation) {\n\t\t\tlet field = sql`JSON_TO_ARRAY(${\n\t\t\t\tsql.join(\n\t\t\t\t\tselection.map(({ field, tsKey, isJson }) =>\n\t\t\t\t\t\tisJson\n\t\t\t\t\t\t\t? sql`${sql.identifier(`${tableAlias}_${tsKey}`)}.${sql.identifier('data')}`\n\t\t\t\t\t\t\t: is(field, SQL.Aliased)\n\t\t\t\t\t\t\t? field.sql\n\t\t\t\t\t\t\t: field\n\t\t\t\t\t),\n\t\t\t\t\tsql`, `,\n\t\t\t\t)\n\t\t\t})`;\n\t\t\tif (is(nestedQueryRelation, Many)) {\n\t\t\t\tfield = sql`json_agg(${field})`;\n\t\t\t}\n\t\t\tconst nestedSelection = [{\n\t\t\t\tdbKey: 'data',\n\t\t\t\ttsKey: 'data',\n\t\t\t\tfield: field.as('data'),\n\t\t\t\tisJson: true,\n\t\t\t\trelationTableTsKey: tableConfig.tsName,\n\t\t\t\tselection,\n\t\t\t}];\n\n\t\t\tconst needsSubquery = limit !== undefined || offset !== undefined || (orderBy?.length ?? 0) > 0;\n\n\t\t\tif (needsSubquery) {\n\t\t\t\tresult = this.buildSelectQuery({\n\t\t\t\t\ttable: aliasedTable(table, tableAlias),\n\t\t\t\t\tfields: {},\n\t\t\t\t\tfieldsFlat: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\t\tfield: sql.raw('*'),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(((orderBy?.length ?? 0) > 0)\n\t\t\t\t\t\t\t? [{\n\t\t\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\t\t\tfield: sql`row_number() over (order by ${sql.join(orderBy!, sql`, `)})`,\n\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t],\n\t\t\t\t\twhere,\n\t\t\t\t\tlimit,\n\t\t\t\t\toffset,\n\t\t\t\t\tsetOperators: [],\n\t\t\t\t});\n\n\t\t\t\twhere = undefined;\n\t\t\t\tlimit = undefined;\n\t\t\t\toffset = undefined;\n\t\t\t\torderBy = undefined;\n\t\t\t} else {\n\t\t\t\tresult = aliasedTable(table, tableAlias);\n\t\t\t}\n\n\t\t\tresult = this.buildSelectQuery({\n\t\t\t\ttable: is(result, SingleStoreTable) ? result : new Subquery(result, {}, tableAlias),\n\t\t\t\tfields: {},\n\t\t\t\tfieldsFlat: nestedSelection.map(({ field }) => ({\n\t\t\t\t\tpath: [],\n\t\t\t\t\tfield: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field,\n\t\t\t\t})),\n\t\t\t\tjoins,\n\t\t\t\twhere,\n\t\t\t\tlimit,\n\t\t\t\toffset,\n\t\t\t\torderBy,\n\t\t\t\tsetOperators: [],\n\t\t\t});\n\t\t} else {\n\t\t\tresult = this.buildSelectQuery({\n\t\t\t\ttable: aliasedTable(table, tableAlias),\n\t\t\t\tfields: {},\n\t\t\t\tfieldsFlat: selection.map(({ field }) => ({\n\t\t\t\t\tpath: [],\n\t\t\t\t\tfield: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field,\n\t\t\t\t})),\n\t\t\t\tjoins,\n\t\t\t\twhere,\n\t\t\t\tlimit,\n\t\t\t\toffset,\n\t\t\t\torderBy,\n\t\t\t\tsetOperators: [],\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\ttableTsKey: tableConfig.tsName,\n\t\t\tsql: result,\n\t\t\tselection,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwG;AACxG,oBAA4B;AAC5B,oBAAuB;AACvB,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D;AAAA,EACD;AACD;","names":["import_table","table","sql","joinOn","field"]}
|
|
1
|
+
{"version":3,"sources":["../../src/singlestore-core/dialect.ts"],"sourcesContent":["import { aliasedTable, aliasedTableColumn, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias } from '~/alias.ts';\nimport { CasingCache } from '~/casing.ts';\nimport { Column } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { DrizzleError } from '~/errors.ts';\nimport type { MigrationConfig, MigrationMeta } from '~/migrator.ts';\nimport {\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tgetOperators,\n\tgetOrderByOperators,\n\tMany,\n\tnormalizeRelation,\n\tOne,\n\ttype Relation,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { and, eq } from '~/sql/expressions/index.ts';\nimport type { Name, Placeholder, QueryWithTypings, SQLChunk } from '~/sql/sql.ts';\nimport { Param, SQL, sql, View } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { getTableName, getTableUniqueName, Table } from '~/table.ts';\nimport { type Casing, orderSelectedFields, type UpdateSet } from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport { SingleStoreColumn } from './columns/common.ts';\nimport type { SingleStoreDeleteConfig } from './query-builders/delete.ts';\nimport type { SingleStoreInsertConfig } from './query-builders/insert.ts';\nimport type {\n\tSelectedFieldsOrdered,\n\tSingleStoreSelectConfig,\n\tSingleStoreSelectJoinConfig,\n} from './query-builders/select.types.ts';\nimport type { SingleStoreUpdateConfig } from './query-builders/update.ts';\nimport type { SingleStoreSession } from './session.ts';\nimport { SingleStoreTable } from './table.ts';\n/* import { SingleStoreViewBase } from './view-base.ts'; */\n\nexport interface SingleStoreDialectConfig {\n\tcasing?: Casing;\n}\n\nexport class SingleStoreDialect {\n\tstatic readonly [entityKind]: string = 'SingleStoreDialect';\n\n\t/** @internal */\n\treadonly casing: CasingCache;\n\n\tconstructor(config?: SingleStoreDialectConfig) {\n\t\tthis.casing = new CasingCache(config?.casing);\n\t}\n\n\tasync migrate(\n\t\tmigrations: MigrationMeta[],\n\t\tsession: SingleStoreSession,\n\t\tconfig: Omit<MigrationConfig, 'migrationsSchema'>,\n\t): Promise<void> {\n\t\tconst migrationsTable = config.migrationsTable ?? '__drizzle_migrations';\n\t\tconst migrationTableCreate = sql`\n\t\t\tcreate table if not exists ${sql.identifier(migrationsTable)} (\n\t\t\t\tid serial primary key,\n\t\t\t\thash text not null,\n\t\t\t\tcreated_at bigint\n\t\t\t)\n\t\t`;\n\t\tawait session.execute(migrationTableCreate);\n\n\t\tconst dbMigrations = await session.all<{\n\t\t\tid: number;\n\t\t\thash: string;\n\t\t\tcreated_at: string;\n\t\t}>(\n\t\t\tsql`select id, hash, created_at from ${sql.identifier(migrationsTable)} order by created_at desc limit 1`,\n\t\t);\n\n\t\tconst lastDbMigration = dbMigrations[0];\n\n\t\tawait session.transaction(async (tx) => {\n\t\t\tfor (const migration of migrations) {\n\t\t\t\tif (\n\t\t\t\t\t!lastDbMigration\n\t\t\t\t\t|| Number(lastDbMigration.created_at) < migration.folderMillis\n\t\t\t\t) {\n\t\t\t\t\tfor (const stmt of migration.sql) {\n\t\t\t\t\t\tawait tx.execute(sql.raw(stmt));\n\t\t\t\t\t}\n\t\t\t\t\tawait tx.execute(\n\t\t\t\t\t\tsql`insert into ${\n\t\t\t\t\t\t\tsql.identifier(\n\t\t\t\t\t\t\t\tmigrationsTable,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} (\\`hash\\`, \\`created_at\\`) values(${migration.hash}, ${migration.folderMillis})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tescapeName(name: string): string {\n\t\treturn `\\`${name.replace(/`/g, '``')}\\``;\n\t}\n\n\tescapeParam(_num: number): string {\n\t\treturn `?`;\n\t}\n\n\tescapeString(str: string): string {\n\t\treturn `'${str.replace(/'/g, \"''\")}'`;\n\t}\n\n\tprivate buildWithCTE(queries: Subquery[] | undefined): SQL | undefined {\n\t\tif (!queries?.length) return undefined;\n\n\t\tconst withSqlChunks = [sql`with `];\n\t\tfor (const [i, w] of queries.entries()) {\n\t\t\twithSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);\n\t\t\tif (i < queries.length - 1) {\n\t\t\t\twithSqlChunks.push(sql`, `);\n\t\t\t}\n\t\t}\n\t\twithSqlChunks.push(sql` `);\n\t\treturn sql.join(withSqlChunks);\n\t}\n\n\tbuildDeleteQuery({\n\t\ttable,\n\t\twhere,\n\t\treturning,\n\t\twithList,\n\t\tlimit,\n\t\torderBy,\n\t}: SingleStoreDeleteConfig): SQL {\n\t\tconst withSql = this.buildWithCTE(withList);\n\n\t\tconst returningSql = returning\n\t\t\t? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}`\n\t\t\t: undefined;\n\n\t\tconst whereSql = where ? sql` where ${where}` : undefined;\n\n\t\tconst orderBySql = this.buildOrderBy(orderBy);\n\n\t\tconst limitSql = this.buildLimit(limit);\n\n\t\treturn sql`${withSql}delete from ${table}${whereSql}${orderBySql}${limitSql}${returningSql}`;\n\t}\n\n\tbuildUpdateSet(table: SingleStoreTable, set: UpdateSet): SQL {\n\t\tconst tableColumns = table[Table.Symbol.Columns];\n\n\t\tconst columnNames = Object.keys(tableColumns).filter(\n\t\t\t(colName) =>\n\t\t\t\tset[colName] !== undefined\n\t\t\t\t|| tableColumns[colName]?.onUpdateFn !== undefined,\n\t\t);\n\n\t\tconst setSize = columnNames.length;\n\t\treturn sql.join(\n\t\t\tcolumnNames.flatMap((colName, i) => {\n\t\t\t\tconst col = tableColumns[colName]!;\n\n\t\t\t\tconst onUpdateFnResult = col.onUpdateFn?.();\n\t\t\t\tconst value = set[colName]\n\t\t\t\t\t?? (is(onUpdateFnResult, SQL)\n\t\t\t\t\t\t? onUpdateFnResult\n\t\t\t\t\t\t: sql.param(onUpdateFnResult, col));\n\t\t\t\tconst res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;\n\n\t\t\t\tif (i < setSize - 1) {\n\t\t\t\t\treturn [res, sql.raw(', ')];\n\t\t\t\t}\n\t\t\t\treturn [res];\n\t\t\t}),\n\t\t);\n\t}\n\n\tbuildUpdateQuery({\n\t\ttable,\n\t\tset,\n\t\twhere,\n\t\treturning,\n\t\twithList,\n\t\tlimit,\n\t\torderBy,\n\t}: SingleStoreUpdateConfig): SQL {\n\t\tconst withSql = this.buildWithCTE(withList);\n\n\t\tconst setSql = this.buildUpdateSet(table, set);\n\n\t\tconst returningSql = returning\n\t\t\t? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}`\n\t\t\t: undefined;\n\n\t\tconst whereSql = where ? sql` where ${where}` : undefined;\n\n\t\tconst orderBySql = this.buildOrderBy(orderBy);\n\n\t\tconst limitSql = this.buildLimit(limit);\n\n\t\treturn sql`${withSql}update ${table} set ${setSql}${whereSql}${orderBySql}${limitSql}${returningSql}`;\n\t}\n\n\t/**\n\t * Builds selection SQL with provided fields/expressions\n\t *\n\t * Examples:\n\t *\n\t * `select <selection> from`\n\t *\n\t * `insert ... returning <selection>`\n\t *\n\t * If `isSingleTable` is true, then columns won't be prefixed with table name\n\t */\n\tprivate buildSelection(\n\t\tfields: SelectedFieldsOrdered,\n\t\t{ isSingleTable = false }: { isSingleTable?: boolean } = {},\n\t): SQL {\n\t\tconst columnsLen = fields.length;\n\n\t\tconst chunks = fields.flatMap(({ field }, i) => {\n\t\t\tconst chunk: SQLChunk[] = [];\n\n\t\t\tif (is(field, SQL.Aliased) && field.isSelectionField) {\n\t\t\t\tchunk.push(sql.identifier(field.fieldAlias));\n\t\t\t} else if (is(field, SQL.Aliased) || is(field, SQL)) {\n\t\t\t\tconst query = is(field, SQL.Aliased) ? field.sql : field;\n\n\t\t\t\tif (isSingleTable) {\n\t\t\t\t\tchunk.push(\n\t\t\t\t\t\tnew SQL(\n\t\t\t\t\t\t\tquery.queryChunks.map((c) => {\n\t\t\t\t\t\t\t\tif (is(c, SingleStoreColumn)) {\n\t\t\t\t\t\t\t\t\treturn sql.identifier(this.casing.getColumnCasing(c));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn c;\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tchunk.push(query);\n\t\t\t\t}\n\n\t\t\t\tif (is(field, SQL.Aliased)) {\n\t\t\t\t\tchunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);\n\t\t\t\t}\n\t\t\t} else if (is(field, Column)) {\n\t\t\t\tif (isSingleTable) {\n\t\t\t\t\tchunk.push(sql.identifier(this.casing.getColumnCasing(field)));\n\t\t\t\t} else {\n\t\t\t\t\tchunk.push(field);\n\t\t\t\t}\n\t\t\t} else if (is(field, Subquery)) {\n\t\t\t\tconst entries = Object.entries(field._.selectedFields) as [\n\t\t\t\t\tstring,\n\t\t\t\t\tSQL.Aliased | Column | SQL,\n\t\t\t\t][];\n\n\t\t\t\tif (entries.length === 1) {\n\t\t\t\t\tconst entry = entries[0]![1];\n\n\t\t\t\t\tconst fieldDecoder = is(entry, SQL)\n\t\t\t\t\t\t? entry.decoder\n\t\t\t\t\t\t: is(entry, Column)\n\t\t\t\t\t\t? { mapFromDriverValue: (v: any) => entry.mapFromDriverValue(v) }\n\t\t\t\t\t\t: entry.sql.decoder;\n\n\t\t\t\t\tif (fieldDecoder) {\n\t\t\t\t\t\tfield._.sql.decoder = fieldDecoder;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tchunk.push(field);\n\t\t\t}\n\n\t\t\tif (i < columnsLen - 1) {\n\t\t\t\tchunk.push(sql`, `);\n\t\t\t}\n\n\t\t\treturn chunk;\n\t\t});\n\n\t\treturn sql.join(chunks);\n\t}\n\n\tprivate buildLimit(limit: number | Placeholder | undefined): SQL | undefined {\n\t\treturn typeof limit === 'object'\n\t\t\t\t|| (typeof limit === 'number' && limit >= 0)\n\t\t\t? sql` limit ${limit}`\n\t\t\t: undefined;\n\t}\n\n\tprivate buildOrderBy(\n\t\torderBy: (SingleStoreColumn | SQL | SQL.Aliased)[] | undefined,\n\t): SQL | undefined {\n\t\treturn orderBy && orderBy.length > 0\n\t\t\t? sql` order by ${sql.join(orderBy, sql`, `)}`\n\t\t\t: undefined;\n\t}\n\n\tbuildSelectQuery({\n\t\twithList,\n\t\tfields,\n\t\tfieldsFlat,\n\t\twhere,\n\t\thaving,\n\t\ttable,\n\t\tjoins,\n\t\torderBy,\n\t\tgroupBy,\n\t\tlimit,\n\t\toffset,\n\t\tlockingClause,\n\t\tdistinct,\n\t\tsetOperators,\n\t}: SingleStoreSelectConfig): SQL {\n\t\tconst fieldsList = fieldsFlat ?? orderSelectedFields<SingleStoreColumn>(fields);\n\t\tfor (const f of fieldsList) {\n\t\t\tif (\n\t\t\t\tis(f.field, Column)\n\t\t\t\t&& getTableName(f.field.table)\n\t\t\t\t\t!== (is(table, Subquery)\n\t\t\t\t\t\t? table._.alias\n\t\t\t\t\t\t/* : is(table, SingleStoreViewBase)\n\t\t\t\t\t\t? table[ViewBaseConfig].name */\n\t\t\t\t\t\t: is(table, SQL)\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: getTableName(table))\n\t\t\t\t&& !((table) =>\n\t\t\t\t\tjoins?.some(\n\t\t\t\t\t\t({ alias }) =>\n\t\t\t\t\t\t\talias\n\t\t\t\t\t\t\t\t=== (table[Table.Symbol.IsAlias]\n\t\t\t\t\t\t\t\t\t? getTableName(table)\n\t\t\t\t\t\t\t\t\t: table[Table.Symbol.BaseName]),\n\t\t\t\t\t))(f.field.table)\n\t\t\t) {\n\t\t\t\tconst tableName = getTableName(f.field.table);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Your \"${\n\t\t\t\t\t\tf.path.join(\n\t\t\t\t\t\t\t'->',\n\t\t\t\t\t\t)\n\t\t\t\t\t}\" field references a column \"${tableName}\".\"${f.field.name}\", but the table \"${tableName}\" is not part of the query! Did you forget to join it?`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst isSingleTable = !joins || joins.length === 0;\n\n\t\tconst withSql = this.buildWithCTE(withList);\n\n\t\tconst distinctSql = distinct ? sql` distinct` : undefined;\n\n\t\tconst selection = this.buildSelection(fieldsList, { isSingleTable });\n\n\t\tconst tableSql = (() => {\n\t\t\tif (is(table, Table) && table[Table.Symbol.IsAlias]) {\n\t\t\t\treturn sql`${sql`${sql.identifier(table[Table.Symbol.Schema] ?? '')}.`.if(table[Table.Symbol.Schema])}${\n\t\t\t\t\tsql.identifier(\n\t\t\t\t\t\ttable[Table.Symbol.OriginalName],\n\t\t\t\t\t)\n\t\t\t\t} ${sql.identifier(table[Table.Symbol.Name])}`;\n\t\t\t}\n\n\t\t\treturn table;\n\t\t})();\n\n\t\tconst joinsArray: SQL[] = [];\n\n\t\tif (joins) {\n\t\t\tfor (const [index, joinMeta] of joins.entries()) {\n\t\t\t\tif (index === 0) {\n\t\t\t\t\tjoinsArray.push(sql` `);\n\t\t\t\t}\n\t\t\t\tconst table = joinMeta.table;\n\t\t\t\tconst lateralSql = joinMeta.lateral ? sql` lateral` : undefined;\n\t\t\t\tconst onSql = joinMeta.on ? sql` on ${joinMeta.on}` : undefined;\n\n\t\t\t\tif (is(table, SingleStoreTable)) {\n\t\t\t\t\tconst tableName = table[SingleStoreTable.Symbol.Name];\n\t\t\t\t\tconst tableSchema = table[SingleStoreTable.Symbol.Schema];\n\t\t\t\t\tconst origTableName = table[SingleStoreTable.Symbol.OriginalName];\n\t\t\t\t\tconst alias = tableName === origTableName ? undefined : joinMeta.alias;\n\t\t\t\t\tjoinsArray.push(\n\t\t\t\t\t\tsql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${\n\t\t\t\t\t\t\ttableSchema ? sql`${sql.identifier(tableSchema)}.` : undefined\n\t\t\t\t\t\t}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`,\n\t\t\t\t\t);\n\t\t\t\t} else if (is(table, View)) {\n\t\t\t\t\tconst viewName = table[ViewBaseConfig].name;\n\t\t\t\t\tconst viewSchema = table[ViewBaseConfig].schema;\n\t\t\t\t\tconst origViewName = table[ViewBaseConfig].originalName;\n\t\t\t\t\tconst alias = viewName === origViewName ? undefined : joinMeta.alias;\n\t\t\t\t\tjoinsArray.push(\n\t\t\t\t\t\tsql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${\n\t\t\t\t\t\t\tviewSchema ? sql`${sql.identifier(viewSchema)}.` : undefined\n\t\t\t\t\t\t}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tjoinsArray.push(\n\t\t\t\t\t\tsql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table}${onSql}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (index < joins.length - 1) {\n\t\t\t\t\tjoinsArray.push(sql` `);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst joinsSql = sql.join(joinsArray);\n\n\t\tconst whereSql = where ? sql` where ${where}` : undefined;\n\n\t\tconst havingSql = having ? sql` having ${having}` : undefined;\n\n\t\tconst orderBySql = this.buildOrderBy(orderBy);\n\n\t\tconst groupBySql = groupBy && groupBy.length > 0\n\t\t\t? sql` group by ${sql.join(groupBy, sql`, `)}`\n\t\t\t: undefined;\n\n\t\tconst limitSql = this.buildLimit(limit);\n\n\t\tconst offsetSql = offset ? sql` offset ${offset}` : undefined;\n\n\t\tlet lockingClausesSql;\n\t\tif (lockingClause) {\n\t\t\tconst { config, strength } = lockingClause;\n\t\t\tlockingClausesSql = sql` for ${sql.raw(strength)}`;\n\t\t\tif (config.noWait) {\n\t\t\t\tlockingClausesSql.append(sql` nowait`);\n\t\t\t} else if (config.skipLocked) {\n\t\t\t\tlockingClausesSql.append(sql` skip locked`);\n\t\t\t}\n\t\t}\n\n\t\tconst finalQuery =\n\t\t\tsql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClausesSql}`;\n\n\t\tif (setOperators.length > 0) {\n\t\t\treturn this.buildSetOperations(finalQuery, setOperators);\n\t\t}\n\n\t\treturn finalQuery;\n\t}\n\n\tbuildSetOperations(\n\t\tleftSelect: SQL,\n\t\tsetOperators: SingleStoreSelectConfig['setOperators'],\n\t): SQL {\n\t\tconst [setOperator, ...rest] = setOperators;\n\n\t\tif (!setOperator) {\n\t\t\tthrow new Error('Cannot pass undefined values to any set operator');\n\t\t}\n\n\t\tif (rest.length === 0) {\n\t\t\treturn this.buildSetOperationQuery({ leftSelect, setOperator });\n\t\t}\n\n\t\t// Some recursive magic here\n\t\treturn this.buildSetOperations(\n\t\t\tthis.buildSetOperationQuery({ leftSelect, setOperator }),\n\t\t\trest,\n\t\t);\n\t}\n\n\tbuildSetOperationQuery({\n\t\tleftSelect,\n\t\tsetOperator: { type, isAll, rightSelect, limit, orderBy, offset },\n\t}: {\n\t\tleftSelect: SQL;\n\t\tsetOperator: SingleStoreSelectConfig['setOperators'][number];\n\t}): SQL {\n\t\tconst leftChunk = sql`(${leftSelect.getSQL()}) `;\n\t\tconst rightChunk = sql`(${rightSelect.getSQL()})`;\n\n\t\tlet orderBySql;\n\t\tif (orderBy && orderBy.length > 0) {\n\t\t\tconst orderByValues: (SQL<unknown> | Name)[] = [];\n\n\t\t\t// The next bit is necessary because the sql operator replaces ${table.column} with `table`.`column`\n\t\t\t// which is invalid SingleStore syntax, Table from one of the SELECTs cannot be used in global ORDER clause\n\t\t\tfor (const orderByUnit of orderBy) {\n\t\t\t\tif (is(orderByUnit, SingleStoreColumn)) {\n\t\t\t\t\torderByValues.push(\n\t\t\t\t\t\tsql.identifier(this.casing.getColumnCasing(orderByUnit)),\n\t\t\t\t\t);\n\t\t\t\t} else if (is(orderByUnit, SQL)) {\n\t\t\t\t\tfor (let i = 0; i < orderByUnit.queryChunks.length; i++) {\n\t\t\t\t\t\tconst chunk = orderByUnit.queryChunks[i];\n\n\t\t\t\t\t\tif (is(chunk, SingleStoreColumn)) {\n\t\t\t\t\t\t\torderByUnit.queryChunks[i] = sql.identifier(\n\t\t\t\t\t\t\t\tthis.casing.getColumnCasing(chunk),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\torderByValues.push(sql`${orderByUnit}`);\n\t\t\t\t} else {\n\t\t\t\t\torderByValues.push(sql`${orderByUnit}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\torderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;\n\t\t}\n\n\t\tconst limitSql = typeof limit === 'object' || (typeof limit === 'number' && limit >= 0)\n\t\t\t? sql` limit ${limit}`\n\t\t\t: undefined;\n\n\t\tconst operatorChunk = sql.raw(`${type} ${isAll ? 'all ' : ''}`);\n\n\t\tconst offsetSql = offset ? sql` offset ${offset}` : undefined;\n\n\t\treturn sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;\n\t}\n\n\tbuildInsertQuery({\n\t\ttable,\n\t\tvalues,\n\t\tignore,\n\t\tonConflict,\n\t}: SingleStoreInsertConfig): {\n\t\tsql: SQL;\n\t\tgeneratedIds: Record<string, unknown>[];\n\t} {\n\t\t// const isSingleValue = values.length === 1;\n\t\tconst valuesSqlList: ((SQLChunk | SQL)[] | SQL)[] = [];\n\t\tconst columns: Record<string, SingleStoreColumn> = table[Table.Symbol.Columns];\n\t\tconst colEntries: [string, SingleStoreColumn][] = Object.entries(\n\t\t\tcolumns,\n\t\t).filter(([_, col]) => !col.shouldDisableInsert());\n\n\t\tconst insertOrder = colEntries.map(([, column]) => sql.identifier(this.casing.getColumnCasing(column)));\n\t\tconst generatedIdsResponse: Record<string, unknown>[] = [];\n\n\t\tfor (const [valueIndex, value] of values.entries()) {\n\t\t\tconst generatedIds: Record<string, unknown> = {};\n\n\t\t\tconst valueList: (SQLChunk | SQL)[] = [];\n\t\t\tfor (const [fieldName, col] of colEntries) {\n\t\t\t\tconst colValue = value[fieldName];\n\t\t\t\tif (\n\t\t\t\t\tcolValue === undefined\n\t\t\t\t\t|| (is(colValue, Param) && colValue.value === undefined)\n\t\t\t\t) {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t\t\t\tif (col.defaultFn !== undefined) {\n\t\t\t\t\t\tconst defaultFnResult = col.defaultFn();\n\t\t\t\t\t\tgeneratedIds[fieldName] = defaultFnResult;\n\t\t\t\t\t\tconst defaultValue = is(defaultFnResult, SQL)\n\t\t\t\t\t\t\t? defaultFnResult\n\t\t\t\t\t\t\t: sql.param(defaultFnResult, col);\n\t\t\t\t\t\tvalueList.push(defaultValue);\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t\t\t\t} else if (!col.default && col.onUpdateFn !== undefined) {\n\t\t\t\t\t\tconst onUpdateFnResult = col.onUpdateFn();\n\t\t\t\t\t\tconst newValue = is(onUpdateFnResult, SQL)\n\t\t\t\t\t\t\t? onUpdateFnResult\n\t\t\t\t\t\t\t: sql.param(onUpdateFnResult, col);\n\t\t\t\t\t\tvalueList.push(newValue);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalueList.push(sql`default`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (col.defaultFn && is(colValue, Param)) {\n\t\t\t\t\t\tgeneratedIds[fieldName] = colValue.value;\n\t\t\t\t\t}\n\t\t\t\t\tvalueList.push(colValue);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgeneratedIdsResponse.push(generatedIds);\n\t\t\tvaluesSqlList.push(valueList);\n\t\t\tif (valueIndex < values.length - 1) {\n\t\t\t\tvaluesSqlList.push(sql`, `);\n\t\t\t}\n\t\t}\n\n\t\tconst valuesSql = sql.join(valuesSqlList);\n\n\t\tconst ignoreSql = ignore ? sql` ignore` : undefined;\n\n\t\tconst onConflictSql = onConflict\n\t\t\t? sql` on duplicate key ${onConflict}`\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tsql: sql`insert${ignoreSql} into ${table} ${insertOrder} values ${valuesSql}${onConflictSql}`,\n\t\t\tgeneratedIds: generatedIdsResponse,\n\t\t};\n\t}\n\n\tsqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings {\n\t\treturn sql.toQuery({\n\t\t\tcasing: this.casing,\n\t\t\tescapeName: this.escapeName,\n\t\t\tescapeParam: this.escapeParam,\n\t\t\tescapeString: this.escapeString,\n\t\t\tinvokeSource,\n\t\t});\n\t}\n\n\tbuildRelationalQuery({\n\t\tfullSchema,\n\t\tschema,\n\t\ttableNamesMap,\n\t\ttable,\n\t\ttableConfig,\n\t\tqueryConfig: config,\n\t\ttableAlias,\n\t\tnestedQueryRelation,\n\t\tjoinOn,\n\t}: {\n\t\tfullSchema: Record<string, unknown>;\n\t\tschema: TablesRelationalConfig;\n\t\ttableNamesMap: Record<string, string>;\n\t\ttable: SingleStoreTable;\n\t\ttableConfig: TableRelationalConfig;\n\t\tqueryConfig: true | DBQueryConfig<'many', true>;\n\t\ttableAlias: string;\n\t\tnestedQueryRelation?: Relation;\n\t\tjoinOn?: SQL;\n\t}): BuildRelationalQueryResult<SingleStoreTable, SingleStoreColumn> {\n\t\tlet selection: BuildRelationalQueryResult<\n\t\t\tSingleStoreTable,\n\t\t\tSingleStoreColumn\n\t\t>['selection'] = [];\n\t\tlet limit, offset, orderBy: SingleStoreSelectConfig['orderBy'], where;\n\t\tconst joins: SingleStoreSelectJoinConfig[] = [];\n\n\t\tif (config === true) {\n\t\t\tconst selectionEntries = Object.entries(tableConfig.columns);\n\t\t\tselection = selectionEntries.map(([key, value]) => ({\n\t\t\t\tdbKey: value.name,\n\t\t\t\ttsKey: key,\n\t\t\t\tfield: aliasedTableColumn(value as SingleStoreColumn, tableAlias),\n\t\t\t\trelationTableTsKey: undefined,\n\t\t\t\tisJson: false,\n\t\t\t\tselection: [],\n\t\t\t}));\n\t\t} else {\n\t\t\tconst aliasedColumns = Object.fromEntries(\n\t\t\t\tObject.entries(tableConfig.columns).map(([key, value]) => [\n\t\t\t\t\tkey,\n\t\t\t\t\taliasedTableColumn(value, tableAlias),\n\t\t\t\t]),\n\t\t\t);\n\n\t\t\tif (config.where) {\n\t\t\t\tconst whereSql = typeof config.where === 'function'\n\t\t\t\t\t? config.where(aliasedColumns, getOperators())\n\t\t\t\t\t: config.where;\n\t\t\t\twhere = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);\n\t\t\t}\n\n\t\t\tconst fieldsSelection: {\n\t\t\t\ttsKey: string;\n\t\t\t\tvalue: SingleStoreColumn | SQL.Aliased;\n\t\t\t}[] = [];\n\t\t\tlet selectedColumns: string[] = [];\n\n\t\t\t// Figure out which columns to select\n\t\t\tif (config.columns) {\n\t\t\t\tlet isIncludeMode = false;\n\n\t\t\t\tfor (const [field, value] of Object.entries(config.columns)) {\n\t\t\t\t\tif (value === undefined) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (field in tableConfig.columns) {\n\t\t\t\t\t\tif (!isIncludeMode && value === true) {\n\t\t\t\t\t\t\tisIncludeMode = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tselectedColumns.push(field);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (selectedColumns.length > 0) {\n\t\t\t\t\tselectedColumns = isIncludeMode\n\t\t\t\t\t\t? selectedColumns.filter((c) => config.columns?.[c] === true)\n\t\t\t\t\t\t: Object.keys(tableConfig.columns).filter(\n\t\t\t\t\t\t\t(key) => !selectedColumns.includes(key),\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Select all columns if selection is not specified\n\t\t\t\tselectedColumns = Object.keys(tableConfig.columns);\n\t\t\t}\n\n\t\t\tfor (const field of selectedColumns) {\n\t\t\t\tconst column = tableConfig.columns[field]! as SingleStoreColumn;\n\t\t\t\tfieldsSelection.push({ tsKey: field, value: column });\n\t\t\t}\n\n\t\t\tlet selectedRelations: {\n\t\t\t\ttsKey: string;\n\t\t\t\tqueryConfig: true | DBQueryConfig<'many', false>;\n\t\t\t\trelation: Relation;\n\t\t\t}[] = [];\n\n\t\t\t// Figure out which relations to select\n\t\t\tif (config.with) {\n\t\t\t\tselectedRelations = Object.entries(config.with)\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t): entry is [(typeof entry)[0], NonNullable<(typeof entry)[1]>] => !!entry[1],\n\t\t\t\t\t)\n\t\t\t\t\t.map(([tsKey, queryConfig]) => ({\n\t\t\t\t\t\ttsKey,\n\t\t\t\t\t\tqueryConfig,\n\t\t\t\t\t\trelation: tableConfig.relations[tsKey]!,\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\tlet extras;\n\n\t\t\t// Figure out which extras to select\n\t\t\tif (config.extras) {\n\t\t\t\textras = typeof config.extras === 'function'\n\t\t\t\t\t? config.extras(aliasedColumns, { sql })\n\t\t\t\t\t: config.extras;\n\t\t\t\tfor (const [tsKey, value] of Object.entries(extras)) {\n\t\t\t\t\tfieldsSelection.push({\n\t\t\t\t\t\ttsKey,\n\t\t\t\t\t\tvalue: mapColumnsInAliasedSQLToAlias(value, tableAlias),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Transform `fieldsSelection` into `selection`\n\t\t\t// `fieldsSelection` shouldn't be used after this point\n\t\t\tfor (const { tsKey, value } of fieldsSelection) {\n\t\t\t\tselection.push({\n\t\t\t\t\tdbKey: is(value, SQL.Aliased)\n\t\t\t\t\t\t? value.fieldAlias\n\t\t\t\t\t\t: tableConfig.columns[tsKey]!.name,\n\t\t\t\t\ttsKey,\n\t\t\t\t\tfield: is(value, Column)\n\t\t\t\t\t\t? aliasedTableColumn(value, tableAlias)\n\t\t\t\t\t\t: value,\n\t\t\t\t\trelationTableTsKey: undefined,\n\t\t\t\t\tisJson: false,\n\t\t\t\t\tselection: [],\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet orderByOrig = typeof config.orderBy === 'function'\n\t\t\t\t? config.orderBy(aliasedColumns, getOrderByOperators())\n\t\t\t\t: (config.orderBy ?? []);\n\t\t\tif (!Array.isArray(orderByOrig)) {\n\t\t\t\torderByOrig = [orderByOrig];\n\t\t\t}\n\t\t\torderBy = orderByOrig.map((orderByValue) => {\n\t\t\t\tif (is(orderByValue, Column)) {\n\t\t\t\t\treturn aliasedTableColumn(\n\t\t\t\t\t\torderByValue,\n\t\t\t\t\t\ttableAlias,\n\t\t\t\t\t) as SingleStoreColumn;\n\t\t\t\t}\n\t\t\t\treturn mapColumnsInSQLToAlias(orderByValue, tableAlias);\n\t\t\t});\n\n\t\t\tlimit = config.limit;\n\t\t\toffset = config.offset;\n\n\t\t\t// Process all relations\n\t\t\tfor (\n\t\t\t\tconst {\n\t\t\t\t\ttsKey: selectedRelationTsKey,\n\t\t\t\t\tqueryConfig: selectedRelationConfigValue,\n\t\t\t\t\trelation,\n\t\t\t\t} of selectedRelations\n\t\t\t) {\n\t\t\t\tconst normalizedRelation = normalizeRelation(\n\t\t\t\t\tschema,\n\t\t\t\t\ttableNamesMap,\n\t\t\t\t\trelation,\n\t\t\t\t);\n\t\t\t\tconst relationTableName = getTableUniqueName(relation.referencedTable);\n\t\t\t\tconst relationTableTsName = tableNamesMap[relationTableName]!;\n\t\t\t\tconst relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;\n\t\t\t\tconst joinOn = and(\n\t\t\t\t\t...normalizedRelation.fields.map((field, i) =>\n\t\t\t\t\t\teq(\n\t\t\t\t\t\t\taliasedTableColumn(\n\t\t\t\t\t\t\t\tnormalizedRelation.references[i]!,\n\t\t\t\t\t\t\t\trelationTableAlias,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\taliasedTableColumn(field, tableAlias),\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tconst builtRelation = this.buildRelationalQuery({\n\t\t\t\t\tfullSchema,\n\t\t\t\t\tschema,\n\t\t\t\t\ttableNamesMap,\n\t\t\t\t\ttable: fullSchema[relationTableTsName] as SingleStoreTable,\n\t\t\t\t\ttableConfig: schema[relationTableTsName]!,\n\t\t\t\t\tqueryConfig: is(relation, One)\n\t\t\t\t\t\t? selectedRelationConfigValue === true\n\t\t\t\t\t\t\t? { limit: 1 }\n\t\t\t\t\t\t\t: { ...selectedRelationConfigValue, limit: 1 }\n\t\t\t\t\t\t: selectedRelationConfigValue,\n\t\t\t\t\ttableAlias: relationTableAlias,\n\t\t\t\t\tjoinOn,\n\t\t\t\t\tnestedQueryRelation: relation,\n\t\t\t\t});\n\t\t\t\tconst field = sql`${sql.identifier(relationTableAlias)}.${sql.identifier('data')}`.as(\n\t\t\t\t\tselectedRelationTsKey,\n\t\t\t\t);\n\t\t\t\tjoins.push({\n\t\t\t\t\ton: sql`true`,\n\t\t\t\t\ttable: new Subquery(builtRelation.sql as SQL, {}, relationTableAlias),\n\t\t\t\t\talias: relationTableAlias,\n\t\t\t\t\tjoinType: 'left',\n\t\t\t\t\tlateral: true,\n\t\t\t\t});\n\t\t\t\tselection.push({\n\t\t\t\t\tdbKey: selectedRelationTsKey,\n\t\t\t\t\ttsKey: selectedRelationTsKey,\n\t\t\t\t\tfield,\n\t\t\t\t\trelationTableTsKey: relationTableTsName,\n\t\t\t\t\tisJson: true,\n\t\t\t\t\tselection: builtRelation.selection,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (selection.length === 0) {\n\t\t\tthrow new DrizzleError({\n\t\t\t\tmessage: `No fields selected for table \"${tableConfig.tsName}\" (\"${tableAlias}\")`,\n\t\t\t});\n\t\t}\n\n\t\tlet result;\n\n\t\twhere = and(joinOn, where);\n\n\t\tif (nestedQueryRelation) {\n\t\t\tlet field = sql`JSON_TO_ARRAY(${\n\t\t\t\tsql.join(\n\t\t\t\t\tselection.map(({ field, tsKey, isJson }) =>\n\t\t\t\t\t\tisJson\n\t\t\t\t\t\t\t? sql`${sql.identifier(`${tableAlias}_${tsKey}`)}.${sql.identifier('data')}`\n\t\t\t\t\t\t\t: is(field, SQL.Aliased)\n\t\t\t\t\t\t\t? field.sql\n\t\t\t\t\t\t\t: field\n\t\t\t\t\t),\n\t\t\t\t\tsql`, `,\n\t\t\t\t)\n\t\t\t})`;\n\t\t\tif (is(nestedQueryRelation, Many)) {\n\t\t\t\tfield = sql`json_agg(${field})`;\n\t\t\t}\n\t\t\tconst nestedSelection = [\n\t\t\t\t{\n\t\t\t\t\tdbKey: 'data',\n\t\t\t\t\ttsKey: 'data',\n\t\t\t\t\tfield: field.as('data'),\n\t\t\t\t\tisJson: true,\n\t\t\t\t\trelationTableTsKey: tableConfig.tsName,\n\t\t\t\t\tselection,\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tconst needsSubquery = limit !== undefined\n\t\t\t\t|| offset !== undefined\n\t\t\t\t|| (orderBy?.length ?? 0) > 0;\n\n\t\t\tif (needsSubquery) {\n\t\t\t\tresult = this.buildSelectQuery({\n\t\t\t\t\ttable: aliasedTable(table, tableAlias),\n\t\t\t\t\tfields: {},\n\t\t\t\t\tfieldsFlat: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\t\tfield: sql.raw('*'),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...((orderBy?.length ?? 0) > 0\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\t\t\t\tfield: sql`row_number() over (order by ${sql.join(orderBy!, sql`, `)})`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: []),\n\t\t\t\t\t],\n\t\t\t\t\twhere,\n\t\t\t\t\tlimit,\n\t\t\t\t\toffset,\n\t\t\t\t\tsetOperators: [],\n\t\t\t\t});\n\n\t\t\t\twhere = undefined;\n\t\t\t\tlimit = undefined;\n\t\t\t\toffset = undefined;\n\t\t\t\torderBy = undefined;\n\t\t\t} else {\n\t\t\t\tresult = aliasedTable(table, tableAlias);\n\t\t\t}\n\n\t\t\tresult = this.buildSelectQuery({\n\t\t\t\ttable: is(result, SingleStoreTable)\n\t\t\t\t\t? result\n\t\t\t\t\t: new Subquery(result, {}, tableAlias),\n\t\t\t\tfields: {},\n\t\t\t\tfieldsFlat: nestedSelection.map(({ field }) => ({\n\t\t\t\t\tpath: [],\n\t\t\t\t\tfield: is(field, Column)\n\t\t\t\t\t\t? aliasedTableColumn(field, tableAlias)\n\t\t\t\t\t\t: field,\n\t\t\t\t})),\n\t\t\t\tjoins,\n\t\t\t\twhere,\n\t\t\t\tlimit,\n\t\t\t\toffset,\n\t\t\t\torderBy,\n\t\t\t\tsetOperators: [],\n\t\t\t});\n\t\t} else {\n\t\t\tresult = this.buildSelectQuery({\n\t\t\t\ttable: aliasedTable(table, tableAlias),\n\t\t\t\tfields: {},\n\t\t\t\tfieldsFlat: selection.map(({ field }) => ({\n\t\t\t\t\tpath: [],\n\t\t\t\t\tfield: is(field, Column)\n\t\t\t\t\t\t? aliasedTableColumn(field, tableAlias)\n\t\t\t\t\t\t: field,\n\t\t\t\t})),\n\t\t\t\tjoins,\n\t\t\t\twhere,\n\t\t\t\tlimit,\n\t\t\t\toffset,\n\t\t\t\torderBy,\n\t\t\t\tsetOperators: [],\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\ttableTsKey: tableConfig.tsName,\n\t\t\tsql: result,\n\t\t\tselection,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwG;AACxG,oBAA4B;AAC5B,oBAAuB;AACvB,oBAA+B;AAC/B,oBAA6B;AAE7B,uBAWO;AACP,yBAAwB;AAExB,iBAAsC;AACtC,sBAAyB;AACzB,mBAAwD;AACxD,mBAAiE;AACjE,yBAA+B;A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,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,CAAC;AAAA,MAChB,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,MACN,YAAY,YAAY;AAAA,MACxB,KAAK;AAAA,MACL;AAAA,IACD;AAAA,EACD;AACD;","names":["import_table","table","sql","joinOn","field"]}
|
|
@@ -22,9 +22,9 @@ export declare class SingleStoreDialect {
|
|
|
22
22
|
escapeParam(_num: number): string;
|
|
23
23
|
escapeString(str: string): string;
|
|
24
24
|
private buildWithCTE;
|
|
25
|
-
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }: SingleStoreDeleteConfig): SQL;
|
|
25
|
+
buildDeleteQuery({ table, where, returning, withList, limit, orderBy, }: SingleStoreDeleteConfig): SQL;
|
|
26
26
|
buildUpdateSet(table: SingleStoreTable, set: UpdateSet): SQL;
|
|
27
|
-
buildUpdateQuery({ table, set, where, returning, withList, limit, orderBy }: SingleStoreUpdateConfig): SQL;
|
|
27
|
+
buildUpdateQuery({ table, set, where, returning, withList, limit, orderBy, }: SingleStoreUpdateConfig): SQL;
|
|
28
28
|
/**
|
|
29
29
|
* Builds selection SQL with provided fields/expressions
|
|
30
30
|
*
|
|
@@ -45,7 +45,7 @@ export declare class SingleStoreDialect {
|
|
|
45
45
|
leftSelect: SQL;
|
|
46
46
|
setOperator: SingleStoreSelectConfig['setOperators'][number];
|
|
47
47
|
}): SQL;
|
|
48
|
-
buildInsertQuery({ table, values, ignore, onConflict }: SingleStoreInsertConfig): {
|
|
48
|
+
buildInsertQuery({ table, values, ignore, onConflict, }: SingleStoreInsertConfig): {
|
|
49
49
|
sql: SQL;
|
|
50
50
|
generatedIds: Record<string, unknown>[];
|
|
51
51
|
};
|
|
@@ -22,9 +22,9 @@ export declare class SingleStoreDialect {
|
|
|
22
22
|
escapeParam(_num: number): string;
|
|
23
23
|
escapeString(str: string): string;
|
|
24
24
|
private buildWithCTE;
|
|
25
|
-
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }: SingleStoreDeleteConfig): SQL;
|
|
25
|
+
buildDeleteQuery({ table, where, returning, withList, limit, orderBy, }: SingleStoreDeleteConfig): SQL;
|
|
26
26
|
buildUpdateSet(table: SingleStoreTable, set: UpdateSet): SQL;
|
|
27
|
-
buildUpdateQuery({ table, set, where, returning, withList, limit, orderBy }: SingleStoreUpdateConfig): SQL;
|
|
27
|
+
buildUpdateQuery({ table, set, where, returning, withList, limit, orderBy, }: SingleStoreUpdateConfig): SQL;
|
|
28
28
|
/**
|
|
29
29
|
* Builds selection SQL with provided fields/expressions
|
|
30
30
|
*
|
|
@@ -45,7 +45,7 @@ export declare class SingleStoreDialect {
|
|
|
45
45
|
leftSelect: SQL;
|
|
46
46
|
setOperator: SingleStoreSelectConfig['setOperators'][number];
|
|
47
47
|
}): SQL;
|
|
48
|
-
buildInsertQuery({ table, values, ignore, onConflict }: SingleStoreInsertConfig): {
|
|
48
|
+
buildInsertQuery({ table, values, ignore, onConflict, }: SingleStoreInsertConfig): {
|
|
49
49
|
sql: SQL;
|
|
50
50
|
generatedIds: Record<string, unknown>[];
|
|
51
51
|
};
|