@gscdump/cli 0.1.3 → 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/dist/index.mjs +693 -1445
- package/package.json +5 -9
- package/dist/_chunks/libs/drizzle-orm.mjs +0 -1043
|
@@ -1,1043 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/entity.js
|
|
2
|
-
const entityKind = Symbol.for("drizzle:entityKind");
|
|
3
|
-
const hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
4
|
-
function is(value, type) {
|
|
5
|
-
if (!value || typeof value !== "object") return false;
|
|
6
|
-
if (value instanceof type) return true;
|
|
7
|
-
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) throw new Error(`Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);
|
|
8
|
-
let cls = Object.getPrototypeOf(value).constructor;
|
|
9
|
-
if (cls) while (cls) {
|
|
10
|
-
if (entityKind in cls && cls[entityKind] === type[entityKind]) return true;
|
|
11
|
-
cls = Object.getPrototypeOf(cls);
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/column.js
|
|
18
|
-
var Column = class {
|
|
19
|
-
constructor(table, config) {
|
|
20
|
-
this.table = table;
|
|
21
|
-
this.config = config;
|
|
22
|
-
this.name = config.name;
|
|
23
|
-
this.keyAsName = config.keyAsName;
|
|
24
|
-
this.notNull = config.notNull;
|
|
25
|
-
this.default = config.default;
|
|
26
|
-
this.defaultFn = config.defaultFn;
|
|
27
|
-
this.onUpdateFn = config.onUpdateFn;
|
|
28
|
-
this.hasDefault = config.hasDefault;
|
|
29
|
-
this.primary = config.primaryKey;
|
|
30
|
-
this.isUnique = config.isUnique;
|
|
31
|
-
this.uniqueName = config.uniqueName;
|
|
32
|
-
this.uniqueType = config.uniqueType;
|
|
33
|
-
this.dataType = config.dataType;
|
|
34
|
-
this.columnType = config.columnType;
|
|
35
|
-
this.generated = config.generated;
|
|
36
|
-
this.generatedIdentity = config.generatedIdentity;
|
|
37
|
-
}
|
|
38
|
-
static [entityKind] = "Column";
|
|
39
|
-
name;
|
|
40
|
-
keyAsName;
|
|
41
|
-
primary;
|
|
42
|
-
notNull;
|
|
43
|
-
default;
|
|
44
|
-
defaultFn;
|
|
45
|
-
onUpdateFn;
|
|
46
|
-
hasDefault;
|
|
47
|
-
isUnique;
|
|
48
|
-
uniqueName;
|
|
49
|
-
uniqueType;
|
|
50
|
-
dataType;
|
|
51
|
-
columnType;
|
|
52
|
-
enumValues = void 0;
|
|
53
|
-
generated = void 0;
|
|
54
|
-
generatedIdentity = void 0;
|
|
55
|
-
config;
|
|
56
|
-
mapFromDriverValue(value) {
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
mapToDriverValue(value) {
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
shouldDisableInsert() {
|
|
63
|
-
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/column-builder.js
|
|
69
|
-
var ColumnBuilder = class {
|
|
70
|
-
static [entityKind] = "ColumnBuilder";
|
|
71
|
-
config;
|
|
72
|
-
constructor(name, dataType, columnType) {
|
|
73
|
-
this.config = {
|
|
74
|
-
name,
|
|
75
|
-
keyAsName: name === "",
|
|
76
|
-
notNull: false,
|
|
77
|
-
default: void 0,
|
|
78
|
-
hasDefault: false,
|
|
79
|
-
primaryKey: false,
|
|
80
|
-
isUnique: false,
|
|
81
|
-
uniqueName: void 0,
|
|
82
|
-
uniqueType: void 0,
|
|
83
|
-
dataType,
|
|
84
|
-
columnType,
|
|
85
|
-
generated: void 0
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```ts
|
|
93
|
-
* const users = pgTable('users', {
|
|
94
|
-
* id: integer('id').$type<UserId>().primaryKey(),
|
|
95
|
-
* details: json('details').$type<UserDetails>().notNull(),
|
|
96
|
-
* });
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
$type() {
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Adds a `not null` clause to the column definition.
|
|
104
|
-
*
|
|
105
|
-
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
|
|
106
|
-
*/
|
|
107
|
-
notNull() {
|
|
108
|
-
this.config.notNull = true;
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Adds a `default <value>` clause to the column definition.
|
|
113
|
-
*
|
|
114
|
-
* Affects the `insert` model of the table - columns *with* `default` are optional on insert.
|
|
115
|
-
*
|
|
116
|
-
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
117
|
-
*/
|
|
118
|
-
default(value) {
|
|
119
|
-
this.config.default = value;
|
|
120
|
-
this.config.hasDefault = true;
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Adds a dynamic default value to the column.
|
|
125
|
-
* The function will be called when the row is inserted, and the returned value will be used as the column value.
|
|
126
|
-
*
|
|
127
|
-
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
128
|
-
*/
|
|
129
|
-
$defaultFn(fn) {
|
|
130
|
-
this.config.defaultFn = fn;
|
|
131
|
-
this.config.hasDefault = true;
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Alias for {@link $defaultFn}.
|
|
136
|
-
*/
|
|
137
|
-
$default = this.$defaultFn;
|
|
138
|
-
/**
|
|
139
|
-
* Adds a dynamic update value to the column.
|
|
140
|
-
* The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
|
|
141
|
-
* If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
|
|
142
|
-
*
|
|
143
|
-
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
144
|
-
*/
|
|
145
|
-
$onUpdateFn(fn) {
|
|
146
|
-
this.config.onUpdateFn = fn;
|
|
147
|
-
this.config.hasDefault = true;
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Alias for {@link $onUpdateFn}.
|
|
152
|
-
*/
|
|
153
|
-
$onUpdate = this.$onUpdateFn;
|
|
154
|
-
/**
|
|
155
|
-
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
156
|
-
*
|
|
157
|
-
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
|
|
158
|
-
*/
|
|
159
|
-
primaryKey() {
|
|
160
|
-
this.config.primaryKey = true;
|
|
161
|
-
this.config.notNull = true;
|
|
162
|
-
return this;
|
|
163
|
-
}
|
|
164
|
-
/** @internal Sets the name of the column to the key within the table definition if a name was not given. */
|
|
165
|
-
setName(name) {
|
|
166
|
-
if (this.config.name !== "") return;
|
|
167
|
-
this.config.name = name;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/table.utils.js
|
|
173
|
-
const TableName = Symbol.for("drizzle:Name");
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/pg-core/foreign-keys.js
|
|
177
|
-
var ForeignKeyBuilder = class {
|
|
178
|
-
static [entityKind] = "PgForeignKeyBuilder";
|
|
179
|
-
/** @internal */
|
|
180
|
-
reference;
|
|
181
|
-
/** @internal */
|
|
182
|
-
_onUpdate = "no action";
|
|
183
|
-
/** @internal */
|
|
184
|
-
_onDelete = "no action";
|
|
185
|
-
constructor(config, actions) {
|
|
186
|
-
this.reference = () => {
|
|
187
|
-
const { name, columns, foreignColumns } = config();
|
|
188
|
-
return {
|
|
189
|
-
name,
|
|
190
|
-
columns,
|
|
191
|
-
foreignTable: foreignColumns[0].table,
|
|
192
|
-
foreignColumns
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
if (actions) {
|
|
196
|
-
this._onUpdate = actions.onUpdate;
|
|
197
|
-
this._onDelete = actions.onDelete;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
onUpdate(action) {
|
|
201
|
-
this._onUpdate = action === void 0 ? "no action" : action;
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
onDelete(action) {
|
|
205
|
-
this._onDelete = action === void 0 ? "no action" : action;
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
/** @internal */
|
|
209
|
-
build(table) {
|
|
210
|
-
return new ForeignKey(table, this);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
var ForeignKey = class {
|
|
214
|
-
constructor(table, builder) {
|
|
215
|
-
this.table = table;
|
|
216
|
-
this.reference = builder.reference;
|
|
217
|
-
this.onUpdate = builder._onUpdate;
|
|
218
|
-
this.onDelete = builder._onDelete;
|
|
219
|
-
}
|
|
220
|
-
static [entityKind] = "PgForeignKey";
|
|
221
|
-
reference;
|
|
222
|
-
onUpdate;
|
|
223
|
-
onDelete;
|
|
224
|
-
getName() {
|
|
225
|
-
const { name, columns, foreignColumns } = this.reference();
|
|
226
|
-
const columnNames = columns.map((column) => column.name);
|
|
227
|
-
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
228
|
-
const chunks = [
|
|
229
|
-
this.table[TableName],
|
|
230
|
-
...columnNames,
|
|
231
|
-
foreignColumns[0].table[TableName],
|
|
232
|
-
...foreignColumnNames
|
|
233
|
-
];
|
|
234
|
-
return name ?? `${chunks.join("_")}_fk`;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/tracing-utils.js
|
|
240
|
-
function iife(fn, ...args) {
|
|
241
|
-
return fn(...args);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
246
|
-
function uniqueKeyName(table, columns) {
|
|
247
|
-
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
248
|
-
}
|
|
249
|
-
var UniqueConstraintBuilder = class {
|
|
250
|
-
constructor(columns, name) {
|
|
251
|
-
this.name = name;
|
|
252
|
-
this.columns = columns;
|
|
253
|
-
}
|
|
254
|
-
static [entityKind] = "PgUniqueConstraintBuilder";
|
|
255
|
-
/** @internal */
|
|
256
|
-
columns;
|
|
257
|
-
/** @internal */
|
|
258
|
-
nullsNotDistinctConfig = false;
|
|
259
|
-
nullsNotDistinct() {
|
|
260
|
-
this.nullsNotDistinctConfig = true;
|
|
261
|
-
return this;
|
|
262
|
-
}
|
|
263
|
-
/** @internal */
|
|
264
|
-
build(table) {
|
|
265
|
-
return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
var UniqueOnConstraintBuilder = class {
|
|
269
|
-
static [entityKind] = "PgUniqueOnConstraintBuilder";
|
|
270
|
-
/** @internal */
|
|
271
|
-
name;
|
|
272
|
-
constructor(name) {
|
|
273
|
-
this.name = name;
|
|
274
|
-
}
|
|
275
|
-
on(...columns) {
|
|
276
|
-
return new UniqueConstraintBuilder(columns, this.name);
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
var UniqueConstraint = class {
|
|
280
|
-
constructor(table, columns, nullsNotDistinct, name) {
|
|
281
|
-
this.table = table;
|
|
282
|
-
this.columns = columns;
|
|
283
|
-
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
|
284
|
-
this.nullsNotDistinct = nullsNotDistinct;
|
|
285
|
-
}
|
|
286
|
-
static [entityKind] = "PgUniqueConstraint";
|
|
287
|
-
columns;
|
|
288
|
-
name;
|
|
289
|
-
nullsNotDistinct = false;
|
|
290
|
-
getName() {
|
|
291
|
-
return this.name;
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
//#endregion
|
|
296
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/pg-core/utils/array.js
|
|
297
|
-
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
298
|
-
for (let i = startFrom; i < arrayString.length; i++) {
|
|
299
|
-
const char = arrayString[i];
|
|
300
|
-
if (char === "\\") {
|
|
301
|
-
i++;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
if (char === "\"") return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
|
|
305
|
-
if (inQuotes) continue;
|
|
306
|
-
if (char === "," || char === "}") return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
|
|
307
|
-
}
|
|
308
|
-
return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
|
|
309
|
-
}
|
|
310
|
-
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
311
|
-
const result = [];
|
|
312
|
-
let i = startFrom;
|
|
313
|
-
let lastCharIsComma = false;
|
|
314
|
-
while (i < arrayString.length) {
|
|
315
|
-
const char = arrayString[i];
|
|
316
|
-
if (char === ",") {
|
|
317
|
-
if (lastCharIsComma || i === startFrom) result.push("");
|
|
318
|
-
lastCharIsComma = true;
|
|
319
|
-
i++;
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
lastCharIsComma = false;
|
|
323
|
-
if (char === "\\") {
|
|
324
|
-
i += 2;
|
|
325
|
-
continue;
|
|
326
|
-
}
|
|
327
|
-
if (char === "\"") {
|
|
328
|
-
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
329
|
-
result.push(value2);
|
|
330
|
-
i = startFrom2;
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
if (char === "}") return [result, i + 1];
|
|
334
|
-
if (char === "{") {
|
|
335
|
-
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
336
|
-
result.push(value2);
|
|
337
|
-
i = startFrom2;
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
341
|
-
result.push(value);
|
|
342
|
-
i = newStartFrom;
|
|
343
|
-
}
|
|
344
|
-
return [result, i];
|
|
345
|
-
}
|
|
346
|
-
function parsePgArray(arrayString) {
|
|
347
|
-
const [result] = parsePgNestedArray(arrayString, 1);
|
|
348
|
-
return result;
|
|
349
|
-
}
|
|
350
|
-
function makePgArray(array) {
|
|
351
|
-
return `{${array.map((item) => {
|
|
352
|
-
if (Array.isArray(item)) return makePgArray(item);
|
|
353
|
-
if (typeof item === "string") return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
354
|
-
return `${item}`;
|
|
355
|
-
}).join(",")}}`;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
//#endregion
|
|
359
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/pg-core/columns/common.js
|
|
360
|
-
var PgColumnBuilder = class extends ColumnBuilder {
|
|
361
|
-
foreignKeyConfigs = [];
|
|
362
|
-
static [entityKind] = "PgColumnBuilder";
|
|
363
|
-
array(size) {
|
|
364
|
-
return new PgArrayBuilder(this.config.name, this, size);
|
|
365
|
-
}
|
|
366
|
-
references(ref, actions = {}) {
|
|
367
|
-
this.foreignKeyConfigs.push({
|
|
368
|
-
ref,
|
|
369
|
-
actions
|
|
370
|
-
});
|
|
371
|
-
return this;
|
|
372
|
-
}
|
|
373
|
-
unique(name, config) {
|
|
374
|
-
this.config.isUnique = true;
|
|
375
|
-
this.config.uniqueName = name;
|
|
376
|
-
this.config.uniqueType = config?.nulls;
|
|
377
|
-
return this;
|
|
378
|
-
}
|
|
379
|
-
generatedAlwaysAs(as) {
|
|
380
|
-
this.config.generated = {
|
|
381
|
-
as,
|
|
382
|
-
type: "always",
|
|
383
|
-
mode: "stored"
|
|
384
|
-
};
|
|
385
|
-
return this;
|
|
386
|
-
}
|
|
387
|
-
/** @internal */
|
|
388
|
-
buildForeignKeys(column, table) {
|
|
389
|
-
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
390
|
-
return iife((ref2, actions2) => {
|
|
391
|
-
const builder = new ForeignKeyBuilder(() => {
|
|
392
|
-
const foreignColumn = ref2();
|
|
393
|
-
return {
|
|
394
|
-
columns: [column],
|
|
395
|
-
foreignColumns: [foreignColumn]
|
|
396
|
-
};
|
|
397
|
-
});
|
|
398
|
-
if (actions2.onUpdate) builder.onUpdate(actions2.onUpdate);
|
|
399
|
-
if (actions2.onDelete) builder.onDelete(actions2.onDelete);
|
|
400
|
-
return builder.build(table);
|
|
401
|
-
}, ref, actions);
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
/** @internal */
|
|
405
|
-
buildExtraConfigColumn(table) {
|
|
406
|
-
return new ExtraConfigColumn(table, this.config);
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
var PgColumn = class extends Column {
|
|
410
|
-
constructor(table, config) {
|
|
411
|
-
if (!config.uniqueName) config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
412
|
-
super(table, config);
|
|
413
|
-
this.table = table;
|
|
414
|
-
}
|
|
415
|
-
static [entityKind] = "PgColumn";
|
|
416
|
-
};
|
|
417
|
-
var ExtraConfigColumn = class extends PgColumn {
|
|
418
|
-
static [entityKind] = "ExtraConfigColumn";
|
|
419
|
-
getSQLType() {
|
|
420
|
-
return this.getSQLType();
|
|
421
|
-
}
|
|
422
|
-
indexConfig = {
|
|
423
|
-
order: this.config.order ?? "asc",
|
|
424
|
-
nulls: this.config.nulls ?? "last",
|
|
425
|
-
opClass: this.config.opClass
|
|
426
|
-
};
|
|
427
|
-
defaultConfig = {
|
|
428
|
-
order: "asc",
|
|
429
|
-
nulls: "last",
|
|
430
|
-
opClass: void 0
|
|
431
|
-
};
|
|
432
|
-
asc() {
|
|
433
|
-
this.indexConfig.order = "asc";
|
|
434
|
-
return this;
|
|
435
|
-
}
|
|
436
|
-
desc() {
|
|
437
|
-
this.indexConfig.order = "desc";
|
|
438
|
-
return this;
|
|
439
|
-
}
|
|
440
|
-
nullsFirst() {
|
|
441
|
-
this.indexConfig.nulls = "first";
|
|
442
|
-
return this;
|
|
443
|
-
}
|
|
444
|
-
nullsLast() {
|
|
445
|
-
this.indexConfig.nulls = "last";
|
|
446
|
-
return this;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* ### PostgreSQL documentation quote
|
|
450
|
-
*
|
|
451
|
-
* > An operator class with optional parameters can be specified for each column of an index.
|
|
452
|
-
* The operator class identifies the operators to be used by the index for that column.
|
|
453
|
-
* For example, a B-tree index on four-byte integers would use the int4_ops class;
|
|
454
|
-
* this operator class includes comparison functions for four-byte integers.
|
|
455
|
-
* In practice the default operator class for the column's data type is usually sufficient.
|
|
456
|
-
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
|
|
457
|
-
* For example, we might want to sort a complex-number data type either by absolute value or by real part.
|
|
458
|
-
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
|
|
459
|
-
* More information about operator classes check:
|
|
460
|
-
*
|
|
461
|
-
* ### Useful links
|
|
462
|
-
* https://www.postgresql.org/docs/current/sql-createindex.html
|
|
463
|
-
*
|
|
464
|
-
* https://www.postgresql.org/docs/current/indexes-opclass.html
|
|
465
|
-
*
|
|
466
|
-
* https://www.postgresql.org/docs/current/xindex.html
|
|
467
|
-
*
|
|
468
|
-
* ### Additional types
|
|
469
|
-
* If you have the `pg_vector` extension installed in your database, you can use the
|
|
470
|
-
* `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types.
|
|
471
|
-
*
|
|
472
|
-
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
|
|
473
|
-
*
|
|
474
|
-
* @param opClass
|
|
475
|
-
* @returns
|
|
476
|
-
*/
|
|
477
|
-
op(opClass) {
|
|
478
|
-
this.indexConfig.opClass = opClass;
|
|
479
|
-
return this;
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
var IndexedColumn = class {
|
|
483
|
-
static [entityKind] = "IndexedColumn";
|
|
484
|
-
constructor(name, keyAsName, type, indexConfig) {
|
|
485
|
-
this.name = name;
|
|
486
|
-
this.keyAsName = keyAsName;
|
|
487
|
-
this.type = type;
|
|
488
|
-
this.indexConfig = indexConfig;
|
|
489
|
-
}
|
|
490
|
-
name;
|
|
491
|
-
keyAsName;
|
|
492
|
-
type;
|
|
493
|
-
indexConfig;
|
|
494
|
-
};
|
|
495
|
-
var PgArrayBuilder = class extends PgColumnBuilder {
|
|
496
|
-
static [entityKind] = "PgArrayBuilder";
|
|
497
|
-
constructor(name, baseBuilder, size) {
|
|
498
|
-
super(name, "array", "PgArray");
|
|
499
|
-
this.config.baseBuilder = baseBuilder;
|
|
500
|
-
this.config.size = size;
|
|
501
|
-
}
|
|
502
|
-
/** @internal */
|
|
503
|
-
build(table) {
|
|
504
|
-
const baseColumn = this.config.baseBuilder.build(table);
|
|
505
|
-
return new PgArray(table, this.config, baseColumn);
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
var PgArray = class PgArray extends PgColumn {
|
|
509
|
-
constructor(table, config, baseColumn, range) {
|
|
510
|
-
super(table, config);
|
|
511
|
-
this.baseColumn = baseColumn;
|
|
512
|
-
this.range = range;
|
|
513
|
-
this.size = config.size;
|
|
514
|
-
}
|
|
515
|
-
size;
|
|
516
|
-
static [entityKind] = "PgArray";
|
|
517
|
-
getSQLType() {
|
|
518
|
-
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
519
|
-
}
|
|
520
|
-
mapFromDriverValue(value) {
|
|
521
|
-
if (typeof value === "string") value = parsePgArray(value);
|
|
522
|
-
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
523
|
-
}
|
|
524
|
-
mapToDriverValue(value, isNestedArray = false) {
|
|
525
|
-
const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
|
|
526
|
-
if (isNestedArray) return a;
|
|
527
|
-
return makePgArray(a);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
533
|
-
var PgEnumObjectColumnBuilder = class extends PgColumnBuilder {
|
|
534
|
-
static [entityKind] = "PgEnumObjectColumnBuilder";
|
|
535
|
-
constructor(name, enumInstance) {
|
|
536
|
-
super(name, "string", "PgEnumObjectColumn");
|
|
537
|
-
this.config.enum = enumInstance;
|
|
538
|
-
}
|
|
539
|
-
/** @internal */
|
|
540
|
-
build(table) {
|
|
541
|
-
return new PgEnumObjectColumn(table, this.config);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
var PgEnumObjectColumn = class extends PgColumn {
|
|
545
|
-
static [entityKind] = "PgEnumObjectColumn";
|
|
546
|
-
enum;
|
|
547
|
-
enumValues = this.config.enum.enumValues;
|
|
548
|
-
constructor(table, config) {
|
|
549
|
-
super(table, config);
|
|
550
|
-
this.enum = config.enum;
|
|
551
|
-
}
|
|
552
|
-
getSQLType() {
|
|
553
|
-
return this.enum.enumName;
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
const isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
557
|
-
function isPgEnum(obj) {
|
|
558
|
-
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
559
|
-
}
|
|
560
|
-
var PgEnumColumnBuilder = class extends PgColumnBuilder {
|
|
561
|
-
static [entityKind] = "PgEnumColumnBuilder";
|
|
562
|
-
constructor(name, enumInstance) {
|
|
563
|
-
super(name, "string", "PgEnumColumn");
|
|
564
|
-
this.config.enum = enumInstance;
|
|
565
|
-
}
|
|
566
|
-
/** @internal */
|
|
567
|
-
build(table) {
|
|
568
|
-
return new PgEnumColumn(table, this.config);
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
var PgEnumColumn = class extends PgColumn {
|
|
572
|
-
static [entityKind] = "PgEnumColumn";
|
|
573
|
-
enum = this.config.enum;
|
|
574
|
-
enumValues = this.config.enum.enumValues;
|
|
575
|
-
constructor(table, config) {
|
|
576
|
-
super(table, config);
|
|
577
|
-
this.enum = config.enum;
|
|
578
|
-
}
|
|
579
|
-
getSQLType() {
|
|
580
|
-
return this.enum.enumName;
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
//#endregion
|
|
585
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/subquery.js
|
|
586
|
-
var Subquery = class {
|
|
587
|
-
static [entityKind] = "Subquery";
|
|
588
|
-
constructor(sql$1, fields, alias, isWith = false, usedTables = []) {
|
|
589
|
-
this._ = {
|
|
590
|
-
brand: "Subquery",
|
|
591
|
-
sql: sql$1,
|
|
592
|
-
selectedFields: fields,
|
|
593
|
-
alias,
|
|
594
|
-
isWith,
|
|
595
|
-
usedTables
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
var WithSubquery = class extends Subquery {
|
|
600
|
-
static [entityKind] = "WithSubquery";
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
//#endregion
|
|
604
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/tracing.js
|
|
605
|
-
const tracer = { startActiveSpan(name, fn) {
|
|
606
|
-
return fn();
|
|
607
|
-
} };
|
|
608
|
-
|
|
609
|
-
//#endregion
|
|
610
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/view-common.js
|
|
611
|
-
const ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
612
|
-
|
|
613
|
-
//#endregion
|
|
614
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/table.js
|
|
615
|
-
const Schema = Symbol.for("drizzle:Schema");
|
|
616
|
-
const Columns = Symbol.for("drizzle:Columns");
|
|
617
|
-
const ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
618
|
-
const OriginalName = Symbol.for("drizzle:OriginalName");
|
|
619
|
-
const BaseName = Symbol.for("drizzle:BaseName");
|
|
620
|
-
const IsAlias = Symbol.for("drizzle:IsAlias");
|
|
621
|
-
const ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
|
622
|
-
const IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
|
623
|
-
var Table = class {
|
|
624
|
-
static [entityKind] = "Table";
|
|
625
|
-
/** @internal */
|
|
626
|
-
static Symbol = {
|
|
627
|
-
Name: TableName,
|
|
628
|
-
Schema,
|
|
629
|
-
OriginalName,
|
|
630
|
-
Columns,
|
|
631
|
-
ExtraConfigColumns,
|
|
632
|
-
BaseName,
|
|
633
|
-
IsAlias,
|
|
634
|
-
ExtraConfigBuilder
|
|
635
|
-
};
|
|
636
|
-
/**
|
|
637
|
-
* @internal
|
|
638
|
-
* Can be changed if the table is aliased.
|
|
639
|
-
*/
|
|
640
|
-
[TableName];
|
|
641
|
-
/**
|
|
642
|
-
* @internal
|
|
643
|
-
* Used to store the original name of the table, before any aliasing.
|
|
644
|
-
*/
|
|
645
|
-
[OriginalName];
|
|
646
|
-
/** @internal */
|
|
647
|
-
[Schema];
|
|
648
|
-
/** @internal */
|
|
649
|
-
[Columns];
|
|
650
|
-
/** @internal */
|
|
651
|
-
[ExtraConfigColumns];
|
|
652
|
-
/**
|
|
653
|
-
* @internal
|
|
654
|
-
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
655
|
-
*/
|
|
656
|
-
[BaseName];
|
|
657
|
-
/** @internal */
|
|
658
|
-
[IsAlias] = false;
|
|
659
|
-
/** @internal */
|
|
660
|
-
[IsDrizzleTable] = true;
|
|
661
|
-
/** @internal */
|
|
662
|
-
[ExtraConfigBuilder] = void 0;
|
|
663
|
-
constructor(name, schema, baseName) {
|
|
664
|
-
this[TableName] = this[OriginalName] = name;
|
|
665
|
-
this[Schema] = schema;
|
|
666
|
-
this[BaseName] = baseName;
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
//#endregion
|
|
671
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/sql/sql.js
|
|
672
|
-
var FakePrimitiveParam = class {
|
|
673
|
-
static [entityKind] = "FakePrimitiveParam";
|
|
674
|
-
};
|
|
675
|
-
function isSQLWrapper(value) {
|
|
676
|
-
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
677
|
-
}
|
|
678
|
-
function mergeQueries(queries) {
|
|
679
|
-
const result = {
|
|
680
|
-
sql: "",
|
|
681
|
-
params: []
|
|
682
|
-
};
|
|
683
|
-
for (const query of queries) {
|
|
684
|
-
result.sql += query.sql;
|
|
685
|
-
result.params.push(...query.params);
|
|
686
|
-
if (query.typings?.length) {
|
|
687
|
-
if (!result.typings) result.typings = [];
|
|
688
|
-
result.typings.push(...query.typings);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return result;
|
|
692
|
-
}
|
|
693
|
-
var StringChunk = class {
|
|
694
|
-
static [entityKind] = "StringChunk";
|
|
695
|
-
value;
|
|
696
|
-
constructor(value) {
|
|
697
|
-
this.value = Array.isArray(value) ? value : [value];
|
|
698
|
-
}
|
|
699
|
-
getSQL() {
|
|
700
|
-
return new SQL([this]);
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
var SQL = class SQL {
|
|
704
|
-
constructor(queryChunks) {
|
|
705
|
-
this.queryChunks = queryChunks;
|
|
706
|
-
for (const chunk of queryChunks) if (is(chunk, Table)) {
|
|
707
|
-
const schemaName = chunk[Table.Symbol.Schema];
|
|
708
|
-
this.usedTables.push(schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
static [entityKind] = "SQL";
|
|
712
|
-
/** @internal */
|
|
713
|
-
decoder = noopDecoder;
|
|
714
|
-
shouldInlineParams = false;
|
|
715
|
-
/** @internal */
|
|
716
|
-
usedTables = [];
|
|
717
|
-
append(query) {
|
|
718
|
-
this.queryChunks.push(...query.queryChunks);
|
|
719
|
-
return this;
|
|
720
|
-
}
|
|
721
|
-
toQuery(config) {
|
|
722
|
-
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
723
|
-
const query = this.buildQueryFromSourceParams(this.queryChunks, config);
|
|
724
|
-
span?.setAttributes({
|
|
725
|
-
"drizzle.query.text": query.sql,
|
|
726
|
-
"drizzle.query.params": JSON.stringify(query.params)
|
|
727
|
-
});
|
|
728
|
-
return query;
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
buildQueryFromSourceParams(chunks, _config) {
|
|
732
|
-
const config = Object.assign({}, _config, {
|
|
733
|
-
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
734
|
-
paramStartIndex: _config.paramStartIndex || { value: 0 }
|
|
735
|
-
});
|
|
736
|
-
const { casing, escapeName, escapeParam, prepareTyping, inlineParams, paramStartIndex } = config;
|
|
737
|
-
return mergeQueries(chunks.map((chunk) => {
|
|
738
|
-
if (is(chunk, StringChunk)) return {
|
|
739
|
-
sql: chunk.value.join(""),
|
|
740
|
-
params: []
|
|
741
|
-
};
|
|
742
|
-
if (is(chunk, Name)) return {
|
|
743
|
-
sql: escapeName(chunk.value),
|
|
744
|
-
params: []
|
|
745
|
-
};
|
|
746
|
-
if (chunk === void 0) return {
|
|
747
|
-
sql: "",
|
|
748
|
-
params: []
|
|
749
|
-
};
|
|
750
|
-
if (Array.isArray(chunk)) {
|
|
751
|
-
const result = [new StringChunk("(")];
|
|
752
|
-
for (const [i, p] of chunk.entries()) {
|
|
753
|
-
result.push(p);
|
|
754
|
-
if (i < chunk.length - 1) result.push(new StringChunk(", "));
|
|
755
|
-
}
|
|
756
|
-
result.push(new StringChunk(")"));
|
|
757
|
-
return this.buildQueryFromSourceParams(result, config);
|
|
758
|
-
}
|
|
759
|
-
if (is(chunk, SQL)) return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
760
|
-
...config,
|
|
761
|
-
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
762
|
-
});
|
|
763
|
-
if (is(chunk, Table)) {
|
|
764
|
-
const schemaName = chunk[Table.Symbol.Schema];
|
|
765
|
-
const tableName = chunk[Table.Symbol.Name];
|
|
766
|
-
return {
|
|
767
|
-
sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
768
|
-
params: []
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
if (is(chunk, Column)) {
|
|
772
|
-
const columnName = casing.getColumnCasing(chunk);
|
|
773
|
-
if (_config.invokeSource === "indexes") return {
|
|
774
|
-
sql: escapeName(columnName),
|
|
775
|
-
params: []
|
|
776
|
-
};
|
|
777
|
-
const schemaName = chunk.table[Table.Symbol.Schema];
|
|
778
|
-
return {
|
|
779
|
-
sql: chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
|
|
780
|
-
params: []
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
if (is(chunk, View)) {
|
|
784
|
-
const schemaName = chunk[ViewBaseConfig].schema;
|
|
785
|
-
const viewName = chunk[ViewBaseConfig].name;
|
|
786
|
-
return {
|
|
787
|
-
sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
788
|
-
params: []
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
if (is(chunk, Param)) {
|
|
792
|
-
if (is(chunk.value, Placeholder)) return {
|
|
793
|
-
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
794
|
-
params: [chunk],
|
|
795
|
-
typings: ["none"]
|
|
796
|
-
};
|
|
797
|
-
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
798
|
-
if (is(mappedValue, SQL)) return this.buildQueryFromSourceParams([mappedValue], config);
|
|
799
|
-
if (inlineParams) return {
|
|
800
|
-
sql: this.mapInlineParam(mappedValue, config),
|
|
801
|
-
params: []
|
|
802
|
-
};
|
|
803
|
-
let typings = ["none"];
|
|
804
|
-
if (prepareTyping) typings = [prepareTyping(chunk.encoder)];
|
|
805
|
-
return {
|
|
806
|
-
sql: escapeParam(paramStartIndex.value++, mappedValue),
|
|
807
|
-
params: [mappedValue],
|
|
808
|
-
typings
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
if (is(chunk, Placeholder)) return {
|
|
812
|
-
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
813
|
-
params: [chunk],
|
|
814
|
-
typings: ["none"]
|
|
815
|
-
};
|
|
816
|
-
if (is(chunk, SQL.Aliased) && chunk.fieldAlias !== void 0) return {
|
|
817
|
-
sql: escapeName(chunk.fieldAlias),
|
|
818
|
-
params: []
|
|
819
|
-
};
|
|
820
|
-
if (is(chunk, Subquery)) {
|
|
821
|
-
if (chunk._.isWith) return {
|
|
822
|
-
sql: escapeName(chunk._.alias),
|
|
823
|
-
params: []
|
|
824
|
-
};
|
|
825
|
-
return this.buildQueryFromSourceParams([
|
|
826
|
-
new StringChunk("("),
|
|
827
|
-
chunk._.sql,
|
|
828
|
-
new StringChunk(") "),
|
|
829
|
-
new Name(chunk._.alias)
|
|
830
|
-
], config);
|
|
831
|
-
}
|
|
832
|
-
if (isPgEnum(chunk)) {
|
|
833
|
-
if (chunk.schema) return {
|
|
834
|
-
sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
|
|
835
|
-
params: []
|
|
836
|
-
};
|
|
837
|
-
return {
|
|
838
|
-
sql: escapeName(chunk.enumName),
|
|
839
|
-
params: []
|
|
840
|
-
};
|
|
841
|
-
}
|
|
842
|
-
if (isSQLWrapper(chunk)) {
|
|
843
|
-
if (chunk.shouldOmitSQLParens?.()) return this.buildQueryFromSourceParams([chunk.getSQL()], config);
|
|
844
|
-
return this.buildQueryFromSourceParams([
|
|
845
|
-
new StringChunk("("),
|
|
846
|
-
chunk.getSQL(),
|
|
847
|
-
new StringChunk(")")
|
|
848
|
-
], config);
|
|
849
|
-
}
|
|
850
|
-
if (inlineParams) return {
|
|
851
|
-
sql: this.mapInlineParam(chunk, config),
|
|
852
|
-
params: []
|
|
853
|
-
};
|
|
854
|
-
return {
|
|
855
|
-
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
856
|
-
params: [chunk],
|
|
857
|
-
typings: ["none"]
|
|
858
|
-
};
|
|
859
|
-
}));
|
|
860
|
-
}
|
|
861
|
-
mapInlineParam(chunk, { escapeString }) {
|
|
862
|
-
if (chunk === null) return "null";
|
|
863
|
-
if (typeof chunk === "number" || typeof chunk === "boolean") return chunk.toString();
|
|
864
|
-
if (typeof chunk === "string") return escapeString(chunk);
|
|
865
|
-
if (typeof chunk === "object") {
|
|
866
|
-
const mappedValueAsString = chunk.toString();
|
|
867
|
-
if (mappedValueAsString === "[object Object]") return escapeString(JSON.stringify(chunk));
|
|
868
|
-
return escapeString(mappedValueAsString);
|
|
869
|
-
}
|
|
870
|
-
throw new Error("Unexpected param value: " + chunk);
|
|
871
|
-
}
|
|
872
|
-
getSQL() {
|
|
873
|
-
return this;
|
|
874
|
-
}
|
|
875
|
-
as(alias) {
|
|
876
|
-
if (alias === void 0) return this;
|
|
877
|
-
return new SQL.Aliased(this, alias);
|
|
878
|
-
}
|
|
879
|
-
mapWith(decoder) {
|
|
880
|
-
this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
|
|
881
|
-
return this;
|
|
882
|
-
}
|
|
883
|
-
inlineParams() {
|
|
884
|
-
this.shouldInlineParams = true;
|
|
885
|
-
return this;
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* This method is used to conditionally include a part of the query.
|
|
889
|
-
*
|
|
890
|
-
* @param condition - Condition to check
|
|
891
|
-
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
892
|
-
*/
|
|
893
|
-
if(condition) {
|
|
894
|
-
return condition ? this : void 0;
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
var Name = class {
|
|
898
|
-
constructor(value) {
|
|
899
|
-
this.value = value;
|
|
900
|
-
}
|
|
901
|
-
static [entityKind] = "Name";
|
|
902
|
-
brand;
|
|
903
|
-
getSQL() {
|
|
904
|
-
return new SQL([this]);
|
|
905
|
-
}
|
|
906
|
-
};
|
|
907
|
-
function isDriverValueEncoder(value) {
|
|
908
|
-
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
909
|
-
}
|
|
910
|
-
const noopDecoder = { mapFromDriverValue: (value) => value };
|
|
911
|
-
const noopEncoder = { mapToDriverValue: (value) => value };
|
|
912
|
-
const noopMapper = {
|
|
913
|
-
...noopDecoder,
|
|
914
|
-
...noopEncoder
|
|
915
|
-
};
|
|
916
|
-
var Param = class {
|
|
917
|
-
/**
|
|
918
|
-
* @param value - Parameter value
|
|
919
|
-
* @param encoder - Encoder to convert the value to a driver parameter
|
|
920
|
-
*/
|
|
921
|
-
constructor(value, encoder = noopEncoder) {
|
|
922
|
-
this.value = value;
|
|
923
|
-
this.encoder = encoder;
|
|
924
|
-
}
|
|
925
|
-
static [entityKind] = "Param";
|
|
926
|
-
brand;
|
|
927
|
-
getSQL() {
|
|
928
|
-
return new SQL([this]);
|
|
929
|
-
}
|
|
930
|
-
};
|
|
931
|
-
function sql(strings, ...params) {
|
|
932
|
-
const queryChunks = [];
|
|
933
|
-
if (params.length > 0 || strings.length > 0 && strings[0] !== "") queryChunks.push(new StringChunk(strings[0]));
|
|
934
|
-
for (const [paramIndex, param2] of params.entries()) queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
935
|
-
return new SQL(queryChunks);
|
|
936
|
-
}
|
|
937
|
-
((sql2) => {
|
|
938
|
-
function empty() {
|
|
939
|
-
return new SQL([]);
|
|
940
|
-
}
|
|
941
|
-
sql2.empty = empty;
|
|
942
|
-
function fromList(list) {
|
|
943
|
-
return new SQL(list);
|
|
944
|
-
}
|
|
945
|
-
sql2.fromList = fromList;
|
|
946
|
-
function raw(str) {
|
|
947
|
-
return new SQL([new StringChunk(str)]);
|
|
948
|
-
}
|
|
949
|
-
sql2.raw = raw;
|
|
950
|
-
function join(chunks, separator) {
|
|
951
|
-
const result = [];
|
|
952
|
-
for (const [i, chunk] of chunks.entries()) {
|
|
953
|
-
if (i > 0 && separator !== void 0) result.push(separator);
|
|
954
|
-
result.push(chunk);
|
|
955
|
-
}
|
|
956
|
-
return new SQL(result);
|
|
957
|
-
}
|
|
958
|
-
sql2.join = join;
|
|
959
|
-
function identifier(value) {
|
|
960
|
-
return new Name(value);
|
|
961
|
-
}
|
|
962
|
-
sql2.identifier = identifier;
|
|
963
|
-
function placeholder2(name2) {
|
|
964
|
-
return new Placeholder(name2);
|
|
965
|
-
}
|
|
966
|
-
sql2.placeholder = placeholder2;
|
|
967
|
-
function param2(value, encoder) {
|
|
968
|
-
return new Param(value, encoder);
|
|
969
|
-
}
|
|
970
|
-
sql2.param = param2;
|
|
971
|
-
})(sql || (sql = {}));
|
|
972
|
-
((SQL2) => {
|
|
973
|
-
class Aliased {
|
|
974
|
-
constructor(sql2, fieldAlias) {
|
|
975
|
-
this.sql = sql2;
|
|
976
|
-
this.fieldAlias = fieldAlias;
|
|
977
|
-
}
|
|
978
|
-
static [entityKind] = "SQL.Aliased";
|
|
979
|
-
/** @internal */
|
|
980
|
-
isSelectionField = false;
|
|
981
|
-
getSQL() {
|
|
982
|
-
return this.sql;
|
|
983
|
-
}
|
|
984
|
-
/** @internal */
|
|
985
|
-
clone() {
|
|
986
|
-
return new Aliased(this.sql, this.fieldAlias);
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
SQL2.Aliased = Aliased;
|
|
990
|
-
})(SQL || (SQL = {}));
|
|
991
|
-
var Placeholder = class {
|
|
992
|
-
constructor(name2) {
|
|
993
|
-
this.name = name2;
|
|
994
|
-
}
|
|
995
|
-
static [entityKind] = "Placeholder";
|
|
996
|
-
getSQL() {
|
|
997
|
-
return new SQL([this]);
|
|
998
|
-
}
|
|
999
|
-
};
|
|
1000
|
-
const IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
|
|
1001
|
-
var View = class {
|
|
1002
|
-
static [entityKind] = "View";
|
|
1003
|
-
/** @internal */
|
|
1004
|
-
[ViewBaseConfig];
|
|
1005
|
-
/** @internal */
|
|
1006
|
-
[IsDrizzleView] = true;
|
|
1007
|
-
constructor({ name: name2, schema, selectedFields, query }) {
|
|
1008
|
-
this[ViewBaseConfig] = {
|
|
1009
|
-
name: name2,
|
|
1010
|
-
originalName: name2,
|
|
1011
|
-
schema,
|
|
1012
|
-
selectedFields,
|
|
1013
|
-
query,
|
|
1014
|
-
isExisting: !query,
|
|
1015
|
-
isAlias: false
|
|
1016
|
-
};
|
|
1017
|
-
}
|
|
1018
|
-
getSQL() {
|
|
1019
|
-
return new SQL([this]);
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
Column.prototype.getSQL = function() {
|
|
1023
|
-
return new SQL([this]);
|
|
1024
|
-
};
|
|
1025
|
-
Table.prototype.getSQL = function() {
|
|
1026
|
-
return new SQL([this]);
|
|
1027
|
-
};
|
|
1028
|
-
Subquery.prototype.getSQL = function() {
|
|
1029
|
-
return new SQL([this]);
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
//#endregion
|
|
1033
|
-
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.1_@libsql+client@0.14.0_@types+better-sqlite3@7.6.13_better-sqlite3@11.10.0_gel@2.2.0_kysely@0.28.9/node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
1034
|
-
function bindIfParam(value, column) {
|
|
1035
|
-
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) return new Param(value, column);
|
|
1036
|
-
return value;
|
|
1037
|
-
}
|
|
1038
|
-
const eq = (left, right) => {
|
|
1039
|
-
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
//#endregion
|
|
1043
|
-
export { eq as t };
|