kanbo-cli 0.2.1 → 0.3.0
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/CHANGELOG.md +173 -0
- package/README.md +16 -47
- package/dist/{better-sqlite3-fU3G4xnX.cjs → better-sqlite3-DPdSZ6sH.cjs} +244 -247
- package/dist/cli-main.cjs +51208 -0
- package/dist/cli.cjs +32 -45216
- package/dist/dist-IHRTF-b5.cjs +2552 -0
- package/dist/lib/{tool-names-WfH4IURz.d.cts → approval-BsBk2xVr.d.cts} +72 -3
- package/dist/lib/{tool-names-3q_GEZej.d.mts → approval-LRZ6ontC.d.mts} +72 -3
- package/dist/lib/{board-store-BvWn9xTB.d.mts → board-store-D_Mpfb84.d.mts} +75 -2
- package/dist/lib/{board-store-BfszzAJB.d.cts → board-store-Dx-mw2I6.d.cts} +75 -2
- package/dist/lib/index.cjs +8 -2
- package/dist/lib/index.d.cts +202 -91
- package/dist/lib/index.d.mts +202 -91
- package/dist/lib/index.mjs +3 -3
- package/dist/lib/{manifest-D9nCRtXM.cjs → manifest-QPoQl8tn.cjs} +6881 -1556
- package/dist/lib/{manifest-DHV2fRdO.mjs → manifest-v2e9x_C8.mjs} +6795 -1556
- package/dist/lib/mcp/index.cjs +156 -21
- package/dist/lib/mcp/index.d.cts +140 -5
- package/dist/lib/mcp/index.d.mts +140 -5
- package/dist/lib/mcp/index.mjs +152 -22
- package/dist/lib/{migrate-DnMjTCvu.cjs → migrate-Dca5WdYd.cjs} +144 -14
- package/dist/lib/{migrate-BhYi9cXw.mjs → migrate-DtBeW3Fs.mjs} +134 -16
- package/dist/lib/{migrations-path-Ciwan537.mjs → migrations-path-ClaYRNwk.mjs} +5 -7
- package/dist/lib/{migrations-path-CZxVOgeD.cjs → migrations-path-DBCE17dT.cjs} +5 -7
- package/dist/lib/postgres/index.cjs +2 -4
- package/dist/lib/postgres/index.d.cts +2 -3
- package/dist/lib/postgres/index.d.mts +2 -3
- package/dist/lib/postgres/index.mjs +2 -4
- package/dist/lib/{roles.sql-CvyCGt38.mjs → roles.sql-BoOZSkBp.mjs} +96 -5
- package/dist/lib/{roles.sql-B9rt-x4o.cjs → roles.sql-E58x7mLS.cjs} +95 -4
- package/dist/lib/schema-D0MyXcej.d.cts +1 -2
- package/dist/lib/schema-D0MyXcej.d.mts +1 -2
- package/dist/lib/schema-epoch-ZyumVL_A.d.cts +1 -2
- package/dist/lib/schema-epoch-ZyumVL_A.d.mts +1 -2
- package/dist/lib/sqlite/index.cjs +2 -2
- package/dist/lib/sqlite/index.d.cts +3 -4
- package/dist/lib/sqlite/index.d.mts +3 -4
- package/dist/lib/sqlite/index.mjs +2 -2
- package/dist/lib/sqlite/schema.cjs +0 -2
- package/dist/lib/sqlite/schema.mjs +0 -2
- package/package.json +13 -10
- package/dist/better-sqlite3-fU3G4xnX.cjs.map +0 -1
- package/dist/cli.cjs.map +0 -1
- package/dist/dist-BsCwQFEl.cjs +0 -989
- package/dist/dist-BsCwQFEl.cjs.map +0 -1
- package/dist/lib/manifest-D9nCRtXM.cjs.map +0 -1
- package/dist/lib/manifest-DHV2fRdO.mjs.map +0 -1
- package/dist/lib/mcp/index.cjs.map +0 -1
- package/dist/lib/mcp/index.mjs.map +0 -1
- package/dist/lib/migrate-BhYi9cXw.mjs.map +0 -1
- package/dist/lib/migrate-DnMjTCvu.cjs.map +0 -1
- package/dist/lib/migrations-path-CZxVOgeD.cjs.map +0 -1
- package/dist/lib/migrations-path-Ciwan537.mjs.map +0 -1
- package/dist/lib/postgres/index.cjs.map +0 -1
- package/dist/lib/postgres/index.mjs.map +0 -1
- package/dist/lib/roles.sql-B9rt-x4o.cjs.map +0 -1
- package/dist/lib/roles.sql-CvyCGt38.mjs.map +0 -1
- package/dist/lib/sqlite/schema.cjs.map +0 -1
- package/dist/lib/sqlite/schema.mjs.map +0 -1
- package/drizzle-postgres/0000_board.sql +0 -135
- package/drizzle-postgres/0001_history_order.sql +0 -2
- package/drizzle-postgres/0002_issue_pull_requests.sql +0 -16
- package/drizzle-postgres/0003_milestone_start_date.sql +0 -1
- package/drizzle-postgres/0004_status_entry_rules.sql +0 -1
- package/drizzle-postgres/0005_run_external_session_ref.sql +0 -1
- package/drizzle-postgres/README.md +0 -61
- package/drizzle-postgres/meta/0000_snapshot.json +0 -1078
- package/drizzle-postgres/meta/0001_snapshot.json +0 -1090
- package/drizzle-postgres/meta/0002_snapshot.json +0 -1239
- package/drizzle-postgres/meta/0003_snapshot.json +0 -1245
- package/drizzle-postgres/meta/0004_snapshot.json +0 -1251
- package/drizzle-postgres/meta/0005_snapshot.json +0 -1257
- package/drizzle-postgres/meta/_journal.json +0 -48
- package/drizzle-sqlite/0000_board.sql +0 -133
- package/drizzle-sqlite/0001_issue_pull_requests.sql +0 -15
- package/drizzle-sqlite/0002_milestone_start_date.sql +0 -1
- package/drizzle-sqlite/0003_status_entry_rules.sql +0 -1
- package/drizzle-sqlite/0004_run_external_session_ref.sql +0 -1
- package/drizzle-sqlite/README.md +0 -67
- package/drizzle-sqlite/meta/0000_snapshot.json +0 -946
- package/drizzle-sqlite/meta/0001_snapshot.json +0 -1054
- package/drizzle-sqlite/meta/0002_snapshot.json +0 -1061
- package/drizzle-sqlite/meta/0003_snapshot.json +0 -1068
- package/drizzle-sqlite/meta/0004_snapshot.json +0 -1075
- package/drizzle-sqlite/meta/_journal.json +0 -41
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const require_cli = require("./cli.cjs");
|
|
1
|
+
const require_cli_main = require("./cli-main.cjs");
|
|
3
2
|
let better_sqlite3 = require("better-sqlite3");
|
|
4
|
-
better_sqlite3 =
|
|
3
|
+
better_sqlite3 = require_cli_main.__toESM(better_sqlite3, 1);
|
|
5
4
|
//#region node_modules/drizzle-orm/sqlite-core/query-builders/delete.js
|
|
6
|
-
var SQLiteDeleteBase = class extends
|
|
5
|
+
var SQLiteDeleteBase = class extends require_cli_main.QueryPromise {
|
|
7
6
|
constructor(table, session, dialect, withList) {
|
|
8
7
|
super();
|
|
9
8
|
this.table = table;
|
|
@@ -14,7 +13,7 @@ var SQLiteDeleteBase = class extends require_cli.QueryPromise {
|
|
|
14
13
|
withList
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
|
-
static [
|
|
16
|
+
static [require_cli_main.entityKind] = "SQLiteDelete";
|
|
18
17
|
/** @internal */
|
|
19
18
|
config;
|
|
20
19
|
/**
|
|
@@ -52,7 +51,7 @@ var SQLiteDeleteBase = class extends require_cli.QueryPromise {
|
|
|
52
51
|
}
|
|
53
52
|
orderBy(...columns) {
|
|
54
53
|
if (typeof columns[0] === "function") {
|
|
55
|
-
const orderBy = columns[0](new Proxy(this.config.table[
|
|
54
|
+
const orderBy = columns[0](new Proxy(this.config.table[require_cli_main.Table.Symbol.Columns], new require_cli_main.SelectionProxyHandler({
|
|
56
55
|
sqlAliasedBehavior: "alias",
|
|
57
56
|
sqlBehavior: "sql"
|
|
58
57
|
})));
|
|
@@ -68,8 +67,8 @@ var SQLiteDeleteBase = class extends require_cli.QueryPromise {
|
|
|
68
67
|
this.config.limit = limit;
|
|
69
68
|
return this;
|
|
70
69
|
}
|
|
71
|
-
returning(fields = this.table[
|
|
72
|
-
this.config.returning =
|
|
70
|
+
returning(fields = this.table[require_cli_main.SQLiteTable.Symbol.Columns]) {
|
|
71
|
+
this.config.returning = require_cli_main.orderSelectedFields(fields);
|
|
73
72
|
return this;
|
|
74
73
|
}
|
|
75
74
|
/** @internal */
|
|
@@ -84,7 +83,7 @@ var SQLiteDeleteBase = class extends require_cli.QueryPromise {
|
|
|
84
83
|
_prepare(isOneTimeQuery = true) {
|
|
85
84
|
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true, void 0, {
|
|
86
85
|
type: "delete",
|
|
87
|
-
tables:
|
|
86
|
+
tables: require_cli_main.extractUsedTable(this.config.table)
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
89
|
prepare() {
|
|
@@ -111,17 +110,17 @@ var SQLiteDeleteBase = class extends require_cli.QueryPromise {
|
|
|
111
110
|
};
|
|
112
111
|
//#endregion
|
|
113
112
|
//#region node_modules/drizzle-orm/sqlite-core/view-base.js
|
|
114
|
-
var SQLiteViewBase = class extends
|
|
115
|
-
static [
|
|
113
|
+
var SQLiteViewBase = class extends require_cli_main.View {
|
|
114
|
+
static [require_cli_main.entityKind] = "SQLiteViewBase";
|
|
116
115
|
};
|
|
117
116
|
//#endregion
|
|
118
117
|
//#region node_modules/drizzle-orm/sqlite-core/dialect.js
|
|
119
118
|
var SQLiteDialect = class {
|
|
120
|
-
static [
|
|
119
|
+
static [require_cli_main.entityKind] = "SQLiteDialect";
|
|
121
120
|
/** @internal */
|
|
122
121
|
casing;
|
|
123
122
|
constructor(config) {
|
|
124
|
-
this.casing = new
|
|
123
|
+
this.casing = new require_cli_main.CasingCache(config?.casing);
|
|
125
124
|
}
|
|
126
125
|
escapeName(name) {
|
|
127
126
|
return `"${name.replace(/"/g, "\"\"")}"`;
|
|
@@ -134,45 +133,45 @@ var SQLiteDialect = class {
|
|
|
134
133
|
}
|
|
135
134
|
buildWithCTE(queries) {
|
|
136
135
|
if (!queries?.length) return void 0;
|
|
137
|
-
const withSqlChunks = [
|
|
136
|
+
const withSqlChunks = [require_cli_main.sql`with `];
|
|
138
137
|
for (const [i, w] of queries.entries()) {
|
|
139
|
-
withSqlChunks.push(
|
|
140
|
-
if (i < queries.length - 1) withSqlChunks.push(
|
|
138
|
+
withSqlChunks.push(require_cli_main.sql`${require_cli_main.sql.identifier(w._.alias)} as (${w._.sql})`);
|
|
139
|
+
if (i < queries.length - 1) withSqlChunks.push(require_cli_main.sql`, `);
|
|
141
140
|
}
|
|
142
|
-
withSqlChunks.push(
|
|
143
|
-
return
|
|
141
|
+
withSqlChunks.push(require_cli_main.sql` `);
|
|
142
|
+
return require_cli_main.sql.join(withSqlChunks);
|
|
144
143
|
}
|
|
145
144
|
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }) {
|
|
146
145
|
const withSql = this.buildWithCTE(withList);
|
|
147
|
-
const returningSql = returning ?
|
|
148
|
-
const whereSql = where ?
|
|
146
|
+
const returningSql = returning ? require_cli_main.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
147
|
+
const whereSql = where ? require_cli_main.sql` where ${where}` : void 0;
|
|
149
148
|
const orderBySql = this.buildOrderBy(orderBy);
|
|
150
149
|
const limitSql = this.buildLimit(limit);
|
|
151
|
-
return
|
|
150
|
+
return require_cli_main.sql`${withSql}delete from ${table}${whereSql}${returningSql}${orderBySql}${limitSql}`;
|
|
152
151
|
}
|
|
153
152
|
buildUpdateSet(table, set) {
|
|
154
|
-
const tableColumns = table[
|
|
153
|
+
const tableColumns = table[require_cli_main.Table.Symbol.Columns];
|
|
155
154
|
const columnNames = Object.keys(tableColumns).filter((colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0);
|
|
156
155
|
const setSize = columnNames.length;
|
|
157
|
-
return
|
|
156
|
+
return require_cli_main.sql.join(columnNames.flatMap((colName, i) => {
|
|
158
157
|
const col = tableColumns[colName];
|
|
159
158
|
const onUpdateFnResult = col.onUpdateFn?.();
|
|
160
|
-
const value = set[colName] ?? (
|
|
161
|
-
const res =
|
|
162
|
-
if (i < setSize - 1) return [res,
|
|
159
|
+
const value = set[colName] ?? (require_cli_main.is(onUpdateFnResult, require_cli_main.SQL) ? onUpdateFnResult : require_cli_main.sql.param(onUpdateFnResult, col));
|
|
160
|
+
const res = require_cli_main.sql`${require_cli_main.sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
|
|
161
|
+
if (i < setSize - 1) return [res, require_cli_main.sql.raw(", ")];
|
|
163
162
|
return [res];
|
|
164
163
|
}));
|
|
165
164
|
}
|
|
166
165
|
buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy }) {
|
|
167
166
|
const withSql = this.buildWithCTE(withList);
|
|
168
167
|
const setSql = this.buildUpdateSet(table, set);
|
|
169
|
-
const fromSql = from &&
|
|
168
|
+
const fromSql = from && require_cli_main.sql.join([require_cli_main.sql.raw(" from "), this.buildFromTable(from)]);
|
|
170
169
|
const joinsSql = this.buildJoins(joins);
|
|
171
|
-
const returningSql = returning ?
|
|
172
|
-
const whereSql = where ?
|
|
170
|
+
const returningSql = returning ? require_cli_main.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
171
|
+
const whereSql = where ? require_cli_main.sql` where ${where}` : void 0;
|
|
173
172
|
const orderBySql = this.buildOrderBy(orderBy);
|
|
174
173
|
const limitSql = this.buildLimit(limit);
|
|
175
|
-
return
|
|
174
|
+
return require_cli_main.sql`${withSql}update ${table} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}${orderBySql}${limitSql}`;
|
|
176
175
|
}
|
|
177
176
|
/**
|
|
178
177
|
* Builds selection SQL with provided fields/expressions
|
|
@@ -189,93 +188,93 @@ var SQLiteDialect = class {
|
|
|
189
188
|
const columnsLen = fields.length;
|
|
190
189
|
const chunks = fields.flatMap(({ field }, i) => {
|
|
191
190
|
const chunk = [];
|
|
192
|
-
if (
|
|
193
|
-
else if (
|
|
194
|
-
const query =
|
|
195
|
-
if (isSingleTable) chunk.push(new
|
|
196
|
-
if (
|
|
191
|
+
if (require_cli_main.is(field, require_cli_main.SQL.Aliased) && field.isSelectionField) chunk.push(require_cli_main.sql.identifier(field.fieldAlias));
|
|
192
|
+
else if (require_cli_main.is(field, require_cli_main.SQL.Aliased) || require_cli_main.is(field, require_cli_main.SQL)) {
|
|
193
|
+
const query = require_cli_main.is(field, require_cli_main.SQL.Aliased) ? field.sql : field;
|
|
194
|
+
if (isSingleTable) chunk.push(new require_cli_main.SQL(query.queryChunks.map((c) => {
|
|
195
|
+
if (require_cli_main.is(c, require_cli_main.Column)) return require_cli_main.sql.identifier(this.casing.getColumnCasing(c));
|
|
197
196
|
return c;
|
|
198
197
|
})));
|
|
199
198
|
else chunk.push(query);
|
|
200
|
-
if (
|
|
201
|
-
} else if (
|
|
202
|
-
const tableName = field.table[
|
|
199
|
+
if (require_cli_main.is(field, require_cli_main.SQL.Aliased)) chunk.push(require_cli_main.sql` as ${require_cli_main.sql.identifier(field.fieldAlias)}`);
|
|
200
|
+
} else if (require_cli_main.is(field, require_cli_main.Column)) {
|
|
201
|
+
const tableName = field.table[require_cli_main.Table.Symbol.Name];
|
|
203
202
|
if (field.columnType === "SQLiteNumericBigInt") {
|
|
204
|
-
if (isSingleTable) chunk.push(
|
|
205
|
-
else chunk.push(
|
|
206
|
-
} else if (isSingleTable) chunk.push(
|
|
207
|
-
else chunk.push(
|
|
208
|
-
} else if (
|
|
203
|
+
if (isSingleTable) chunk.push(require_cli_main.sql`cast(${require_cli_main.sql.identifier(this.casing.getColumnCasing(field))} as text)`);
|
|
204
|
+
else chunk.push(require_cli_main.sql`cast(${require_cli_main.sql.identifier(tableName)}.${require_cli_main.sql.identifier(this.casing.getColumnCasing(field))} as text)`);
|
|
205
|
+
} else if (isSingleTable) chunk.push(require_cli_main.sql.identifier(this.casing.getColumnCasing(field)));
|
|
206
|
+
else chunk.push(require_cli_main.sql`${require_cli_main.sql.identifier(tableName)}.${require_cli_main.sql.identifier(this.casing.getColumnCasing(field))}`);
|
|
207
|
+
} else if (require_cli_main.is(field, require_cli_main.Subquery)) {
|
|
209
208
|
const entries = Object.entries(field._.selectedFields);
|
|
210
209
|
if (entries.length === 1) {
|
|
211
210
|
const entry = entries[0][1];
|
|
212
|
-
const fieldDecoder =
|
|
211
|
+
const fieldDecoder = require_cli_main.is(entry, require_cli_main.SQL) ? entry.decoder : require_cli_main.is(entry, require_cli_main.Column) ? { mapFromDriverValue: (v) => entry.mapFromDriverValue(v) } : entry.sql.decoder;
|
|
213
212
|
if (fieldDecoder) field._.sql.decoder = fieldDecoder;
|
|
214
213
|
}
|
|
215
214
|
chunk.push(field);
|
|
216
215
|
}
|
|
217
|
-
if (i < columnsLen - 1) chunk.push(
|
|
216
|
+
if (i < columnsLen - 1) chunk.push(require_cli_main.sql`, `);
|
|
218
217
|
return chunk;
|
|
219
218
|
});
|
|
220
|
-
return
|
|
219
|
+
return require_cli_main.sql.join(chunks);
|
|
221
220
|
}
|
|
222
221
|
buildJoins(joins) {
|
|
223
222
|
if (!joins || joins.length === 0) return;
|
|
224
223
|
const joinsArray = [];
|
|
225
224
|
if (joins) for (const [index, joinMeta] of joins.entries()) {
|
|
226
|
-
if (index === 0) joinsArray.push(
|
|
225
|
+
if (index === 0) joinsArray.push(require_cli_main.sql` `);
|
|
227
226
|
const table = joinMeta.table;
|
|
228
|
-
const onSql = joinMeta.on ?
|
|
229
|
-
if (
|
|
230
|
-
const tableName = table[
|
|
231
|
-
const tableSchema = table[
|
|
232
|
-
const origTableName = table[
|
|
227
|
+
const onSql = joinMeta.on ? require_cli_main.sql` on ${joinMeta.on}` : void 0;
|
|
228
|
+
if (require_cli_main.is(table, require_cli_main.SQLiteTable)) {
|
|
229
|
+
const tableName = table[require_cli_main.SQLiteTable.Symbol.Name];
|
|
230
|
+
const tableSchema = table[require_cli_main.SQLiteTable.Symbol.Schema];
|
|
231
|
+
const origTableName = table[require_cli_main.SQLiteTable.Symbol.OriginalName];
|
|
233
232
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
234
|
-
joinsArray.push(
|
|
235
|
-
} else joinsArray.push(
|
|
236
|
-
if (index < joins.length - 1) joinsArray.push(
|
|
233
|
+
joinsArray.push(require_cli_main.sql`${require_cli_main.sql.raw(joinMeta.joinType)} join ${tableSchema ? require_cli_main.sql`${require_cli_main.sql.identifier(tableSchema)}.` : void 0}${require_cli_main.sql.identifier(origTableName)}${alias && require_cli_main.sql` ${require_cli_main.sql.identifier(alias)}`}${onSql}`);
|
|
234
|
+
} else joinsArray.push(require_cli_main.sql`${require_cli_main.sql.raw(joinMeta.joinType)} join ${table}${onSql}`);
|
|
235
|
+
if (index < joins.length - 1) joinsArray.push(require_cli_main.sql` `);
|
|
237
236
|
}
|
|
238
|
-
return
|
|
237
|
+
return require_cli_main.sql.join(joinsArray);
|
|
239
238
|
}
|
|
240
239
|
buildLimit(limit) {
|
|
241
|
-
return typeof limit === "object" || typeof limit === "number" && limit >= 0 ?
|
|
240
|
+
return typeof limit === "object" || typeof limit === "number" && limit >= 0 ? require_cli_main.sql` limit ${limit}` : void 0;
|
|
242
241
|
}
|
|
243
242
|
buildOrderBy(orderBy) {
|
|
244
243
|
const orderByList = [];
|
|
245
244
|
if (orderBy) for (const [index, orderByValue] of orderBy.entries()) {
|
|
246
245
|
orderByList.push(orderByValue);
|
|
247
|
-
if (index < orderBy.length - 1) orderByList.push(
|
|
246
|
+
if (index < orderBy.length - 1) orderByList.push(require_cli_main.sql`, `);
|
|
248
247
|
}
|
|
249
|
-
return orderByList.length > 0 ?
|
|
248
|
+
return orderByList.length > 0 ? require_cli_main.sql` order by ${require_cli_main.sql.join(orderByList)}` : void 0;
|
|
250
249
|
}
|
|
251
250
|
buildFromTable(table) {
|
|
252
|
-
if (
|
|
251
|
+
if (require_cli_main.is(table, require_cli_main.Table) && table[require_cli_main.Table.Symbol.IsAlias]) return require_cli_main.sql`${require_cli_main.sql`${require_cli_main.sql.identifier(table[require_cli_main.Table.Symbol.Schema] ?? "")}.`.if(table[require_cli_main.Table.Symbol.Schema])}${require_cli_main.sql.identifier(table[require_cli_main.Table.Symbol.OriginalName])} ${require_cli_main.sql.identifier(table[require_cli_main.Table.Symbol.Name])}`;
|
|
253
252
|
return table;
|
|
254
253
|
}
|
|
255
254
|
buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, distinct, setOperators }) {
|
|
256
|
-
const fieldsList = fieldsFlat ??
|
|
257
|
-
for (const f of fieldsList) if (
|
|
258
|
-
const tableName =
|
|
255
|
+
const fieldsList = fieldsFlat ?? require_cli_main.orderSelectedFields(fields);
|
|
256
|
+
for (const f of fieldsList) if (require_cli_main.is(f.field, require_cli_main.Column) && require_cli_main.getTableName(f.field.table) !== (require_cli_main.is(table, require_cli_main.Subquery) ? table._.alias : require_cli_main.is(table, SQLiteViewBase) ? table[require_cli_main.ViewBaseConfig].name : require_cli_main.is(table, require_cli_main.SQL) ? void 0 : require_cli_main.getTableName(table)) && !((table2) => joins?.some(({ alias }) => alias === (table2[require_cli_main.Table.Symbol.IsAlias] ? require_cli_main.getTableName(table2) : table2[require_cli_main.Table.Symbol.BaseName])))(f.field.table)) {
|
|
257
|
+
const tableName = require_cli_main.getTableName(f.field.table);
|
|
259
258
|
throw new Error(`Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`);
|
|
260
259
|
}
|
|
261
260
|
const isSingleTable = !joins || joins.length === 0;
|
|
262
261
|
const withSql = this.buildWithCTE(withList);
|
|
263
|
-
const distinctSql = distinct ?
|
|
262
|
+
const distinctSql = distinct ? require_cli_main.sql` distinct` : void 0;
|
|
264
263
|
const selection = this.buildSelection(fieldsList, { isSingleTable });
|
|
265
264
|
const tableSql = this.buildFromTable(table);
|
|
266
265
|
const joinsSql = this.buildJoins(joins);
|
|
267
|
-
const whereSql = where ?
|
|
268
|
-
const havingSql = having ?
|
|
266
|
+
const whereSql = where ? require_cli_main.sql` where ${where}` : void 0;
|
|
267
|
+
const havingSql = having ? require_cli_main.sql` having ${having}` : void 0;
|
|
269
268
|
const groupByList = [];
|
|
270
269
|
if (groupBy) for (const [index, groupByValue] of groupBy.entries()) {
|
|
271
270
|
groupByList.push(groupByValue);
|
|
272
|
-
if (index < groupBy.length - 1) groupByList.push(
|
|
271
|
+
if (index < groupBy.length - 1) groupByList.push(require_cli_main.sql`, `);
|
|
273
272
|
}
|
|
274
|
-
const groupBySql = groupByList.length > 0 ?
|
|
273
|
+
const groupBySql = groupByList.length > 0 ? require_cli_main.sql` group by ${require_cli_main.sql.join(groupByList)}` : void 0;
|
|
275
274
|
const orderBySql = this.buildOrderBy(orderBy);
|
|
276
275
|
const limitSql = this.buildLimit(limit);
|
|
277
|
-
const offsetSql = offset ?
|
|
278
|
-
const finalQuery =
|
|
276
|
+
const offsetSql = offset ? require_cli_main.sql` offset ${offset}` : void 0;
|
|
277
|
+
const finalQuery = require_cli_main.sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}`;
|
|
279
278
|
if (setOperators.length > 0) return this.buildSetOperations(finalQuery, setOperators);
|
|
280
279
|
return finalQuery;
|
|
281
280
|
}
|
|
@@ -292,64 +291,64 @@ var SQLiteDialect = class {
|
|
|
292
291
|
}), rest);
|
|
293
292
|
}
|
|
294
293
|
buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset } }) {
|
|
295
|
-
const leftChunk =
|
|
296
|
-
const rightChunk =
|
|
294
|
+
const leftChunk = require_cli_main.sql`${leftSelect.getSQL()} `;
|
|
295
|
+
const rightChunk = require_cli_main.sql`${rightSelect.getSQL()}`;
|
|
297
296
|
let orderBySql;
|
|
298
297
|
if (orderBy && orderBy.length > 0) {
|
|
299
298
|
const orderByValues = [];
|
|
300
|
-
for (const singleOrderBy of orderBy) if (
|
|
301
|
-
else if (
|
|
299
|
+
for (const singleOrderBy of orderBy) if (require_cli_main.is(singleOrderBy, require_cli_main.SQLiteColumn)) orderByValues.push(require_cli_main.sql.identifier(singleOrderBy.name));
|
|
300
|
+
else if (require_cli_main.is(singleOrderBy, require_cli_main.SQL)) {
|
|
302
301
|
for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
|
|
303
302
|
const chunk = singleOrderBy.queryChunks[i];
|
|
304
|
-
if (
|
|
303
|
+
if (require_cli_main.is(chunk, require_cli_main.SQLiteColumn)) singleOrderBy.queryChunks[i] = require_cli_main.sql.identifier(this.casing.getColumnCasing(chunk));
|
|
305
304
|
}
|
|
306
|
-
orderByValues.push(
|
|
307
|
-
} else orderByValues.push(
|
|
308
|
-
orderBySql =
|
|
305
|
+
orderByValues.push(require_cli_main.sql`${singleOrderBy}`);
|
|
306
|
+
} else orderByValues.push(require_cli_main.sql`${singleOrderBy}`);
|
|
307
|
+
orderBySql = require_cli_main.sql` order by ${require_cli_main.sql.join(orderByValues, require_cli_main.sql`, `)}`;
|
|
309
308
|
}
|
|
310
|
-
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ?
|
|
311
|
-
const operatorChunk =
|
|
312
|
-
const offsetSql = offset ?
|
|
313
|
-
return
|
|
309
|
+
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? require_cli_main.sql` limit ${limit}` : void 0;
|
|
310
|
+
const operatorChunk = require_cli_main.sql.raw(`${type} ${isAll ? "all " : ""}`);
|
|
311
|
+
const offsetSql = offset ? require_cli_main.sql` offset ${offset}` : void 0;
|
|
312
|
+
return require_cli_main.sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
|
|
314
313
|
}
|
|
315
314
|
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select }) {
|
|
316
315
|
const valuesSqlList = [];
|
|
317
|
-
const columns = table[
|
|
316
|
+
const columns = table[require_cli_main.Table.Symbol.Columns];
|
|
318
317
|
const colEntries = Object.entries(columns).filter(([_, col]) => !col.shouldDisableInsert());
|
|
319
|
-
const insertOrder = colEntries.map(([, column]) =>
|
|
318
|
+
const insertOrder = colEntries.map(([, column]) => require_cli_main.sql.identifier(this.casing.getColumnCasing(column)));
|
|
320
319
|
if (select) {
|
|
321
320
|
const select2 = valuesOrSelect;
|
|
322
|
-
if (
|
|
321
|
+
if (require_cli_main.is(select2, require_cli_main.SQL)) valuesSqlList.push(select2);
|
|
323
322
|
else valuesSqlList.push(select2.getSQL());
|
|
324
323
|
} else {
|
|
325
324
|
const values = valuesOrSelect;
|
|
326
|
-
valuesSqlList.push(
|
|
325
|
+
valuesSqlList.push(require_cli_main.sql.raw("values "));
|
|
327
326
|
for (const [valueIndex, value] of values.entries()) {
|
|
328
327
|
const valueList = [];
|
|
329
328
|
for (const [fieldName, col] of colEntries) {
|
|
330
329
|
const colValue = value[fieldName];
|
|
331
|
-
if (colValue === void 0 ||
|
|
330
|
+
if (colValue === void 0 || require_cli_main.is(colValue, require_cli_main.Param) && colValue.value === void 0) {
|
|
332
331
|
let defaultValue;
|
|
333
|
-
if (col.default !== null && col.default !== void 0) defaultValue =
|
|
332
|
+
if (col.default !== null && col.default !== void 0) defaultValue = require_cli_main.is(col.default, require_cli_main.SQL) ? col.default : require_cli_main.sql.param(col.default, col);
|
|
334
333
|
else if (col.defaultFn !== void 0) {
|
|
335
334
|
const defaultFnResult = col.defaultFn();
|
|
336
|
-
defaultValue =
|
|
335
|
+
defaultValue = require_cli_main.is(defaultFnResult, require_cli_main.SQL) ? defaultFnResult : require_cli_main.sql.param(defaultFnResult, col);
|
|
337
336
|
} else if (!col.default && col.onUpdateFn !== void 0) {
|
|
338
337
|
const onUpdateFnResult = col.onUpdateFn();
|
|
339
|
-
defaultValue =
|
|
340
|
-
} else defaultValue =
|
|
338
|
+
defaultValue = require_cli_main.is(onUpdateFnResult, require_cli_main.SQL) ? onUpdateFnResult : require_cli_main.sql.param(onUpdateFnResult, col);
|
|
339
|
+
} else defaultValue = require_cli_main.sql`null`;
|
|
341
340
|
valueList.push(defaultValue);
|
|
342
341
|
} else valueList.push(colValue);
|
|
343
342
|
}
|
|
344
343
|
valuesSqlList.push(valueList);
|
|
345
|
-
if (valueIndex < values.length - 1) valuesSqlList.push(
|
|
344
|
+
if (valueIndex < values.length - 1) valuesSqlList.push(require_cli_main.sql`, `);
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
347
|
const withSql = this.buildWithCTE(withList);
|
|
349
|
-
const valuesSql =
|
|
350
|
-
const returningSql = returning ?
|
|
351
|
-
const onConflictSql = onConflict?.length ?
|
|
352
|
-
return
|
|
348
|
+
const valuesSql = require_cli_main.sql.join(valuesSqlList);
|
|
349
|
+
const returningSql = returning ? require_cli_main.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
350
|
+
const onConflictSql = onConflict?.length ? require_cli_main.sql.join(onConflict) : void 0;
|
|
351
|
+
return require_cli_main.sql`${withSql}insert into ${table} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
|
|
353
352
|
}
|
|
354
353
|
sqlToQuery(sql2, invokeSource) {
|
|
355
354
|
return sql2.toQuery({
|
|
@@ -367,16 +366,16 @@ var SQLiteDialect = class {
|
|
|
367
366
|
if (config === true) selection = Object.entries(tableConfig.columns).map(([key, value]) => ({
|
|
368
367
|
dbKey: value.name,
|
|
369
368
|
tsKey: key,
|
|
370
|
-
field:
|
|
369
|
+
field: require_cli_main.aliasedTableColumn(value, tableAlias),
|
|
371
370
|
relationTableTsKey: void 0,
|
|
372
371
|
isJson: false,
|
|
373
372
|
selection: []
|
|
374
373
|
}));
|
|
375
374
|
else {
|
|
376
|
-
const aliasedColumns = Object.fromEntries(Object.entries(tableConfig.columns).map(([key, value]) => [key,
|
|
375
|
+
const aliasedColumns = Object.fromEntries(Object.entries(tableConfig.columns).map(([key, value]) => [key, require_cli_main.aliasedTableColumn(value, tableAlias)]));
|
|
377
376
|
if (config.where) {
|
|
378
|
-
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns,
|
|
379
|
-
where = whereSql &&
|
|
377
|
+
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, require_cli_main.getOperators()) : config.where;
|
|
378
|
+
where = whereSql && require_cli_main.mapColumnsInSQLToAlias(whereSql, tableAlias);
|
|
380
379
|
}
|
|
381
380
|
const fieldsSelection = [];
|
|
382
381
|
let selectedColumns = [];
|
|
@@ -406,40 +405,40 @@ var SQLiteDialect = class {
|
|
|
406
405
|
}));
|
|
407
406
|
let extras;
|
|
408
407
|
if (config.extras) {
|
|
409
|
-
extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql:
|
|
408
|
+
extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql: require_cli_main.sql }) : config.extras;
|
|
410
409
|
for (const [tsKey, value] of Object.entries(extras)) fieldsSelection.push({
|
|
411
410
|
tsKey,
|
|
412
|
-
value:
|
|
411
|
+
value: require_cli_main.mapColumnsInAliasedSQLToAlias(value, tableAlias)
|
|
413
412
|
});
|
|
414
413
|
}
|
|
415
414
|
for (const { tsKey, value } of fieldsSelection) selection.push({
|
|
416
|
-
dbKey:
|
|
415
|
+
dbKey: require_cli_main.is(value, require_cli_main.SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey].name,
|
|
417
416
|
tsKey,
|
|
418
|
-
field:
|
|
417
|
+
field: require_cli_main.is(value, require_cli_main.Column) ? require_cli_main.aliasedTableColumn(value, tableAlias) : value,
|
|
419
418
|
relationTableTsKey: void 0,
|
|
420
419
|
isJson: false,
|
|
421
420
|
selection: []
|
|
422
421
|
});
|
|
423
|
-
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns,
|
|
422
|
+
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, require_cli_main.getOrderByOperators()) : config.orderBy ?? [];
|
|
424
423
|
if (!Array.isArray(orderByOrig)) orderByOrig = [orderByOrig];
|
|
425
424
|
orderBy = orderByOrig.map((orderByValue) => {
|
|
426
|
-
if (
|
|
427
|
-
return
|
|
425
|
+
if (require_cli_main.is(orderByValue, require_cli_main.Column)) return require_cli_main.aliasedTableColumn(orderByValue, tableAlias);
|
|
426
|
+
return require_cli_main.mapColumnsInSQLToAlias(orderByValue, tableAlias);
|
|
428
427
|
});
|
|
429
428
|
limit = config.limit;
|
|
430
429
|
offset = config.offset;
|
|
431
430
|
for (const { tsKey: selectedRelationTsKey, queryConfig: selectedRelationConfigValue, relation } of selectedRelations) {
|
|
432
|
-
const normalizedRelation =
|
|
433
|
-
const relationTableTsName = tableNamesMap[
|
|
431
|
+
const normalizedRelation = require_cli_main.normalizeRelation(schema, tableNamesMap, relation);
|
|
432
|
+
const relationTableTsName = tableNamesMap[require_cli_main.getTableUniqueName(relation.referencedTable)];
|
|
434
433
|
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
435
|
-
const joinOn2 =
|
|
434
|
+
const joinOn2 = require_cli_main.and(...normalizedRelation.fields.map((field2, i) => require_cli_main.eq(require_cli_main.aliasedTableColumn(normalizedRelation.references[i], relationTableAlias), require_cli_main.aliasedTableColumn(field2, tableAlias))));
|
|
436
435
|
const builtRelation = this.buildRelationalQuery({
|
|
437
436
|
fullSchema,
|
|
438
437
|
schema,
|
|
439
438
|
tableNamesMap,
|
|
440
439
|
table: fullSchema[relationTableTsName],
|
|
441
440
|
tableConfig: schema[relationTableTsName],
|
|
442
|
-
queryConfig:
|
|
441
|
+
queryConfig: require_cli_main.is(relation, require_cli_main.One) ? selectedRelationConfigValue === true ? { limit: 1 } : {
|
|
443
442
|
...selectedRelationConfigValue,
|
|
444
443
|
limit: 1
|
|
445
444
|
} : selectedRelationConfigValue,
|
|
@@ -447,7 +446,7 @@ var SQLiteDialect = class {
|
|
|
447
446
|
joinOn: joinOn2,
|
|
448
447
|
nestedQueryRelation: relation
|
|
449
448
|
});
|
|
450
|
-
const field =
|
|
449
|
+
const field = require_cli_main.sql`(${builtRelation.sql})`.as(selectedRelationTsKey);
|
|
451
450
|
selection.push({
|
|
452
451
|
dbKey: selectedRelationTsKey,
|
|
453
452
|
tsKey: selectedRelationTsKey,
|
|
@@ -458,12 +457,12 @@ var SQLiteDialect = class {
|
|
|
458
457
|
});
|
|
459
458
|
}
|
|
460
459
|
}
|
|
461
|
-
if (selection.length === 0) throw new
|
|
460
|
+
if (selection.length === 0) throw new require_cli_main.DrizzleError({ message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.` });
|
|
462
461
|
let result;
|
|
463
|
-
where =
|
|
462
|
+
where = require_cli_main.and(joinOn, where);
|
|
464
463
|
if (nestedQueryRelation) {
|
|
465
|
-
let field =
|
|
466
|
-
if (
|
|
464
|
+
let field = require_cli_main.sql`json_array(${require_cli_main.sql.join(selection.map(({ field: field2 }) => require_cli_main.is(field2, require_cli_main.SQLiteColumn) ? require_cli_main.sql.identifier(this.casing.getColumnCasing(field2)) : require_cli_main.is(field2, require_cli_main.SQL.Aliased) ? field2.sql : field2), require_cli_main.sql`, `)})`;
|
|
465
|
+
if (require_cli_main.is(nestedQueryRelation, require_cli_main.Many)) field = require_cli_main.sql`coalesce(json_group_array(${field}), json_array())`;
|
|
467
466
|
const nestedSelection = [{
|
|
468
467
|
dbKey: "data",
|
|
469
468
|
tsKey: "data",
|
|
@@ -474,11 +473,11 @@ var SQLiteDialect = class {
|
|
|
474
473
|
}];
|
|
475
474
|
if (limit !== void 0 || offset !== void 0 || orderBy.length > 0) {
|
|
476
475
|
result = this.buildSelectQuery({
|
|
477
|
-
table:
|
|
476
|
+
table: require_cli_main.aliasedTable(table, tableAlias),
|
|
478
477
|
fields: {},
|
|
479
478
|
fieldsFlat: [{
|
|
480
479
|
path: [],
|
|
481
|
-
field:
|
|
480
|
+
field: require_cli_main.sql.raw("*")
|
|
482
481
|
}],
|
|
483
482
|
where,
|
|
484
483
|
limit,
|
|
@@ -490,13 +489,13 @@ var SQLiteDialect = class {
|
|
|
490
489
|
limit = void 0;
|
|
491
490
|
offset = void 0;
|
|
492
491
|
orderBy = void 0;
|
|
493
|
-
} else result =
|
|
492
|
+
} else result = require_cli_main.aliasedTable(table, tableAlias);
|
|
494
493
|
result = this.buildSelectQuery({
|
|
495
|
-
table:
|
|
494
|
+
table: require_cli_main.is(result, require_cli_main.SQLiteTable) ? result : new require_cli_main.Subquery(result, {}, tableAlias),
|
|
496
495
|
fields: {},
|
|
497
496
|
fieldsFlat: nestedSelection.map(({ field: field2 }) => ({
|
|
498
497
|
path: [],
|
|
499
|
-
field:
|
|
498
|
+
field: require_cli_main.is(field2, require_cli_main.Column) ? require_cli_main.aliasedTableColumn(field2, tableAlias) : field2
|
|
500
499
|
})),
|
|
501
500
|
joins,
|
|
502
501
|
where,
|
|
@@ -506,11 +505,11 @@ var SQLiteDialect = class {
|
|
|
506
505
|
setOperators: []
|
|
507
506
|
});
|
|
508
507
|
} else result = this.buildSelectQuery({
|
|
509
|
-
table:
|
|
508
|
+
table: require_cli_main.aliasedTable(table, tableAlias),
|
|
510
509
|
fields: {},
|
|
511
510
|
fieldsFlat: selection.map(({ field }) => ({
|
|
512
511
|
path: [],
|
|
513
|
-
field:
|
|
512
|
+
field: require_cli_main.is(field, require_cli_main.Column) ? require_cli_main.aliasedTableColumn(field, tableAlias) : field
|
|
514
513
|
})),
|
|
515
514
|
joins,
|
|
516
515
|
where,
|
|
@@ -527,27 +526,27 @@ var SQLiteDialect = class {
|
|
|
527
526
|
}
|
|
528
527
|
};
|
|
529
528
|
var SQLiteSyncDialect = class extends SQLiteDialect {
|
|
530
|
-
static [
|
|
529
|
+
static [require_cli_main.entityKind] = "SQLiteSyncDialect";
|
|
531
530
|
migrate(migrations, session, config) {
|
|
532
531
|
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.migrationsTable ?? "__drizzle_migrations";
|
|
533
|
-
const migrationTableCreate =
|
|
534
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
532
|
+
const migrationTableCreate = require_cli_main.sql`
|
|
533
|
+
CREATE TABLE IF NOT EXISTS ${require_cli_main.sql.identifier(migrationsTable)} (
|
|
535
534
|
id SERIAL PRIMARY KEY,
|
|
536
535
|
hash text NOT NULL,
|
|
537
536
|
created_at numeric
|
|
538
537
|
)
|
|
539
538
|
`;
|
|
540
539
|
session.run(migrationTableCreate);
|
|
541
|
-
const lastDbMigration = session.values(
|
|
542
|
-
session.run(
|
|
540
|
+
const lastDbMigration = session.values(require_cli_main.sql`SELECT id, hash, created_at FROM ${require_cli_main.sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`)[0] ?? void 0;
|
|
541
|
+
session.run(require_cli_main.sql`BEGIN`);
|
|
543
542
|
try {
|
|
544
543
|
for (const migration of migrations) if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
|
|
545
|
-
for (const stmt of migration.sql) session.run(
|
|
546
|
-
session.run(
|
|
544
|
+
for (const stmt of migration.sql) session.run(require_cli_main.sql.raw(stmt));
|
|
545
|
+
session.run(require_cli_main.sql`INSERT INTO ${require_cli_main.sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`);
|
|
547
546
|
}
|
|
548
|
-
session.run(
|
|
547
|
+
session.run(require_cli_main.sql`COMMIT`);
|
|
549
548
|
} catch (e) {
|
|
550
|
-
session.run(
|
|
549
|
+
session.run(require_cli_main.sql`ROLLBACK`);
|
|
551
550
|
throw e;
|
|
552
551
|
}
|
|
553
552
|
}
|
|
@@ -555,7 +554,7 @@ var SQLiteSyncDialect = class extends SQLiteDialect {
|
|
|
555
554
|
//#endregion
|
|
556
555
|
//#region node_modules/drizzle-orm/sqlite-core/query-builders/select.js
|
|
557
556
|
var SQLiteSelectBuilder = class {
|
|
558
|
-
static [
|
|
557
|
+
static [require_cli_main.entityKind] = "SQLiteSelectBuilder";
|
|
559
558
|
fields;
|
|
560
559
|
session;
|
|
561
560
|
dialect;
|
|
@@ -572,10 +571,10 @@ var SQLiteSelectBuilder = class {
|
|
|
572
571
|
const isPartialSelect = !!this.fields;
|
|
573
572
|
let fields;
|
|
574
573
|
if (this.fields) fields = this.fields;
|
|
575
|
-
else if (
|
|
576
|
-
else if (
|
|
577
|
-
else if (
|
|
578
|
-
else fields =
|
|
574
|
+
else if (require_cli_main.is(source, require_cli_main.Subquery)) fields = Object.fromEntries(Object.keys(source._.selectedFields).map((key) => [key, source[key]]));
|
|
575
|
+
else if (require_cli_main.is(source, SQLiteViewBase)) fields = source[require_cli_main.ViewBaseConfig].selectedFields;
|
|
576
|
+
else if (require_cli_main.is(source, require_cli_main.SQL)) fields = {};
|
|
577
|
+
else fields = require_cli_main.getTableColumns(source);
|
|
579
578
|
return new SQLiteSelectBase({
|
|
580
579
|
table: source,
|
|
581
580
|
fields,
|
|
@@ -587,8 +586,8 @@ var SQLiteSelectBuilder = class {
|
|
|
587
586
|
});
|
|
588
587
|
}
|
|
589
588
|
};
|
|
590
|
-
var SQLiteSelectQueryBuilderBase = class extends
|
|
591
|
-
static [
|
|
589
|
+
var SQLiteSelectQueryBuilderBase = class extends require_cli_main.TypedQueryBuilder {
|
|
590
|
+
static [require_cli_main.entityKind] = "SQLiteSelectQueryBuilder";
|
|
592
591
|
_;
|
|
593
592
|
/** @internal */
|
|
594
593
|
config;
|
|
@@ -615,9 +614,9 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
615
614
|
selectedFields: fields,
|
|
616
615
|
config: this.config
|
|
617
616
|
};
|
|
618
|
-
this.tableName =
|
|
617
|
+
this.tableName = require_cli_main.getTableLikeName(table);
|
|
619
618
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
620
|
-
for (const item of
|
|
619
|
+
for (const item of require_cli_main.extractUsedTable(table)) this.usedTables.add(item);
|
|
621
620
|
}
|
|
622
621
|
/** @internal */
|
|
623
622
|
getUsedTables() {
|
|
@@ -626,17 +625,17 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
626
625
|
createJoin(joinType) {
|
|
627
626
|
return (table, on) => {
|
|
628
627
|
const baseTableName = this.tableName;
|
|
629
|
-
const tableName =
|
|
630
|
-
for (const item of
|
|
628
|
+
const tableName = require_cli_main.getTableLikeName(table);
|
|
629
|
+
for (const item of require_cli_main.extractUsedTable(table)) this.usedTables.add(item);
|
|
631
630
|
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
632
631
|
if (!this.isPartialSelect) {
|
|
633
632
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
634
|
-
if (typeof tableName === "string" && !
|
|
635
|
-
const selection =
|
|
633
|
+
if (typeof tableName === "string" && !require_cli_main.is(table, require_cli_main.SQL)) {
|
|
634
|
+
const selection = require_cli_main.is(table, require_cli_main.Subquery) ? table._.selectedFields : require_cli_main.is(table, require_cli_main.View) ? table[require_cli_main.ViewBaseConfig].selectedFields : table[require_cli_main.Table.Symbol.Columns];
|
|
636
635
|
this.config.fields[tableName] = selection;
|
|
637
636
|
}
|
|
638
637
|
}
|
|
639
|
-
if (typeof on === "function") on = on(new Proxy(this.config.fields, new
|
|
638
|
+
if (typeof on === "function") on = on(new Proxy(this.config.fields, new require_cli_main.SelectionProxyHandler({
|
|
640
639
|
sqlAliasedBehavior: "sql",
|
|
641
640
|
sqlBehavior: "sql"
|
|
642
641
|
})));
|
|
@@ -808,7 +807,7 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
808
807
|
createSetOperator(type, isAll) {
|
|
809
808
|
return (rightSelection) => {
|
|
810
809
|
const rightSelect = typeof rightSelection === "function" ? rightSelection(getSQLiteSetOperators()) : rightSelection;
|
|
811
|
-
if (!
|
|
810
|
+
if (!require_cli_main.haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields())) throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");
|
|
812
811
|
this.config.setOperators.push({
|
|
813
812
|
type,
|
|
814
813
|
isAll,
|
|
@@ -956,7 +955,7 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
956
955
|
* ```
|
|
957
956
|
*/
|
|
958
957
|
where(where) {
|
|
959
|
-
if (typeof where === "function") where = where(new Proxy(this.config.fields, new
|
|
958
|
+
if (typeof where === "function") where = where(new Proxy(this.config.fields, new require_cli_main.SelectionProxyHandler({
|
|
960
959
|
sqlAliasedBehavior: "sql",
|
|
961
960
|
sqlBehavior: "sql"
|
|
962
961
|
})));
|
|
@@ -986,7 +985,7 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
986
985
|
* ```
|
|
987
986
|
*/
|
|
988
987
|
having(having) {
|
|
989
|
-
if (typeof having === "function") having = having(new Proxy(this.config.fields, new
|
|
988
|
+
if (typeof having === "function") having = having(new Proxy(this.config.fields, new require_cli_main.SelectionProxyHandler({
|
|
990
989
|
sqlAliasedBehavior: "sql",
|
|
991
990
|
sqlBehavior: "sql"
|
|
992
991
|
})));
|
|
@@ -995,7 +994,7 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
995
994
|
}
|
|
996
995
|
groupBy(...columns) {
|
|
997
996
|
if (typeof columns[0] === "function") {
|
|
998
|
-
const groupBy = columns[0](new Proxy(this.config.fields, new
|
|
997
|
+
const groupBy = columns[0](new Proxy(this.config.fields, new require_cli_main.SelectionProxyHandler({
|
|
999
998
|
sqlAliasedBehavior: "alias",
|
|
1000
999
|
sqlBehavior: "sql"
|
|
1001
1000
|
})));
|
|
@@ -1005,7 +1004,7 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
1005
1004
|
}
|
|
1006
1005
|
orderBy(...columns) {
|
|
1007
1006
|
if (typeof columns[0] === "function") {
|
|
1008
|
-
const orderBy = columns[0](new Proxy(this.config.fields, new
|
|
1007
|
+
const orderBy = columns[0](new Proxy(this.config.fields, new require_cli_main.SelectionProxyHandler({
|
|
1009
1008
|
sqlAliasedBehavior: "alias",
|
|
1010
1009
|
sqlBehavior: "sql"
|
|
1011
1010
|
})));
|
|
@@ -1071,9 +1070,9 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
1071
1070
|
}
|
|
1072
1071
|
as(alias) {
|
|
1073
1072
|
const usedTables = [];
|
|
1074
|
-
usedTables.push(...
|
|
1075
|
-
if (this.config.joins) for (const it of this.config.joins) usedTables.push(...
|
|
1076
|
-
return new Proxy(new
|
|
1073
|
+
usedTables.push(...require_cli_main.extractUsedTable(this.config.table));
|
|
1074
|
+
if (this.config.joins) for (const it of this.config.joins) usedTables.push(...require_cli_main.extractUsedTable(it.table));
|
|
1075
|
+
return new Proxy(new require_cli_main.Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]), new require_cli_main.SelectionProxyHandler({
|
|
1077
1076
|
alias,
|
|
1078
1077
|
sqlAliasedBehavior: "alias",
|
|
1079
1078
|
sqlBehavior: "error"
|
|
@@ -1081,7 +1080,7 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
1081
1080
|
}
|
|
1082
1081
|
/** @internal */
|
|
1083
1082
|
getSelectedFields() {
|
|
1084
|
-
return new Proxy(this.config.fields, new
|
|
1083
|
+
return new Proxy(this.config.fields, new require_cli_main.SelectionProxyHandler({
|
|
1085
1084
|
alias: this.tableName,
|
|
1086
1085
|
sqlAliasedBehavior: "alias",
|
|
1087
1086
|
sqlBehavior: "error"
|
|
@@ -1092,11 +1091,11 @@ var SQLiteSelectQueryBuilderBase = class extends require_cli.TypedQueryBuilder {
|
|
|
1092
1091
|
}
|
|
1093
1092
|
};
|
|
1094
1093
|
var SQLiteSelectBase = class extends SQLiteSelectQueryBuilderBase {
|
|
1095
|
-
static [
|
|
1094
|
+
static [require_cli_main.entityKind] = "SQLiteSelect";
|
|
1096
1095
|
/** @internal */
|
|
1097
1096
|
_prepare(isOneTimeQuery = true) {
|
|
1098
1097
|
if (!this.session) throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
|
1099
|
-
const fieldsList =
|
|
1098
|
+
const fieldsList = require_cli_main.orderSelectedFields(this.config.fields);
|
|
1100
1099
|
const query = this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), fieldsList, "all", true, void 0, {
|
|
1101
1100
|
type: "select",
|
|
1102
1101
|
tables: [...this.usedTables]
|
|
@@ -1135,7 +1134,7 @@ var SQLiteSelectBase = class extends SQLiteSelectQueryBuilderBase {
|
|
|
1135
1134
|
return this.all();
|
|
1136
1135
|
}
|
|
1137
1136
|
};
|
|
1138
|
-
|
|
1137
|
+
require_cli_main.applyMixins(SQLiteSelectBase, [require_cli_main.QueryPromise]);
|
|
1139
1138
|
function createSetOperator(type, isAll) {
|
|
1140
1139
|
return (leftSelect, rightSelect, ...restSelects) => {
|
|
1141
1140
|
const setOperators = [rightSelect, ...restSelects].map((select) => ({
|
|
@@ -1143,7 +1142,7 @@ function createSetOperator(type, isAll) {
|
|
|
1143
1142
|
isAll,
|
|
1144
1143
|
rightSelect: select
|
|
1145
1144
|
}));
|
|
1146
|
-
for (const setOperator of setOperators) if (!
|
|
1145
|
+
for (const setOperator of setOperators) if (!require_cli_main.haveSameKeys(leftSelect.getSelectedFields(), setOperator.rightSelect.getSelectedFields())) throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");
|
|
1147
1146
|
return leftSelect.addSetOperators(setOperators);
|
|
1148
1147
|
};
|
|
1149
1148
|
}
|
|
@@ -1160,18 +1159,18 @@ const except = createSetOperator("except", false);
|
|
|
1160
1159
|
//#endregion
|
|
1161
1160
|
//#region node_modules/drizzle-orm/sqlite-core/query-builders/query-builder.js
|
|
1162
1161
|
var QueryBuilder = class {
|
|
1163
|
-
static [
|
|
1162
|
+
static [require_cli_main.entityKind] = "SQLiteQueryBuilder";
|
|
1164
1163
|
dialect;
|
|
1165
1164
|
dialectConfig;
|
|
1166
1165
|
constructor(dialect) {
|
|
1167
|
-
this.dialect =
|
|
1168
|
-
this.dialectConfig =
|
|
1166
|
+
this.dialect = require_cli_main.is(dialect, SQLiteDialect) ? dialect : void 0;
|
|
1167
|
+
this.dialectConfig = require_cli_main.is(dialect, SQLiteDialect) ? void 0 : dialect;
|
|
1169
1168
|
}
|
|
1170
1169
|
$with = (alias, selection) => {
|
|
1171
1170
|
const queryBuilder = this;
|
|
1172
1171
|
const as = (qb) => {
|
|
1173
1172
|
if (typeof qb === "function") qb = qb(queryBuilder);
|
|
1174
|
-
return new Proxy(new
|
|
1173
|
+
return new Proxy(new require_cli_main.WithSubquery(qb.getSQL(), selection ?? ("getSelectedFields" in qb ? qb.getSelectedFields() ?? {} : {}), alias, true), new require_cli_main.SelectionProxyHandler({
|
|
1175
1174
|
alias,
|
|
1176
1175
|
sqlAliasedBehavior: "alias",
|
|
1177
1176
|
sqlBehavior: "error"
|
|
@@ -1232,16 +1231,16 @@ var SQLiteInsertBuilder = class {
|
|
|
1232
1231
|
this.dialect = dialect;
|
|
1233
1232
|
this.withList = withList;
|
|
1234
1233
|
}
|
|
1235
|
-
static [
|
|
1234
|
+
static [require_cli_main.entityKind] = "SQLiteInsertBuilder";
|
|
1236
1235
|
values(values) {
|
|
1237
1236
|
values = Array.isArray(values) ? values : [values];
|
|
1238
1237
|
if (values.length === 0) throw new Error("values() must be called with at least one value");
|
|
1239
1238
|
const mappedValues = values.map((entry) => {
|
|
1240
1239
|
const result = {};
|
|
1241
|
-
const cols = this.table[
|
|
1240
|
+
const cols = this.table[require_cli_main.Table.Symbol.Columns];
|
|
1242
1241
|
for (const colKey of Object.keys(entry)) {
|
|
1243
1242
|
const colValue = entry[colKey];
|
|
1244
|
-
result[colKey] =
|
|
1243
|
+
result[colKey] = require_cli_main.is(colValue, require_cli_main.SQL) ? colValue : new require_cli_main.Param(colValue, cols[colKey]);
|
|
1245
1244
|
}
|
|
1246
1245
|
return result;
|
|
1247
1246
|
});
|
|
@@ -1249,11 +1248,11 @@ var SQLiteInsertBuilder = class {
|
|
|
1249
1248
|
}
|
|
1250
1249
|
select(selectQuery) {
|
|
1251
1250
|
const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder()) : selectQuery;
|
|
1252
|
-
if (!
|
|
1251
|
+
if (!require_cli_main.is(select, require_cli_main.SQL) && !require_cli_main.haveSameKeys(this.table[require_cli_main.Columns], select._.selectedFields)) throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");
|
|
1253
1252
|
return new SQLiteInsertBase(this.table, select, this.session, this.dialect, this.withList, true);
|
|
1254
1253
|
}
|
|
1255
1254
|
};
|
|
1256
|
-
var SQLiteInsertBase = class extends
|
|
1255
|
+
var SQLiteInsertBase = class extends require_cli_main.QueryPromise {
|
|
1257
1256
|
constructor(table, values, session, dialect, withList, select) {
|
|
1258
1257
|
super();
|
|
1259
1258
|
this.session = session;
|
|
@@ -1265,11 +1264,11 @@ var SQLiteInsertBase = class extends require_cli.QueryPromise {
|
|
|
1265
1264
|
select
|
|
1266
1265
|
};
|
|
1267
1266
|
}
|
|
1268
|
-
static [
|
|
1267
|
+
static [require_cli_main.entityKind] = "SQLiteInsert";
|
|
1269
1268
|
/** @internal */
|
|
1270
1269
|
config;
|
|
1271
|
-
returning(fields = this.config.table[
|
|
1272
|
-
this.config.returning =
|
|
1270
|
+
returning(fields = this.config.table[require_cli_main.SQLiteTable.Symbol.Columns]) {
|
|
1271
|
+
this.config.returning = require_cli_main.orderSelectedFields(fields);
|
|
1273
1272
|
return this;
|
|
1274
1273
|
}
|
|
1275
1274
|
/**
|
|
@@ -1296,11 +1295,11 @@ var SQLiteInsertBase = class extends require_cli.QueryPromise {
|
|
|
1296
1295
|
*/
|
|
1297
1296
|
onConflictDoNothing(config = {}) {
|
|
1298
1297
|
if (!this.config.onConflict) this.config.onConflict = [];
|
|
1299
|
-
if (config.target === void 0) this.config.onConflict.push(
|
|
1298
|
+
if (config.target === void 0) this.config.onConflict.push(require_cli_main.sql` on conflict do nothing`);
|
|
1300
1299
|
else {
|
|
1301
|
-
const targetSql = Array.isArray(config.target) ?
|
|
1302
|
-
const whereSql = config.where ?
|
|
1303
|
-
this.config.onConflict.push(
|
|
1300
|
+
const targetSql = Array.isArray(config.target) ? require_cli_main.sql`${config.target}` : require_cli_main.sql`${[config.target]}`;
|
|
1301
|
+
const whereSql = config.where ? require_cli_main.sql` where ${config.where}` : require_cli_main.sql``;
|
|
1302
|
+
this.config.onConflict.push(require_cli_main.sql` on conflict ${targetSql} do nothing${whereSql}`);
|
|
1304
1303
|
}
|
|
1305
1304
|
return this;
|
|
1306
1305
|
}
|
|
@@ -1336,12 +1335,12 @@ var SQLiteInsertBase = class extends require_cli.QueryPromise {
|
|
|
1336
1335
|
onConflictDoUpdate(config) {
|
|
1337
1336
|
if (config.where && (config.targetWhere || config.setWhere)) throw new Error("You cannot use both \"where\" and \"targetWhere\"/\"setWhere\" at the same time - \"where\" is deprecated, use \"targetWhere\" or \"setWhere\" instead.");
|
|
1338
1337
|
if (!this.config.onConflict) this.config.onConflict = [];
|
|
1339
|
-
const whereSql = config.where ?
|
|
1340
|
-
const targetWhereSql = config.targetWhere ?
|
|
1341
|
-
const setWhereSql = config.setWhere ?
|
|
1342
|
-
const targetSql = Array.isArray(config.target) ?
|
|
1343
|
-
const setSql = this.dialect.buildUpdateSet(this.config.table,
|
|
1344
|
-
this.config.onConflict.push(
|
|
1338
|
+
const whereSql = config.where ? require_cli_main.sql` where ${config.where}` : void 0;
|
|
1339
|
+
const targetWhereSql = config.targetWhere ? require_cli_main.sql` where ${config.targetWhere}` : void 0;
|
|
1340
|
+
const setWhereSql = config.setWhere ? require_cli_main.sql` where ${config.setWhere}` : void 0;
|
|
1341
|
+
const targetSql = Array.isArray(config.target) ? require_cli_main.sql`${config.target}` : require_cli_main.sql`${[config.target]}`;
|
|
1342
|
+
const setSql = this.dialect.buildUpdateSet(this.config.table, require_cli_main.mapUpdateSet(this.config.table, config.set));
|
|
1343
|
+
this.config.onConflict.push(require_cli_main.sql` on conflict ${targetSql}${targetWhereSql} do update set ${setSql}${whereSql}${setWhereSql}`);
|
|
1345
1344
|
return this;
|
|
1346
1345
|
}
|
|
1347
1346
|
/** @internal */
|
|
@@ -1356,7 +1355,7 @@ var SQLiteInsertBase = class extends require_cli.QueryPromise {
|
|
|
1356
1355
|
_prepare(isOneTimeQuery = true) {
|
|
1357
1356
|
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true, void 0, {
|
|
1358
1357
|
type: "insert",
|
|
1359
|
-
tables:
|
|
1358
|
+
tables: require_cli_main.extractUsedTable(this.config.table)
|
|
1360
1359
|
});
|
|
1361
1360
|
}
|
|
1362
1361
|
prepare() {
|
|
@@ -1390,12 +1389,12 @@ var SQLiteUpdateBuilder = class {
|
|
|
1390
1389
|
this.dialect = dialect;
|
|
1391
1390
|
this.withList = withList;
|
|
1392
1391
|
}
|
|
1393
|
-
static [
|
|
1392
|
+
static [require_cli_main.entityKind] = "SQLiteUpdateBuilder";
|
|
1394
1393
|
set(values) {
|
|
1395
|
-
return new SQLiteUpdateBase(this.table,
|
|
1394
|
+
return new SQLiteUpdateBase(this.table, require_cli_main.mapUpdateSet(this.table, values), this.session, this.dialect, this.withList);
|
|
1396
1395
|
}
|
|
1397
1396
|
};
|
|
1398
|
-
var SQLiteUpdateBase = class extends
|
|
1397
|
+
var SQLiteUpdateBase = class extends require_cli_main.QueryPromise {
|
|
1399
1398
|
constructor(table, set, session, dialect, withList) {
|
|
1400
1399
|
super();
|
|
1401
1400
|
this.session = session;
|
|
@@ -1407,7 +1406,7 @@ var SQLiteUpdateBase = class extends require_cli.QueryPromise {
|
|
|
1407
1406
|
joins: []
|
|
1408
1407
|
};
|
|
1409
1408
|
}
|
|
1410
|
-
static [
|
|
1409
|
+
static [require_cli_main.entityKind] = "SQLiteUpdate";
|
|
1411
1410
|
/** @internal */
|
|
1412
1411
|
config;
|
|
1413
1412
|
from(source) {
|
|
@@ -1416,14 +1415,14 @@ var SQLiteUpdateBase = class extends require_cli.QueryPromise {
|
|
|
1416
1415
|
}
|
|
1417
1416
|
createJoin(joinType) {
|
|
1418
1417
|
return (table, on) => {
|
|
1419
|
-
const tableName =
|
|
1418
|
+
const tableName = require_cli_main.getTableLikeName(table);
|
|
1420
1419
|
if (typeof tableName === "string" && this.config.joins.some((join) => join.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
1421
1420
|
if (typeof on === "function") {
|
|
1422
|
-
const from = this.config.from ?
|
|
1423
|
-
on = on(new Proxy(this.config.table[
|
|
1421
|
+
const from = this.config.from ? require_cli_main.is(table, require_cli_main.SQLiteTable) ? table[require_cli_main.Table.Symbol.Columns] : require_cli_main.is(table, require_cli_main.Subquery) ? table._.selectedFields : require_cli_main.is(table, SQLiteViewBase) ? table[require_cli_main.ViewBaseConfig].selectedFields : void 0 : void 0;
|
|
1422
|
+
on = on(new Proxy(this.config.table[require_cli_main.Table.Symbol.Columns], new require_cli_main.SelectionProxyHandler({
|
|
1424
1423
|
sqlAliasedBehavior: "sql",
|
|
1425
1424
|
sqlBehavior: "sql"
|
|
1426
|
-
})), from && new Proxy(from, new
|
|
1425
|
+
})), from && new Proxy(from, new require_cli_main.SelectionProxyHandler({
|
|
1427
1426
|
sqlAliasedBehavior: "sql",
|
|
1428
1427
|
sqlBehavior: "sql"
|
|
1429
1428
|
})));
|
|
@@ -1480,7 +1479,7 @@ var SQLiteUpdateBase = class extends require_cli.QueryPromise {
|
|
|
1480
1479
|
}
|
|
1481
1480
|
orderBy(...columns) {
|
|
1482
1481
|
if (typeof columns[0] === "function") {
|
|
1483
|
-
const orderBy = columns[0](new Proxy(this.config.table[
|
|
1482
|
+
const orderBy = columns[0](new Proxy(this.config.table[require_cli_main.Table.Symbol.Columns], new require_cli_main.SelectionProxyHandler({
|
|
1484
1483
|
sqlAliasedBehavior: "alias",
|
|
1485
1484
|
sqlBehavior: "sql"
|
|
1486
1485
|
})));
|
|
@@ -1496,8 +1495,8 @@ var SQLiteUpdateBase = class extends require_cli.QueryPromise {
|
|
|
1496
1495
|
this.config.limit = limit;
|
|
1497
1496
|
return this;
|
|
1498
1497
|
}
|
|
1499
|
-
returning(fields = this.config.table[
|
|
1500
|
-
this.config.returning =
|
|
1498
|
+
returning(fields = this.config.table[require_cli_main.SQLiteTable.Symbol.Columns]) {
|
|
1499
|
+
this.config.returning = require_cli_main.orderSelectedFields(fields);
|
|
1501
1500
|
return this;
|
|
1502
1501
|
}
|
|
1503
1502
|
/** @internal */
|
|
@@ -1512,7 +1511,7 @@ var SQLiteUpdateBase = class extends require_cli.QueryPromise {
|
|
|
1512
1511
|
_prepare(isOneTimeQuery = true) {
|
|
1513
1512
|
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](this.dialect.sqlToQuery(this.getSQL()), this.config.returning, this.config.returning ? "all" : "run", true, void 0, {
|
|
1514
1513
|
type: "insert",
|
|
1515
|
-
tables:
|
|
1514
|
+
tables: require_cli_main.extractUsedTable(this.config.table)
|
|
1516
1515
|
});
|
|
1517
1516
|
}
|
|
1518
1517
|
prepare() {
|
|
@@ -1539,7 +1538,7 @@ var SQLiteUpdateBase = class extends require_cli.QueryPromise {
|
|
|
1539
1538
|
};
|
|
1540
1539
|
//#endregion
|
|
1541
1540
|
//#region node_modules/drizzle-orm/sqlite-core/query-builders/count.js
|
|
1542
|
-
var SQLiteCountBuilder = class SQLiteCountBuilder extends
|
|
1541
|
+
var SQLiteCountBuilder = class SQLiteCountBuilder extends require_cli_main.SQL {
|
|
1543
1542
|
constructor(params) {
|
|
1544
1543
|
super(SQLiteCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
|
|
1545
1544
|
this.params = params;
|
|
@@ -1547,14 +1546,14 @@ var SQLiteCountBuilder = class SQLiteCountBuilder extends require_cli.SQL {
|
|
|
1547
1546
|
this.sql = SQLiteCountBuilder.buildCount(params.source, params.filters);
|
|
1548
1547
|
}
|
|
1549
1548
|
sql;
|
|
1550
|
-
static [
|
|
1549
|
+
static [require_cli_main.entityKind] = "SQLiteCountBuilderAsync";
|
|
1551
1550
|
[Symbol.toStringTag] = "SQLiteCountBuilderAsync";
|
|
1552
1551
|
session;
|
|
1553
1552
|
static buildEmbeddedCount(source, filters) {
|
|
1554
|
-
return
|
|
1553
|
+
return require_cli_main.sql`(select count(*) from ${source}${require_cli_main.sql.raw(" where ").if(filters)}${filters})`;
|
|
1555
1554
|
}
|
|
1556
1555
|
static buildCount(source, filters) {
|
|
1557
|
-
return
|
|
1556
|
+
return require_cli_main.sql`select count(*) from ${source}${require_cli_main.sql.raw(" where ").if(filters)}${filters}`;
|
|
1558
1557
|
}
|
|
1559
1558
|
then(onfulfilled, onrejected) {
|
|
1560
1559
|
return Promise.resolve(this.session.count(this.sql)).then(onfulfilled, onrejected);
|
|
@@ -1585,7 +1584,7 @@ var RelationalQueryBuilder = class {
|
|
|
1585
1584
|
this.dialect = dialect;
|
|
1586
1585
|
this.session = session;
|
|
1587
1586
|
}
|
|
1588
|
-
static [
|
|
1587
|
+
static [require_cli_main.entityKind] = "SQLiteAsyncRelationalQueryBuilder";
|
|
1589
1588
|
findMany(config) {
|
|
1590
1589
|
return this.mode === "sync" ? new SQLiteSyncRelationalQuery(this.fullSchema, this.schema, this.tableNamesMap, this.table, this.tableConfig, this.dialect, this.session, config ? config : {}, "many") : new SQLiteRelationalQuery(this.fullSchema, this.schema, this.tableNamesMap, this.table, this.tableConfig, this.dialect, this.session, config ? config : {}, "many");
|
|
1591
1590
|
}
|
|
@@ -1599,7 +1598,7 @@ var RelationalQueryBuilder = class {
|
|
|
1599
1598
|
} : { limit: 1 }, "first");
|
|
1600
1599
|
}
|
|
1601
1600
|
};
|
|
1602
|
-
var SQLiteRelationalQuery = class extends
|
|
1601
|
+
var SQLiteRelationalQuery = class extends require_cli_main.QueryPromise {
|
|
1603
1602
|
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, mode) {
|
|
1604
1603
|
super();
|
|
1605
1604
|
this.fullSchema = fullSchema;
|
|
@@ -1612,7 +1611,7 @@ var SQLiteRelationalQuery = class extends require_cli.QueryPromise {
|
|
|
1612
1611
|
this.config = config;
|
|
1613
1612
|
this.mode = mode;
|
|
1614
1613
|
}
|
|
1615
|
-
static [
|
|
1614
|
+
static [require_cli_main.entityKind] = "SQLiteAsyncRelationalQuery";
|
|
1616
1615
|
/** @internal */
|
|
1617
1616
|
mode;
|
|
1618
1617
|
/** @internal */
|
|
@@ -1631,7 +1630,7 @@ var SQLiteRelationalQuery = class extends require_cli.QueryPromise {
|
|
|
1631
1630
|
_prepare(isOneTimeQuery = false) {
|
|
1632
1631
|
const { query, builtQuery } = this._toSQL();
|
|
1633
1632
|
return this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](builtQuery, void 0, this.mode === "first" ? "get" : "all", true, (rawRows, mapColumnValue) => {
|
|
1634
|
-
const rows = rawRows.map((row) =>
|
|
1633
|
+
const rows = rawRows.map((row) => require_cli_main.mapRelationalRow(this.schema, this.tableConfig, row, query.selection, mapColumnValue));
|
|
1635
1634
|
if (this.mode === "first") return rows[0];
|
|
1636
1635
|
return rows;
|
|
1637
1636
|
});
|
|
@@ -1667,14 +1666,14 @@ var SQLiteRelationalQuery = class extends require_cli.QueryPromise {
|
|
|
1667
1666
|
}
|
|
1668
1667
|
};
|
|
1669
1668
|
var SQLiteSyncRelationalQuery = class extends SQLiteRelationalQuery {
|
|
1670
|
-
static [
|
|
1669
|
+
static [require_cli_main.entityKind] = "SQLiteSyncRelationalQuery";
|
|
1671
1670
|
sync() {
|
|
1672
1671
|
return this.executeRaw();
|
|
1673
1672
|
}
|
|
1674
1673
|
};
|
|
1675
1674
|
//#endregion
|
|
1676
1675
|
//#region node_modules/drizzle-orm/sqlite-core/query-builders/raw.js
|
|
1677
|
-
var SQLiteRaw = class extends
|
|
1676
|
+
var SQLiteRaw = class extends require_cli_main.QueryPromise {
|
|
1678
1677
|
constructor(execute, getSQL, action, dialect, mapBatchResult) {
|
|
1679
1678
|
super();
|
|
1680
1679
|
this.execute = execute;
|
|
@@ -1683,7 +1682,7 @@ var SQLiteRaw = class extends require_cli.QueryPromise {
|
|
|
1683
1682
|
this.mapBatchResult = mapBatchResult;
|
|
1684
1683
|
this.config = { action };
|
|
1685
1684
|
}
|
|
1686
|
-
static [
|
|
1685
|
+
static [require_cli_main.entityKind] = "SQLiteRaw";
|
|
1687
1686
|
/** @internal */
|
|
1688
1687
|
config;
|
|
1689
1688
|
getQuery() {
|
|
@@ -1724,7 +1723,7 @@ var BaseSQLiteDatabase = class {
|
|
|
1724
1723
|
if (this._.schema) for (const [tableName, columns] of Object.entries(this._.schema)) query[tableName] = new RelationalQueryBuilder(resultKind, schema.fullSchema, this._.schema, this._.tableNamesMap, schema.fullSchema[tableName], columns, dialect, session);
|
|
1725
1724
|
this.$cache = { invalidate: async (_params) => {} };
|
|
1726
1725
|
}
|
|
1727
|
-
static [
|
|
1726
|
+
static [require_cli_main.entityKind] = "BaseSQLiteDatabase";
|
|
1728
1727
|
query;
|
|
1729
1728
|
/**
|
|
1730
1729
|
* Creates a subquery that defines a temporary named result set as a CTE.
|
|
@@ -1762,7 +1761,7 @@ var BaseSQLiteDatabase = class {
|
|
|
1762
1761
|
const self = this;
|
|
1763
1762
|
const as = (qb) => {
|
|
1764
1763
|
if (typeof qb === "function") qb = qb(new QueryBuilder(self.dialect));
|
|
1765
|
-
return new Proxy(new
|
|
1764
|
+
return new Proxy(new require_cli_main.WithSubquery(qb.getSQL(), selection ?? ("getSelectedFields" in qb ? qb.getSelectedFields() ?? {} : {}), alias, true), new require_cli_main.SelectionProxyHandler({
|
|
1766
1765
|
alias,
|
|
1767
1766
|
sqlAliasedBehavior: "alias",
|
|
1768
1767
|
sqlBehavior: "error"
|
|
@@ -1933,22 +1932,22 @@ var BaseSQLiteDatabase = class {
|
|
|
1933
1932
|
return new SQLiteDeleteBase(from, this.session, this.dialect);
|
|
1934
1933
|
}
|
|
1935
1934
|
run(query) {
|
|
1936
|
-
const sequel = typeof query === "string" ?
|
|
1935
|
+
const sequel = typeof query === "string" ? require_cli_main.sql.raw(query) : query.getSQL();
|
|
1937
1936
|
if (this.resultKind === "async") return new SQLiteRaw(async () => this.session.run(sequel), () => sequel, "run", this.dialect, this.session.extractRawRunValueFromBatchResult.bind(this.session));
|
|
1938
1937
|
return this.session.run(sequel);
|
|
1939
1938
|
}
|
|
1940
1939
|
all(query) {
|
|
1941
|
-
const sequel = typeof query === "string" ?
|
|
1940
|
+
const sequel = typeof query === "string" ? require_cli_main.sql.raw(query) : query.getSQL();
|
|
1942
1941
|
if (this.resultKind === "async") return new SQLiteRaw(async () => this.session.all(sequel), () => sequel, "all", this.dialect, this.session.extractRawAllValueFromBatchResult.bind(this.session));
|
|
1943
1942
|
return this.session.all(sequel);
|
|
1944
1943
|
}
|
|
1945
1944
|
get(query) {
|
|
1946
|
-
const sequel = typeof query === "string" ?
|
|
1945
|
+
const sequel = typeof query === "string" ? require_cli_main.sql.raw(query) : query.getSQL();
|
|
1947
1946
|
if (this.resultKind === "async") return new SQLiteRaw(async () => this.session.get(sequel), () => sequel, "get", this.dialect, this.session.extractRawGetValueFromBatchResult.bind(this.session));
|
|
1948
1947
|
return this.session.get(sequel);
|
|
1949
1948
|
}
|
|
1950
1949
|
values(query) {
|
|
1951
|
-
const sequel = typeof query === "string" ?
|
|
1950
|
+
const sequel = typeof query === "string" ? require_cli_main.sql.raw(query) : query.getSQL();
|
|
1952
1951
|
if (this.resultKind === "async") return new SQLiteRaw(async () => this.session.values(sequel), () => sequel, "values", this.dialect, this.session.extractRawValuesValueFromBatchResult.bind(this.session));
|
|
1953
1952
|
return this.session.values(sequel);
|
|
1954
1953
|
}
|
|
@@ -1958,12 +1957,12 @@ var BaseSQLiteDatabase = class {
|
|
|
1958
1957
|
};
|
|
1959
1958
|
//#endregion
|
|
1960
1959
|
//#region node_modules/drizzle-orm/sqlite-core/session.js
|
|
1961
|
-
var ExecuteResultSync = class extends
|
|
1960
|
+
var ExecuteResultSync = class extends require_cli_main.QueryPromise {
|
|
1962
1961
|
constructor(resultCb) {
|
|
1963
1962
|
super();
|
|
1964
1963
|
this.resultCb = resultCb;
|
|
1965
1964
|
}
|
|
1966
|
-
static [
|
|
1965
|
+
static [require_cli_main.entityKind] = "ExecuteResultSync";
|
|
1967
1966
|
async execute() {
|
|
1968
1967
|
return this.resultCb();
|
|
1969
1968
|
}
|
|
@@ -1985,42 +1984,42 @@ var SQLitePreparedQuery = class {
|
|
|
1985
1984
|
};
|
|
1986
1985
|
if (!this.cacheConfig?.enable) this.cacheConfig = void 0;
|
|
1987
1986
|
}
|
|
1988
|
-
static [
|
|
1987
|
+
static [require_cli_main.entityKind] = "PreparedQuery";
|
|
1989
1988
|
/** @internal */
|
|
1990
1989
|
joinsNotNullableMap;
|
|
1991
1990
|
/** @internal */
|
|
1992
1991
|
async queryWithCache(queryString, params, query) {
|
|
1993
|
-
if (this.cache === void 0 ||
|
|
1992
|
+
if (this.cache === void 0 || require_cli_main.is(this.cache, require_cli_main.NoopCache) || this.queryMetadata === void 0) try {
|
|
1994
1993
|
return await query();
|
|
1995
1994
|
} catch (e) {
|
|
1996
|
-
throw new
|
|
1995
|
+
throw new require_cli_main.DrizzleQueryError(queryString, params, e);
|
|
1997
1996
|
}
|
|
1998
1997
|
if (this.cacheConfig && !this.cacheConfig.enable) try {
|
|
1999
1998
|
return await query();
|
|
2000
1999
|
} catch (e) {
|
|
2001
|
-
throw new
|
|
2000
|
+
throw new require_cli_main.DrizzleQueryError(queryString, params, e);
|
|
2002
2001
|
}
|
|
2003
2002
|
if ((this.queryMetadata.type === "insert" || this.queryMetadata.type === "update" || this.queryMetadata.type === "delete") && this.queryMetadata.tables.length > 0) try {
|
|
2004
2003
|
const [res] = await Promise.all([query(), this.cache.onMutate({ tables: this.queryMetadata.tables })]);
|
|
2005
2004
|
return res;
|
|
2006
2005
|
} catch (e) {
|
|
2007
|
-
throw new
|
|
2006
|
+
throw new require_cli_main.DrizzleQueryError(queryString, params, e);
|
|
2008
2007
|
}
|
|
2009
2008
|
if (!this.cacheConfig) try {
|
|
2010
2009
|
return await query();
|
|
2011
2010
|
} catch (e) {
|
|
2012
|
-
throw new
|
|
2011
|
+
throw new require_cli_main.DrizzleQueryError(queryString, params, e);
|
|
2013
2012
|
}
|
|
2014
2013
|
if (this.queryMetadata.type === "select") {
|
|
2015
|
-
const fromCache = await this.cache.get(this.cacheConfig.tag ?? await
|
|
2014
|
+
const fromCache = await this.cache.get(this.cacheConfig.tag ?? await require_cli_main.hashQuery(queryString, params), this.queryMetadata.tables, this.cacheConfig.tag !== void 0, this.cacheConfig.autoInvalidate);
|
|
2016
2015
|
if (fromCache === void 0) {
|
|
2017
2016
|
let result;
|
|
2018
2017
|
try {
|
|
2019
2018
|
result = await query();
|
|
2020
2019
|
} catch (e) {
|
|
2021
|
-
throw new
|
|
2020
|
+
throw new require_cli_main.DrizzleQueryError(queryString, params, e);
|
|
2022
2021
|
}
|
|
2023
|
-
await this.cache.put(this.cacheConfig.tag ?? await
|
|
2022
|
+
await this.cache.put(this.cacheConfig.tag ?? await require_cli_main.hashQuery(queryString, params), result, this.cacheConfig.autoInvalidate ? this.queryMetadata.tables : [], this.cacheConfig.tag !== void 0, this.cacheConfig.config);
|
|
2024
2023
|
return result;
|
|
2025
2024
|
}
|
|
2026
2025
|
return fromCache;
|
|
@@ -2028,7 +2027,7 @@ var SQLitePreparedQuery = class {
|
|
|
2028
2027
|
try {
|
|
2029
2028
|
return await query();
|
|
2030
2029
|
} catch (e) {
|
|
2031
|
-
throw new
|
|
2030
|
+
throw new require_cli_main.DrizzleQueryError(queryString, params, e);
|
|
2032
2031
|
}
|
|
2033
2032
|
}
|
|
2034
2033
|
getQuery() {
|
|
@@ -2059,7 +2058,7 @@ var SQLiteSession = class {
|
|
|
2059
2058
|
constructor(dialect) {
|
|
2060
2059
|
this.dialect = dialect;
|
|
2061
2060
|
}
|
|
2062
|
-
static [
|
|
2061
|
+
static [require_cli_main.entityKind] = "SQLiteSession";
|
|
2063
2062
|
prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
2064
2063
|
return this.prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig);
|
|
2065
2064
|
}
|
|
@@ -2068,7 +2067,7 @@ var SQLiteSession = class {
|
|
|
2068
2067
|
try {
|
|
2069
2068
|
return this.prepareOneTimeQuery(staticQuery, void 0, "run", false).run();
|
|
2070
2069
|
} catch (err) {
|
|
2071
|
-
throw new
|
|
2070
|
+
throw new require_cli_main.DrizzleError({
|
|
2072
2071
|
cause: err,
|
|
2073
2072
|
message: `Failed to run the query '${staticQuery.sql}'`
|
|
2074
2073
|
});
|
|
@@ -2109,9 +2108,9 @@ var SQLiteTransaction = class extends BaseSQLiteDatabase {
|
|
|
2109
2108
|
this.schema = schema;
|
|
2110
2109
|
this.nestedIndex = nestedIndex;
|
|
2111
2110
|
}
|
|
2112
|
-
static [
|
|
2111
|
+
static [require_cli_main.entityKind] = "SQLiteTransaction";
|
|
2113
2112
|
rollback() {
|
|
2114
|
-
throw new
|
|
2113
|
+
throw new require_cli_main.TransactionRollbackError();
|
|
2115
2114
|
}
|
|
2116
2115
|
};
|
|
2117
2116
|
//#endregion
|
|
@@ -2121,10 +2120,10 @@ var BetterSQLiteSession = class extends SQLiteSession {
|
|
|
2121
2120
|
super(dialect);
|
|
2122
2121
|
this.client = client;
|
|
2123
2122
|
this.schema = schema;
|
|
2124
|
-
this.logger = options.logger ?? new
|
|
2125
|
-
this.cache = options.cache ?? new
|
|
2123
|
+
this.logger = options.logger ?? new require_cli_main.NoopLogger();
|
|
2124
|
+
this.cache = options.cache ?? new require_cli_main.NoopCache();
|
|
2126
2125
|
}
|
|
2127
|
-
static [
|
|
2126
|
+
static [require_cli_main.entityKind] = "BetterSQLiteSession";
|
|
2128
2127
|
logger;
|
|
2129
2128
|
cache;
|
|
2130
2129
|
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
@@ -2136,17 +2135,17 @@ var BetterSQLiteSession = class extends SQLiteSession {
|
|
|
2136
2135
|
}
|
|
2137
2136
|
};
|
|
2138
2137
|
var BetterSQLiteTransaction = class BetterSQLiteTransaction extends SQLiteTransaction {
|
|
2139
|
-
static [
|
|
2138
|
+
static [require_cli_main.entityKind] = "BetterSQLiteTransaction";
|
|
2140
2139
|
transaction(transaction) {
|
|
2141
2140
|
const savepointName = `sp${this.nestedIndex}`;
|
|
2142
2141
|
const tx = new BetterSQLiteTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
2143
|
-
this.session.run(
|
|
2142
|
+
this.session.run(require_cli_main.sql.raw(`savepoint ${savepointName}`));
|
|
2144
2143
|
try {
|
|
2145
2144
|
const result = transaction(tx);
|
|
2146
|
-
this.session.run(
|
|
2145
|
+
this.session.run(require_cli_main.sql.raw(`release savepoint ${savepointName}`));
|
|
2147
2146
|
return result;
|
|
2148
2147
|
} catch (err) {
|
|
2149
|
-
this.session.run(
|
|
2148
|
+
this.session.run(require_cli_main.sql.raw(`rollback to savepoint ${savepointName}`));
|
|
2150
2149
|
throw err;
|
|
2151
2150
|
}
|
|
2152
2151
|
}
|
|
@@ -2160,35 +2159,35 @@ var PreparedQuery = class extends SQLitePreparedQuery {
|
|
|
2160
2159
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
2161
2160
|
this.customResultMapper = customResultMapper;
|
|
2162
2161
|
}
|
|
2163
|
-
static [
|
|
2162
|
+
static [require_cli_main.entityKind] = "BetterSQLitePreparedQuery";
|
|
2164
2163
|
run(placeholderValues) {
|
|
2165
|
-
const params =
|
|
2164
|
+
const params = require_cli_main.fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
2166
2165
|
this.logger.logQuery(this.query.sql, params);
|
|
2167
2166
|
return this.stmt.run(...params);
|
|
2168
2167
|
}
|
|
2169
2168
|
all(placeholderValues) {
|
|
2170
2169
|
const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this;
|
|
2171
2170
|
if (!fields && !customResultMapper) {
|
|
2172
|
-
const params =
|
|
2171
|
+
const params = require_cli_main.fillPlaceholders(query.params, placeholderValues ?? {});
|
|
2173
2172
|
logger.logQuery(query.sql, params);
|
|
2174
2173
|
return stmt.all(...params);
|
|
2175
2174
|
}
|
|
2176
2175
|
const rows = this.values(placeholderValues);
|
|
2177
2176
|
if (customResultMapper) return customResultMapper(rows);
|
|
2178
|
-
return rows.map((row) =>
|
|
2177
|
+
return rows.map((row) => require_cli_main.mapResultRow(fields, row, joinsNotNullableMap));
|
|
2179
2178
|
}
|
|
2180
2179
|
get(placeholderValues) {
|
|
2181
|
-
const params =
|
|
2180
|
+
const params = require_cli_main.fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
2182
2181
|
this.logger.logQuery(this.query.sql, params);
|
|
2183
2182
|
const { fields, stmt, joinsNotNullableMap, customResultMapper } = this;
|
|
2184
2183
|
if (!fields && !customResultMapper) return stmt.get(...params);
|
|
2185
2184
|
const row = stmt.raw().get(...params);
|
|
2186
2185
|
if (!row) return;
|
|
2187
2186
|
if (customResultMapper) return customResultMapper([row]);
|
|
2188
|
-
return
|
|
2187
|
+
return require_cli_main.mapResultRow(fields, row, joinsNotNullableMap);
|
|
2189
2188
|
}
|
|
2190
2189
|
values(placeholderValues) {
|
|
2191
|
-
const params =
|
|
2190
|
+
const params = require_cli_main.fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
2192
2191
|
this.logger.logQuery(this.query.sql, params);
|
|
2193
2192
|
return this.stmt.raw().all(...params);
|
|
2194
2193
|
}
|
|
@@ -2200,16 +2199,16 @@ var PreparedQuery = class extends SQLitePreparedQuery {
|
|
|
2200
2199
|
//#endregion
|
|
2201
2200
|
//#region node_modules/drizzle-orm/better-sqlite3/driver.js
|
|
2202
2201
|
var BetterSQLite3Database = class extends BaseSQLiteDatabase {
|
|
2203
|
-
static [
|
|
2202
|
+
static [require_cli_main.entityKind] = "BetterSQLite3Database";
|
|
2204
2203
|
};
|
|
2205
2204
|
function construct(client, config = {}) {
|
|
2206
2205
|
const dialect = new SQLiteSyncDialect({ casing: config.casing });
|
|
2207
2206
|
let logger;
|
|
2208
|
-
if (config.logger === true) logger = new
|
|
2207
|
+
if (config.logger === true) logger = new require_cli_main.DefaultLogger();
|
|
2209
2208
|
else if (config.logger !== false) logger = config.logger;
|
|
2210
2209
|
let schema;
|
|
2211
2210
|
if (config.schema) {
|
|
2212
|
-
const tablesConfig =
|
|
2211
|
+
const tablesConfig = require_cli_main.extractTablesRelationalConfig(config.schema, require_cli_main.createTableRelationsHelpers);
|
|
2213
2212
|
schema = {
|
|
2214
2213
|
fullSchema: config.schema,
|
|
2215
2214
|
schema: tablesConfig.tables,
|
|
@@ -2222,7 +2221,7 @@ function construct(client, config = {}) {
|
|
|
2222
2221
|
}
|
|
2223
2222
|
function drizzle(...params) {
|
|
2224
2223
|
if (params[0] === void 0 || typeof params[0] === "string") return construct(params[0] === void 0 ? new better_sqlite3.default() : new better_sqlite3.default(params[0]), params[1]);
|
|
2225
|
-
if (
|
|
2224
|
+
if (require_cli_main.isConfig(params[0])) {
|
|
2226
2225
|
const { connection, client, ...drizzleConfig } = params[0];
|
|
2227
2226
|
if (client) return construct(client, drizzleConfig);
|
|
2228
2227
|
if (typeof connection === "object") {
|
|
@@ -2250,5 +2249,3 @@ Object.defineProperty(exports, "drizzle", {
|
|
|
2250
2249
|
return drizzle;
|
|
2251
2250
|
}
|
|
2252
2251
|
});
|
|
2253
|
-
|
|
2254
|
-
//# sourceMappingURL=better-sqlite3-fU3G4xnX.cjs.map
|