effect-qb 0.19.0 → 0.21.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/README.md +7 -1
- package/dist/index.js +1990 -679
- package/dist/mysql.js +1490 -617
- package/dist/postgres/metadata.js +1334 -263
- package/dist/postgres.js +3376 -2307
- package/dist/sqlite.js +1573 -628
- package/dist/standard.js +1984 -673
- package/package.json +3 -6
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.d.ts +3 -3
- package/src/internal/column-state.ts +13 -12
- package/src/internal/column.ts +8 -8
- package/src/internal/datatypes/define.ts +5 -0
- package/src/internal/datatypes/lookup.ts +67 -18
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/dialect-renderers/mysql.ts +6 -4
- package/src/internal/dialect-renderers/postgres.ts +6 -4
- package/src/internal/dialect-renderers/sqlite.ts +6 -4
- package/src/internal/dialect.ts +1 -1
- package/src/internal/executor.ts +56 -43
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/query.d.ts +1 -1
- package/src/internal/query.ts +1 -1
- package/src/internal/runtime/driver-value-mapping.ts +3 -3
- package/src/internal/runtime/schema.ts +28 -38
- package/src/internal/runtime/value.ts +20 -23
- package/src/internal/scalar.d.ts +1 -1
- package/src/internal/scalar.ts +2 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +11 -11
- package/src/internal/standard-dsl.ts +121 -28
- package/src/internal/table.ts +451 -120
- package/src/mysql/column.ts +6 -6
- package/src/mysql/datatypes/index.ts +1 -0
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +4 -6
- package/src/mysql/function/temporal.ts +1 -1
- package/src/mysql/internal/dsl.ts +116 -16
- package/src/mysql/json.ts +1 -33
- package/src/mysql/renderer.ts +13 -6
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +3 -1
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column.ts +11 -11
- package/src/postgres/datatypes/index.ts +1 -0
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +4 -6
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/temporal.ts +1 -1
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dsl.ts +122 -21
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +726 -173
- package/src/postgres/jsonb.ts +0 -1
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/renderer.ts +13 -6
- package/src/postgres/schema-management.ts +1 -6
- package/src/postgres/schema.ts +16 -8
- package/src/postgres/table.ts +111 -113
- package/src/postgres/type.ts +86 -4
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +12 -6
- package/src/sqlite/column.ts +6 -6
- package/src/sqlite/datatypes/index.ts +1 -0
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +4 -6
- package/src/sqlite/function/temporal.ts +1 -1
- package/src/sqlite/internal/dsl.ts +100 -5
- package/src/sqlite/json.ts +1 -32
- package/src/sqlite/renderer.ts +13 -6
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +3 -1
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +10 -10
- package/src/standard/datatypes/index.ts +2 -2
- package/src/standard/datatypes/spec.ts +10 -96
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/temporal.ts +1 -1
- package/src/standard/index.ts +17 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/renderer.ts +31 -3
- package/src/standard/table.ts +25 -21
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +14 -0
- package/src/internal/table.d.ts +0 -174
- package/src/postgres/cast.ts +0 -45
package/dist/mysql.js
CHANGED
|
@@ -22,7 +22,7 @@ import * as Schema4 from "effect/Schema";
|
|
|
22
22
|
import * as Schema2 from "effect/Schema";
|
|
23
23
|
|
|
24
24
|
// src/internal/column-state.ts
|
|
25
|
-
import { pipeArguments } from "effect/Pipeable";
|
|
25
|
+
import { pipeArguments as pipeArguments2 } from "effect/Pipeable";
|
|
26
26
|
import * as Schema from "effect/Schema";
|
|
27
27
|
|
|
28
28
|
// src/internal/scalar.ts
|
|
@@ -35,12 +35,181 @@ var TypeId = Symbol.for("effect-qb/Expression");
|
|
|
35
35
|
// src/internal/expression-ast.ts
|
|
36
36
|
var TypeId2 = Symbol.for("effect-qb/ExpressionAst");
|
|
37
37
|
|
|
38
|
+
// src/internal/json/path-access.ts
|
|
39
|
+
import { pipeArguments } from "effect/Pipeable";
|
|
40
|
+
|
|
41
|
+
// src/internal/json/path.ts
|
|
42
|
+
var SegmentTypeId = Symbol.for("effect-qb/JsonPathSegment");
|
|
43
|
+
var TypeId3 = Symbol.for("effect-qb/JsonPath");
|
|
44
|
+
var makeSegment = (segment) => segment;
|
|
45
|
+
var key = (value) => makeSegment({
|
|
46
|
+
[SegmentTypeId]: {
|
|
47
|
+
kind: "key"
|
|
48
|
+
},
|
|
49
|
+
kind: "key",
|
|
50
|
+
key: value
|
|
51
|
+
});
|
|
52
|
+
var index = (value) => makeSegment({
|
|
53
|
+
[SegmentTypeId]: {
|
|
54
|
+
kind: "index"
|
|
55
|
+
},
|
|
56
|
+
kind: "index",
|
|
57
|
+
index: value
|
|
58
|
+
});
|
|
59
|
+
var wildcard = () => makeSegment({
|
|
60
|
+
[SegmentTypeId]: {
|
|
61
|
+
kind: "wildcard"
|
|
62
|
+
},
|
|
63
|
+
kind: "wildcard"
|
|
64
|
+
});
|
|
65
|
+
var slice = (start, end) => makeSegment({
|
|
66
|
+
[SegmentTypeId]: {
|
|
67
|
+
kind: "slice"
|
|
68
|
+
},
|
|
69
|
+
kind: "slice",
|
|
70
|
+
start,
|
|
71
|
+
end
|
|
72
|
+
});
|
|
73
|
+
var descend = () => makeSegment({
|
|
74
|
+
[SegmentTypeId]: {
|
|
75
|
+
kind: "descend"
|
|
76
|
+
},
|
|
77
|
+
kind: "descend"
|
|
78
|
+
});
|
|
79
|
+
var path = (...segments) => ({
|
|
80
|
+
[TypeId3]: {
|
|
81
|
+
segments
|
|
82
|
+
},
|
|
83
|
+
segments
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// src/internal/json/path-access.ts
|
|
87
|
+
var WrappedTypeId = Symbol.for("effect-qb/JsonPathAccess");
|
|
88
|
+
var accessKinds = new Set([
|
|
89
|
+
"jsonGet",
|
|
90
|
+
"jsonPath",
|
|
91
|
+
"jsonAccess",
|
|
92
|
+
"jsonTraverse",
|
|
93
|
+
"jsonGetText",
|
|
94
|
+
"jsonPathText",
|
|
95
|
+
"jsonAccessText",
|
|
96
|
+
"jsonTraverseText"
|
|
97
|
+
]);
|
|
98
|
+
var reservedKeys = new Set([
|
|
99
|
+
"pipe",
|
|
100
|
+
"then",
|
|
101
|
+
"toString",
|
|
102
|
+
"toJSON",
|
|
103
|
+
"valueOf",
|
|
104
|
+
"constructor",
|
|
105
|
+
"__proto__",
|
|
106
|
+
"prototype",
|
|
107
|
+
"inspect",
|
|
108
|
+
"schema",
|
|
109
|
+
"metadata",
|
|
110
|
+
"columns",
|
|
111
|
+
"name"
|
|
112
|
+
]);
|
|
113
|
+
var isObjectLike = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
|
|
114
|
+
var isExpression = (value) => isObjectLike(value) && (TypeId in value);
|
|
115
|
+
var isJsonExpression = (value) => {
|
|
116
|
+
if (!isExpression(value)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const dbType = value[TypeId].dbType;
|
|
120
|
+
return dbType.kind === "json" || dbType.kind === "jsonb" || dbType.variant === "json" || dbType.variant === "jsonb";
|
|
121
|
+
};
|
|
122
|
+
var isWrapped = (value) => value[WrappedTypeId] === true;
|
|
123
|
+
var normalizeSegment = (segment) => {
|
|
124
|
+
switch (segment.kind) {
|
|
125
|
+
case "key":
|
|
126
|
+
return key(segment.key);
|
|
127
|
+
case "index":
|
|
128
|
+
return index(segment.index);
|
|
129
|
+
case "wildcard":
|
|
130
|
+
return wildcard();
|
|
131
|
+
case "slice":
|
|
132
|
+
return slice(segment.start, segment.end);
|
|
133
|
+
case "descend":
|
|
134
|
+
return descend();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var accessPathOf = (value) => {
|
|
138
|
+
const segments = [];
|
|
139
|
+
let base = value;
|
|
140
|
+
while (isExpression(base)) {
|
|
141
|
+
const ast = base[TypeId2];
|
|
142
|
+
if (ast === undefined || typeof ast.kind !== "string" || !accessKinds.has(ast.kind) || !isExpression(ast.base) || !Array.isArray(ast.segments)) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
segments.unshift(...ast.segments.map(normalizeSegment));
|
|
146
|
+
base = ast.base;
|
|
147
|
+
}
|
|
148
|
+
return { base, segments };
|
|
149
|
+
};
|
|
150
|
+
var isIntegerProperty = (property) => /^(?:-?(?:0|[1-9][0-9]*))$/.test(property);
|
|
151
|
+
var jsonAccessKind = (segments) => segments.every((segment) => segment.kind === "key" || segment.kind === "index") ? segments.length === 1 ? "jsonGet" : "jsonPath" : "jsonTraverse";
|
|
152
|
+
var makeExpression = (state, ast) => {
|
|
153
|
+
const expression = Object.create(null);
|
|
154
|
+
Object.defineProperty(expression, "pipe", {
|
|
155
|
+
configurable: true,
|
|
156
|
+
writable: true,
|
|
157
|
+
value: function() {
|
|
158
|
+
return pipeArguments(expression, arguments);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
expression[TypeId] = state;
|
|
162
|
+
expression[TypeId2] = ast;
|
|
163
|
+
return expression;
|
|
164
|
+
};
|
|
165
|
+
var makePathExpression = (value, segment) => {
|
|
166
|
+
const access = accessPathOf(value);
|
|
167
|
+
const segments = [...access.segments, normalizeSegment(segment)];
|
|
168
|
+
const base = access.base;
|
|
169
|
+
const baseState = base[TypeId];
|
|
170
|
+
return withJsonPathAccess(makeExpression({
|
|
171
|
+
...baseState,
|
|
172
|
+
runtime: undefined,
|
|
173
|
+
nullability: undefined
|
|
174
|
+
}, {
|
|
175
|
+
kind: jsonAccessKind(segments),
|
|
176
|
+
base,
|
|
177
|
+
segments
|
|
178
|
+
}));
|
|
179
|
+
};
|
|
180
|
+
var pathProxyHandler = {
|
|
181
|
+
get(target, property, receiver) {
|
|
182
|
+
if (typeof property === "symbol") {
|
|
183
|
+
return Reflect.get(target, property, receiver);
|
|
184
|
+
}
|
|
185
|
+
if (Reflect.has(target, property) || reservedKeys.has(property)) {
|
|
186
|
+
return Reflect.get(target, property, receiver);
|
|
187
|
+
}
|
|
188
|
+
const segment = isIntegerProperty(property) ? index(Number(property)) : key(property);
|
|
189
|
+
return makePathExpression(target, segment);
|
|
190
|
+
},
|
|
191
|
+
has(target, property) {
|
|
192
|
+
return Reflect.has(target, property);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var withJsonPathAccess = (value) => {
|
|
196
|
+
if (!isObjectLike(value) || !isJsonExpression(value) || isWrapped(value)) {
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
const proxy = new Proxy(value, pathProxyHandler);
|
|
200
|
+
Object.defineProperty(proxy, WrappedTypeId, {
|
|
201
|
+
configurable: false,
|
|
202
|
+
value: true
|
|
203
|
+
});
|
|
204
|
+
return proxy;
|
|
205
|
+
};
|
|
206
|
+
|
|
38
207
|
// src/internal/column-state.ts
|
|
39
208
|
var ColumnTypeId = Symbol.for("effect-qb/Column");
|
|
40
209
|
var BoundColumnTypeId = Symbol.for("effect-qb/BoundColumn");
|
|
41
210
|
var ColumnProto = {
|
|
42
211
|
pipe() {
|
|
43
|
-
return
|
|
212
|
+
return pipeArguments2(this, arguments);
|
|
44
213
|
}
|
|
45
214
|
};
|
|
46
215
|
var attachPipe = (value) => {
|
|
@@ -48,7 +217,7 @@ var attachPipe = (value) => {
|
|
|
48
217
|
configurable: true,
|
|
49
218
|
writable: true,
|
|
50
219
|
value: function() {
|
|
51
|
-
return
|
|
220
|
+
return pipeArguments2(value, arguments);
|
|
52
221
|
}
|
|
53
222
|
});
|
|
54
223
|
return value;
|
|
@@ -85,7 +254,7 @@ var makeColumnDefinition = (schema, metadata) => {
|
|
|
85
254
|
identity: metadata.identity,
|
|
86
255
|
enum: metadata.enum
|
|
87
256
|
};
|
|
88
|
-
return column;
|
|
257
|
+
return withJsonPathAccess(column);
|
|
89
258
|
};
|
|
90
259
|
var remapColumnDefinition = (column, options = {}) => {
|
|
91
260
|
const schema = options.schema ?? column.schema;
|
|
@@ -127,7 +296,7 @@ var remapColumnDefinition = (column, options = {}) => {
|
|
|
127
296
|
if (BoundColumnTypeId in column) {
|
|
128
297
|
next[BoundColumnTypeId] = column[BoundColumnTypeId];
|
|
129
298
|
}
|
|
130
|
-
return next;
|
|
299
|
+
return withJsonPathAccess(next);
|
|
131
300
|
};
|
|
132
301
|
var bindColumn = (tableName, columnName, column, baseTableName, schemaName, casing) => {
|
|
133
302
|
const brandName = `${tableName}.${columnName}`;
|
|
@@ -160,7 +329,7 @@ var bindColumn = (tableName, columnName, column, baseTableName, schemaName, casi
|
|
|
160
329
|
schemaName,
|
|
161
330
|
casing
|
|
162
331
|
};
|
|
163
|
-
return bound;
|
|
332
|
+
return withJsonPathAccess(bound);
|
|
164
333
|
};
|
|
165
334
|
|
|
166
335
|
// src/internal/column.ts
|
|
@@ -245,7 +414,7 @@ var array = (options) => (column) => remapColumnDefinition(column, {
|
|
|
245
414
|
ddlType: `${column.metadata.ddlType ?? column.metadata.dbType.kind}[]`
|
|
246
415
|
}
|
|
247
416
|
});
|
|
248
|
-
function
|
|
417
|
+
function index2(arg) {
|
|
249
418
|
if (isColumnDefinitionValue(arg)) {
|
|
250
419
|
return mapColumn(arg, {
|
|
251
420
|
...arg.metadata,
|
|
@@ -309,7 +478,7 @@ var enrichDbType = (datatypes, dbType) => {
|
|
|
309
478
|
|
|
310
479
|
// src/internal/runtime/value.ts
|
|
311
480
|
import * as Schema3 from "effect/Schema";
|
|
312
|
-
var brandString = (
|
|
481
|
+
var brandString = (pattern, brand5) => Schema3.String.pipe(Schema3.check(Schema3.isPattern(pattern)), Schema3.brand(brand5));
|
|
313
482
|
var localDatePattern = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
314
483
|
var isValidLocalDateString = (value) => {
|
|
315
484
|
const match = localDatePattern.exec(value);
|
|
@@ -362,11 +531,11 @@ var isValidInstantString = (value) => {
|
|
|
362
531
|
const match = instantPattern.exec(value);
|
|
363
532
|
return match !== null && isValidLocalDateString(match[1]) && isValidLocalTimeString(match[2]) && isValidOffset(match[3]);
|
|
364
533
|
};
|
|
365
|
-
var LocalDateStringSchema = Schema3.String.pipe(Schema3.
|
|
366
|
-
var LocalTimeStringSchema = Schema3.String.pipe(Schema3.
|
|
367
|
-
var OffsetTimeStringSchema = Schema3.String.pipe(Schema3.
|
|
368
|
-
var LocalDateTimeStringSchema = Schema3.String.pipe(Schema3.
|
|
369
|
-
var InstantStringSchema = Schema3.String.pipe(Schema3.
|
|
534
|
+
var LocalDateStringSchema = Schema3.String.pipe(Schema3.check(Schema3.isPattern(localDatePattern)), Schema3.check(Schema3.makeFilter((value) => isValidLocalDateString(value))), Schema3.brand("LocalDateString"));
|
|
535
|
+
var LocalTimeStringSchema = Schema3.String.pipe(Schema3.check(Schema3.isPattern(localTimePattern)), Schema3.check(Schema3.makeFilter((value) => isValidLocalTimeString(value))), Schema3.brand("LocalTimeString"));
|
|
536
|
+
var OffsetTimeStringSchema = Schema3.String.pipe(Schema3.check(Schema3.isPattern(offsetTimePattern)), Schema3.check(Schema3.makeFilter((value) => isValidOffsetTimeString(value))), Schema3.brand("OffsetTimeString"));
|
|
537
|
+
var LocalDateTimeStringSchema = Schema3.String.pipe(Schema3.check(Schema3.isPattern(localDateTimePattern)), Schema3.check(Schema3.makeFilter((value) => isValidLocalDateTimeString(value))), Schema3.brand("LocalDateTimeString"));
|
|
538
|
+
var InstantStringSchema = Schema3.String.pipe(Schema3.check(Schema3.isPattern(instantPattern)), Schema3.check(Schema3.makeFilter((value) => isValidInstantString(value))), Schema3.brand("InstantString"));
|
|
370
539
|
var YearStringSchema = brandString(/^\d{4}$/, "YearString");
|
|
371
540
|
var canonicalizeBigIntString = (input) => {
|
|
372
541
|
const trimmed = input.trim();
|
|
@@ -406,13 +575,22 @@ var isCanonicalDecimalString = (value) => {
|
|
|
406
575
|
return false;
|
|
407
576
|
}
|
|
408
577
|
};
|
|
409
|
-
var BigIntStringSchema = Schema3.String.pipe(Schema3.
|
|
410
|
-
var DecimalStringSchema = Schema3.String.pipe(Schema3.
|
|
411
|
-
var JsonValueSchema = Schema3.suspend(() => Schema3.Union(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
578
|
+
var BigIntStringSchema = Schema3.String.pipe(Schema3.check(Schema3.makeFilter((value) => isCanonicalBigIntString(value))), Schema3.brand("BigIntString"));
|
|
579
|
+
var DecimalStringSchema = Schema3.String.pipe(Schema3.check(Schema3.makeFilter((value) => isCanonicalDecimalString(value))), Schema3.brand("DecimalString"));
|
|
580
|
+
var JsonValueSchema = Schema3.suspend(() => Schema3.Union([
|
|
581
|
+
Schema3.String,
|
|
582
|
+
Schema3.Number.check(Schema3.isFinite()),
|
|
583
|
+
Schema3.Boolean,
|
|
584
|
+
Schema3.Null,
|
|
585
|
+
Schema3.Array(JsonValueSchema),
|
|
586
|
+
Schema3.Record(Schema3.String, JsonValueSchema)
|
|
587
|
+
]));
|
|
588
|
+
var JsonPrimitiveSchema = Schema3.Union([
|
|
589
|
+
Schema3.String,
|
|
590
|
+
Schema3.Number.check(Schema3.isFinite()),
|
|
591
|
+
Schema3.Boolean,
|
|
592
|
+
Schema3.Null
|
|
593
|
+
]);
|
|
416
594
|
|
|
417
595
|
// src/mysql/datatypes/index.ts
|
|
418
596
|
var exports_datatypes = {};
|
|
@@ -420,7 +598,564 @@ __export(exports_datatypes, {
|
|
|
420
598
|
mysqlDatatypes: () => mysqlDatatypes
|
|
421
599
|
});
|
|
422
600
|
|
|
423
|
-
// src/
|
|
601
|
+
// src/internal/datatypes/matrix.ts
|
|
602
|
+
var portableDatatypeFamilies = {
|
|
603
|
+
uuid: {
|
|
604
|
+
compareGroup: "uuid",
|
|
605
|
+
castTargets: ["uuid", "char", "varchar", "text"],
|
|
606
|
+
traits: {
|
|
607
|
+
textual: true
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
text: {
|
|
611
|
+
compareGroup: "text",
|
|
612
|
+
castTargets: [
|
|
613
|
+
"text",
|
|
614
|
+
"numeric",
|
|
615
|
+
"integer",
|
|
616
|
+
"real",
|
|
617
|
+
"boolean",
|
|
618
|
+
"date",
|
|
619
|
+
"time",
|
|
620
|
+
"datetime",
|
|
621
|
+
"interval",
|
|
622
|
+
"uuid",
|
|
623
|
+
"json",
|
|
624
|
+
"blob",
|
|
625
|
+
"binary",
|
|
626
|
+
"array",
|
|
627
|
+
"range",
|
|
628
|
+
"multirange",
|
|
629
|
+
"record",
|
|
630
|
+
"enum",
|
|
631
|
+
"set",
|
|
632
|
+
"money",
|
|
633
|
+
"null"
|
|
634
|
+
],
|
|
635
|
+
traits: {
|
|
636
|
+
textual: true,
|
|
637
|
+
ordered: true
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
numeric: {
|
|
641
|
+
compareGroup: "numeric",
|
|
642
|
+
castTargets: ["numeric", "integer", "real", "text", "boolean", "date", "time", "datetime"],
|
|
643
|
+
traits: {
|
|
644
|
+
ordered: true
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
integer: {
|
|
648
|
+
compareGroup: "numeric",
|
|
649
|
+
castTargets: ["integer", "numeric", "real", "text", "boolean", "date", "time", "datetime"],
|
|
650
|
+
traits: {
|
|
651
|
+
ordered: true
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
real: {
|
|
655
|
+
compareGroup: "numeric",
|
|
656
|
+
castTargets: ["real", "numeric", "integer", "text", "boolean"],
|
|
657
|
+
traits: {
|
|
658
|
+
ordered: true
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
boolean: {
|
|
662
|
+
compareGroup: "boolean",
|
|
663
|
+
castTargets: ["boolean", "integer", "numeric", "text"],
|
|
664
|
+
traits: {}
|
|
665
|
+
},
|
|
666
|
+
date: {
|
|
667
|
+
compareGroup: "date",
|
|
668
|
+
castTargets: ["date", "time", "datetime", "text", "numeric", "integer"],
|
|
669
|
+
traits: {
|
|
670
|
+
ordered: true
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
time: {
|
|
674
|
+
compareGroup: "time",
|
|
675
|
+
castTargets: ["time", "date", "datetime", "text", "numeric", "integer"],
|
|
676
|
+
traits: {
|
|
677
|
+
ordered: true
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
datetime: {
|
|
681
|
+
compareGroup: "datetime",
|
|
682
|
+
castTargets: ["datetime", "date", "time", "text", "numeric", "integer"],
|
|
683
|
+
traits: {
|
|
684
|
+
ordered: true
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
json: {
|
|
688
|
+
compareGroup: "json",
|
|
689
|
+
castTargets: ["json", "text"],
|
|
690
|
+
traits: {}
|
|
691
|
+
},
|
|
692
|
+
blob: {
|
|
693
|
+
compareGroup: "blob",
|
|
694
|
+
castTargets: ["blob", "text"],
|
|
695
|
+
traits: {}
|
|
696
|
+
},
|
|
697
|
+
null: {
|
|
698
|
+
compareGroup: "null",
|
|
699
|
+
castTargets: ["uuid", "text", "numeric", "integer", "real", "boolean", "date", "time", "datetime", "json", "blob", "null"],
|
|
700
|
+
traits: {}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var portableDatatypeKinds = {
|
|
704
|
+
uuid: { family: "uuid", runtime: "string" },
|
|
705
|
+
text: { family: "text", runtime: "string" },
|
|
706
|
+
varchar: { family: "text", runtime: "string" },
|
|
707
|
+
char: { family: "text", runtime: "string" },
|
|
708
|
+
int: { family: "integer", runtime: "number" },
|
|
709
|
+
integer: { family: "integer", runtime: "number" },
|
|
710
|
+
bigint: { family: "integer", runtime: "bigintString" },
|
|
711
|
+
numeric: { family: "numeric", runtime: "decimalString" },
|
|
712
|
+
decimal: { family: "numeric", runtime: "decimalString" },
|
|
713
|
+
real: { family: "real", runtime: "number" },
|
|
714
|
+
boolean: { family: "boolean", runtime: "boolean" },
|
|
715
|
+
date: { family: "date", runtime: "localDate" },
|
|
716
|
+
time: { family: "time", runtime: "localTime" },
|
|
717
|
+
datetime: { family: "datetime", runtime: "localDateTime" },
|
|
718
|
+
timestamp: { family: "datetime", runtime: "localDateTime" },
|
|
719
|
+
json: { family: "json", runtime: "json" },
|
|
720
|
+
blob: { family: "blob", runtime: "bytes" }
|
|
721
|
+
};
|
|
722
|
+
var portableDatatypeKeys = Object.keys(portableDatatypeKinds);
|
|
723
|
+
var portableDatatypeDdlTypeByDialect = {
|
|
724
|
+
standard: {
|
|
725
|
+
uuid: "uuid",
|
|
726
|
+
text: "text",
|
|
727
|
+
varchar: "varchar",
|
|
728
|
+
char: "char",
|
|
729
|
+
int: "int",
|
|
730
|
+
integer: "integer",
|
|
731
|
+
bigint: "bigint",
|
|
732
|
+
numeric: "numeric",
|
|
733
|
+
decimal: "decimal",
|
|
734
|
+
real: "real",
|
|
735
|
+
boolean: "boolean",
|
|
736
|
+
date: "date",
|
|
737
|
+
time: "time",
|
|
738
|
+
datetime: "datetime",
|
|
739
|
+
timestamp: "timestamp",
|
|
740
|
+
json: "json",
|
|
741
|
+
blob: "blob"
|
|
742
|
+
},
|
|
743
|
+
postgres: {
|
|
744
|
+
uuid: "uuid",
|
|
745
|
+
text: "text",
|
|
746
|
+
varchar: "varchar",
|
|
747
|
+
char: "char",
|
|
748
|
+
int: "int",
|
|
749
|
+
integer: "integer",
|
|
750
|
+
bigint: "bigint",
|
|
751
|
+
numeric: "numeric",
|
|
752
|
+
decimal: "decimal",
|
|
753
|
+
real: "real",
|
|
754
|
+
boolean: "boolean",
|
|
755
|
+
date: "date",
|
|
756
|
+
time: "time",
|
|
757
|
+
datetime: "timestamp",
|
|
758
|
+
timestamp: "timestamp",
|
|
759
|
+
json: "json",
|
|
760
|
+
blob: "bytea"
|
|
761
|
+
},
|
|
762
|
+
mysql: {
|
|
763
|
+
uuid: "char(36)",
|
|
764
|
+
text: "text",
|
|
765
|
+
varchar: "varchar(255)",
|
|
766
|
+
char: "char",
|
|
767
|
+
int: "int",
|
|
768
|
+
integer: "integer",
|
|
769
|
+
bigint: "bigint",
|
|
770
|
+
numeric: "numeric",
|
|
771
|
+
decimal: "decimal",
|
|
772
|
+
real: "real",
|
|
773
|
+
boolean: "boolean",
|
|
774
|
+
date: "date",
|
|
775
|
+
time: "time",
|
|
776
|
+
datetime: "datetime",
|
|
777
|
+
timestamp: "timestamp",
|
|
778
|
+
json: "json",
|
|
779
|
+
blob: "blob"
|
|
780
|
+
},
|
|
781
|
+
sqlite: {
|
|
782
|
+
uuid: "text",
|
|
783
|
+
text: "text",
|
|
784
|
+
varchar: "varchar",
|
|
785
|
+
char: "char",
|
|
786
|
+
int: "int",
|
|
787
|
+
integer: "integer",
|
|
788
|
+
bigint: "bigint",
|
|
789
|
+
numeric: "numeric",
|
|
790
|
+
decimal: "decimal",
|
|
791
|
+
real: "real",
|
|
792
|
+
boolean: "boolean",
|
|
793
|
+
date: "date",
|
|
794
|
+
time: "time",
|
|
795
|
+
datetime: "datetime",
|
|
796
|
+
timestamp: "datetime",
|
|
797
|
+
json: "json",
|
|
798
|
+
blob: "blob"
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var portableDatatypeCastTypeByDialect = {
|
|
802
|
+
standard: portableDatatypeDdlTypeByDialect.standard,
|
|
803
|
+
postgres: portableDatatypeDdlTypeByDialect.postgres,
|
|
804
|
+
mysql: {
|
|
805
|
+
...portableDatatypeDdlTypeByDialect.mysql,
|
|
806
|
+
uuid: "char(36)",
|
|
807
|
+
text: "char",
|
|
808
|
+
varchar: "char",
|
|
809
|
+
char: "char",
|
|
810
|
+
int: "signed",
|
|
811
|
+
integer: "signed",
|
|
812
|
+
bigint: "signed",
|
|
813
|
+
numeric: "decimal",
|
|
814
|
+
decimal: "decimal",
|
|
815
|
+
boolean: "unsigned",
|
|
816
|
+
datetime: "datetime",
|
|
817
|
+
timestamp: "datetime",
|
|
818
|
+
blob: "binary"
|
|
819
|
+
},
|
|
820
|
+
sqlite: {
|
|
821
|
+
...portableDatatypeDdlTypeByDialect.sqlite,
|
|
822
|
+
uuid: "text",
|
|
823
|
+
int: "integer",
|
|
824
|
+
timestamp: "datetime"
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
var hasOwn = (value, key2) => Object.prototype.hasOwnProperty.call(value, key2);
|
|
828
|
+
var renderPortableDatatypeDdlType = (dialect, kind) => {
|
|
829
|
+
if (!hasOwn(portableDatatypeDdlTypeByDialect, dialect)) {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
const byKind = portableDatatypeDdlTypeByDialect[dialect];
|
|
833
|
+
return hasOwn(byKind, kind) ? byKind[kind] : undefined;
|
|
834
|
+
};
|
|
835
|
+
var renderPortableDatatypeCastType = (dialect, kind) => {
|
|
836
|
+
if (!hasOwn(portableDatatypeCastTypeByDialect, dialect)) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
const byKind = portableDatatypeCastTypeByDialect[dialect];
|
|
840
|
+
return hasOwn(byKind, kind) ? byKind[kind] : undefined;
|
|
841
|
+
};
|
|
842
|
+
var postgresDatatypeFamilies = {
|
|
843
|
+
text: {
|
|
844
|
+
compareGroup: "text",
|
|
845
|
+
castTargets: [
|
|
846
|
+
"text",
|
|
847
|
+
"numeric",
|
|
848
|
+
"boolean",
|
|
849
|
+
"date",
|
|
850
|
+
"time",
|
|
851
|
+
"timestamp",
|
|
852
|
+
"interval",
|
|
853
|
+
"binary",
|
|
854
|
+
"uuid",
|
|
855
|
+
"json",
|
|
856
|
+
"xml",
|
|
857
|
+
"bit",
|
|
858
|
+
"oid",
|
|
859
|
+
"identifier",
|
|
860
|
+
"network",
|
|
861
|
+
"spatial",
|
|
862
|
+
"textsearch",
|
|
863
|
+
"range",
|
|
864
|
+
"multirange",
|
|
865
|
+
"array",
|
|
866
|
+
"money",
|
|
867
|
+
"null"
|
|
868
|
+
],
|
|
869
|
+
traits: {
|
|
870
|
+
textual: true,
|
|
871
|
+
ordered: true
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
numeric: {
|
|
875
|
+
compareGroup: "numeric",
|
|
876
|
+
castTargets: ["numeric", "text", "boolean", "date", "time", "timestamp", "interval", "uuid", "bit", "oid", "money"],
|
|
877
|
+
traits: {
|
|
878
|
+
ordered: true
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
boolean: {
|
|
882
|
+
compareGroup: "boolean",
|
|
883
|
+
castTargets: ["boolean", "text", "numeric"],
|
|
884
|
+
traits: {}
|
|
885
|
+
},
|
|
886
|
+
date: {
|
|
887
|
+
compareGroup: "date",
|
|
888
|
+
castTargets: ["date", "timestamp", "text"],
|
|
889
|
+
traits: {
|
|
890
|
+
ordered: true
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
time: {
|
|
894
|
+
compareGroup: "time",
|
|
895
|
+
castTargets: ["time", "timestamp", "text"],
|
|
896
|
+
traits: {
|
|
897
|
+
ordered: true
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
timestamp: {
|
|
901
|
+
compareGroup: "timestamp",
|
|
902
|
+
castTargets: ["timestamp", "date", "text"],
|
|
903
|
+
traits: {
|
|
904
|
+
ordered: true
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
interval: {
|
|
908
|
+
compareGroup: "interval",
|
|
909
|
+
castTargets: ["interval", "text"],
|
|
910
|
+
traits: {
|
|
911
|
+
ordered: true
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
binary: {
|
|
915
|
+
compareGroup: "binary",
|
|
916
|
+
castTargets: ["binary", "text"],
|
|
917
|
+
traits: {}
|
|
918
|
+
},
|
|
919
|
+
uuid: {
|
|
920
|
+
compareGroup: "uuid",
|
|
921
|
+
castTargets: ["uuid", "text"],
|
|
922
|
+
traits: {
|
|
923
|
+
ordered: true
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
json: {
|
|
927
|
+
compareGroup: "json",
|
|
928
|
+
castTargets: ["json", "text"],
|
|
929
|
+
traits: {}
|
|
930
|
+
},
|
|
931
|
+
xml: {
|
|
932
|
+
compareGroup: "xml",
|
|
933
|
+
castTargets: ["xml", "text"],
|
|
934
|
+
traits: {}
|
|
935
|
+
},
|
|
936
|
+
bit: {
|
|
937
|
+
compareGroup: "bit",
|
|
938
|
+
castTargets: ["bit", "text", "numeric"],
|
|
939
|
+
traits: {}
|
|
940
|
+
},
|
|
941
|
+
oid: {
|
|
942
|
+
compareGroup: "oid",
|
|
943
|
+
castTargets: ["oid", "text", "numeric"],
|
|
944
|
+
traits: {
|
|
945
|
+
ordered: true
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
identifier: {
|
|
949
|
+
compareGroup: "identifier",
|
|
950
|
+
castTargets: ["identifier", "text"],
|
|
951
|
+
traits: {}
|
|
952
|
+
},
|
|
953
|
+
network: {
|
|
954
|
+
compareGroup: "network",
|
|
955
|
+
castTargets: ["network", "text"],
|
|
956
|
+
traits: {}
|
|
957
|
+
},
|
|
958
|
+
spatial: {
|
|
959
|
+
compareGroup: "spatial",
|
|
960
|
+
castTargets: ["spatial", "text"],
|
|
961
|
+
traits: {}
|
|
962
|
+
},
|
|
963
|
+
textsearch: {
|
|
964
|
+
compareGroup: "textsearch",
|
|
965
|
+
castTargets: ["textsearch", "text"],
|
|
966
|
+
traits: {}
|
|
967
|
+
},
|
|
968
|
+
range: {
|
|
969
|
+
compareGroup: "range",
|
|
970
|
+
castTargets: ["range", "text"],
|
|
971
|
+
traits: {}
|
|
972
|
+
},
|
|
973
|
+
multirange: {
|
|
974
|
+
compareGroup: "multirange",
|
|
975
|
+
castTargets: ["multirange", "text"],
|
|
976
|
+
traits: {}
|
|
977
|
+
},
|
|
978
|
+
enum: {
|
|
979
|
+
compareGroup: "enum",
|
|
980
|
+
castTargets: ["enum", "text"],
|
|
981
|
+
traits: {
|
|
982
|
+
textual: true,
|
|
983
|
+
ordered: true
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
record: {
|
|
987
|
+
compareGroup: "record",
|
|
988
|
+
castTargets: ["record", "text"],
|
|
989
|
+
traits: {}
|
|
990
|
+
},
|
|
991
|
+
array: {
|
|
992
|
+
compareGroup: "array",
|
|
993
|
+
castTargets: ["array", "text"],
|
|
994
|
+
traits: {}
|
|
995
|
+
},
|
|
996
|
+
money: {
|
|
997
|
+
compareGroup: "money",
|
|
998
|
+
castTargets: ["money", "text", "numeric"],
|
|
999
|
+
traits: {
|
|
1000
|
+
ordered: true
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
null: {
|
|
1004
|
+
compareGroup: "null",
|
|
1005
|
+
castTargets: [
|
|
1006
|
+
"text",
|
|
1007
|
+
"numeric",
|
|
1008
|
+
"boolean",
|
|
1009
|
+
"date",
|
|
1010
|
+
"time",
|
|
1011
|
+
"timestamp",
|
|
1012
|
+
"interval",
|
|
1013
|
+
"binary",
|
|
1014
|
+
"uuid",
|
|
1015
|
+
"json",
|
|
1016
|
+
"xml",
|
|
1017
|
+
"bit",
|
|
1018
|
+
"oid",
|
|
1019
|
+
"identifier",
|
|
1020
|
+
"network",
|
|
1021
|
+
"spatial",
|
|
1022
|
+
"textsearch",
|
|
1023
|
+
"range",
|
|
1024
|
+
"multirange",
|
|
1025
|
+
"array",
|
|
1026
|
+
"money",
|
|
1027
|
+
"null"
|
|
1028
|
+
],
|
|
1029
|
+
traits: {}
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
var postgresDatatypeKinds = {
|
|
1033
|
+
text: { family: "text", runtime: "string" },
|
|
1034
|
+
varchar: { family: "text", runtime: "string" },
|
|
1035
|
+
char: { family: "text", runtime: "string" },
|
|
1036
|
+
citext: { family: "text", runtime: "string" },
|
|
1037
|
+
name: { family: "text", runtime: "string" },
|
|
1038
|
+
uuid: { family: "uuid", runtime: "string" },
|
|
1039
|
+
int2: { family: "numeric", runtime: "number" },
|
|
1040
|
+
int4: { family: "numeric", runtime: "number" },
|
|
1041
|
+
int8: { family: "numeric", runtime: "bigintString" },
|
|
1042
|
+
numeric: { family: "numeric", runtime: "decimalString" },
|
|
1043
|
+
float4: { family: "numeric", runtime: "number" },
|
|
1044
|
+
float8: { family: "numeric", runtime: "number" },
|
|
1045
|
+
money: { family: "money", runtime: "number" },
|
|
1046
|
+
bool: { family: "boolean", runtime: "boolean" },
|
|
1047
|
+
date: { family: "date", runtime: "localDate" },
|
|
1048
|
+
time: { family: "time", runtime: "localTime" },
|
|
1049
|
+
timetz: { family: "time", runtime: "offsetTime" },
|
|
1050
|
+
timestamp: { family: "timestamp", runtime: "localDateTime" },
|
|
1051
|
+
timestamptz: { family: "timestamp", runtime: "instant" },
|
|
1052
|
+
interval: { family: "interval", runtime: "string" },
|
|
1053
|
+
bytea: { family: "binary", runtime: "bytes" },
|
|
1054
|
+
json: { family: "json", runtime: "json" },
|
|
1055
|
+
jsonb: { family: "json", runtime: "json" },
|
|
1056
|
+
xml: { family: "xml", runtime: "string" },
|
|
1057
|
+
bit: { family: "bit", runtime: "string" },
|
|
1058
|
+
varbit: { family: "bit", runtime: "string" },
|
|
1059
|
+
oid: { family: "oid", runtime: "number" },
|
|
1060
|
+
xid: { family: "oid", runtime: "number" },
|
|
1061
|
+
xid8: { family: "oid", runtime: "bigintString" },
|
|
1062
|
+
cid: { family: "oid", runtime: "number" },
|
|
1063
|
+
tid: { family: "identifier", runtime: "string" },
|
|
1064
|
+
regclass: { family: "identifier", runtime: "string" },
|
|
1065
|
+
regtype: { family: "identifier", runtime: "string" },
|
|
1066
|
+
regproc: { family: "identifier", runtime: "string" },
|
|
1067
|
+
regprocedure: { family: "identifier", runtime: "string" },
|
|
1068
|
+
regoper: { family: "identifier", runtime: "string" },
|
|
1069
|
+
regoperator: { family: "identifier", runtime: "string" },
|
|
1070
|
+
regconfig: { family: "identifier", runtime: "string" },
|
|
1071
|
+
regdictionary: { family: "identifier", runtime: "string" },
|
|
1072
|
+
pg_lsn: { family: "identifier", runtime: "string" },
|
|
1073
|
+
txid_snapshot: { family: "identifier", runtime: "string" },
|
|
1074
|
+
inet: { family: "network", runtime: "string" },
|
|
1075
|
+
cidr: { family: "network", runtime: "string" },
|
|
1076
|
+
macaddr: { family: "network", runtime: "string" },
|
|
1077
|
+
macaddr8: { family: "network", runtime: "string" },
|
|
1078
|
+
point: { family: "spatial", runtime: "unknown" },
|
|
1079
|
+
line: { family: "spatial", runtime: "unknown" },
|
|
1080
|
+
lseg: { family: "spatial", runtime: "unknown" },
|
|
1081
|
+
box: { family: "spatial", runtime: "unknown" },
|
|
1082
|
+
path: { family: "spatial", runtime: "unknown" },
|
|
1083
|
+
polygon: { family: "spatial", runtime: "unknown" },
|
|
1084
|
+
circle: { family: "spatial", runtime: "unknown" },
|
|
1085
|
+
tsvector: { family: "textsearch", runtime: "string" },
|
|
1086
|
+
tsquery: { family: "textsearch", runtime: "string" },
|
|
1087
|
+
int4range: { family: "range", runtime: "unknown" },
|
|
1088
|
+
int8range: { family: "range", runtime: "unknown" },
|
|
1089
|
+
numrange: { family: "range", runtime: "unknown" },
|
|
1090
|
+
tsrange: { family: "range", runtime: "unknown" },
|
|
1091
|
+
tstzrange: { family: "range", runtime: "unknown" },
|
|
1092
|
+
daterange: { family: "range", runtime: "unknown" },
|
|
1093
|
+
int4multirange: { family: "multirange", runtime: "unknown" },
|
|
1094
|
+
int8multirange: { family: "multirange", runtime: "unknown" },
|
|
1095
|
+
nummultirange: { family: "multirange", runtime: "unknown" },
|
|
1096
|
+
tsmultirange: { family: "multirange", runtime: "unknown" },
|
|
1097
|
+
tstzmultirange: { family: "multirange", runtime: "unknown" },
|
|
1098
|
+
datemultirange: { family: "multirange", runtime: "unknown" }
|
|
1099
|
+
};
|
|
1100
|
+
var postgresSpecificDatatypeKeys = [
|
|
1101
|
+
"int2",
|
|
1102
|
+
"int4",
|
|
1103
|
+
"int8",
|
|
1104
|
+
"float4",
|
|
1105
|
+
"float8",
|
|
1106
|
+
"money",
|
|
1107
|
+
"bool",
|
|
1108
|
+
"timetz",
|
|
1109
|
+
"timestamptz",
|
|
1110
|
+
"interval",
|
|
1111
|
+
"bytea",
|
|
1112
|
+
"citext",
|
|
1113
|
+
"name",
|
|
1114
|
+
"jsonb",
|
|
1115
|
+
"xml",
|
|
1116
|
+
"bit",
|
|
1117
|
+
"varbit",
|
|
1118
|
+
"oid",
|
|
1119
|
+
"xid",
|
|
1120
|
+
"xid8",
|
|
1121
|
+
"cid",
|
|
1122
|
+
"tid",
|
|
1123
|
+
"regclass",
|
|
1124
|
+
"regtype",
|
|
1125
|
+
"regproc",
|
|
1126
|
+
"regprocedure",
|
|
1127
|
+
"regoper",
|
|
1128
|
+
"regoperator",
|
|
1129
|
+
"regconfig",
|
|
1130
|
+
"regdictionary",
|
|
1131
|
+
"pg_lsn",
|
|
1132
|
+
"txid_snapshot",
|
|
1133
|
+
"inet",
|
|
1134
|
+
"cidr",
|
|
1135
|
+
"macaddr",
|
|
1136
|
+
"macaddr8",
|
|
1137
|
+
"point",
|
|
1138
|
+
"line",
|
|
1139
|
+
"lseg",
|
|
1140
|
+
"box",
|
|
1141
|
+
"path",
|
|
1142
|
+
"polygon",
|
|
1143
|
+
"circle",
|
|
1144
|
+
"tsvector",
|
|
1145
|
+
"tsquery",
|
|
1146
|
+
"int4range",
|
|
1147
|
+
"int8range",
|
|
1148
|
+
"numrange",
|
|
1149
|
+
"tsrange",
|
|
1150
|
+
"tstzrange",
|
|
1151
|
+
"daterange",
|
|
1152
|
+
"int4multirange",
|
|
1153
|
+
"int8multirange",
|
|
1154
|
+
"nummultirange",
|
|
1155
|
+
"tsmultirange",
|
|
1156
|
+
"tstzmultirange",
|
|
1157
|
+
"datemultirange"
|
|
1158
|
+
];
|
|
424
1159
|
var mysqlDatatypeFamilies = {
|
|
425
1160
|
text: {
|
|
426
1161
|
compareGroup: "text",
|
|
@@ -595,11 +1330,140 @@ var mysqlDatatypeKinds = {
|
|
|
595
1330
|
enum: { family: "enum", runtime: "string" },
|
|
596
1331
|
set: { family: "set", runtime: "string" }
|
|
597
1332
|
};
|
|
1333
|
+
var mysqlSpecificDatatypeKeys = [
|
|
1334
|
+
"tinytext",
|
|
1335
|
+
"mediumtext",
|
|
1336
|
+
"longtext",
|
|
1337
|
+
"tinyint",
|
|
1338
|
+
"smallint",
|
|
1339
|
+
"mediumint",
|
|
1340
|
+
"dec",
|
|
1341
|
+
"fixed",
|
|
1342
|
+
"float",
|
|
1343
|
+
"double",
|
|
1344
|
+
"bool",
|
|
1345
|
+
"bit",
|
|
1346
|
+
"year",
|
|
1347
|
+
"binary",
|
|
1348
|
+
"varbinary",
|
|
1349
|
+
"tinyblob",
|
|
1350
|
+
"mediumblob",
|
|
1351
|
+
"longblob",
|
|
1352
|
+
"geometry",
|
|
1353
|
+
"point",
|
|
1354
|
+
"linestring",
|
|
1355
|
+
"polygon",
|
|
1356
|
+
"multipoint",
|
|
1357
|
+
"multilinestring",
|
|
1358
|
+
"multipolygon",
|
|
1359
|
+
"geometrycollection"
|
|
1360
|
+
];
|
|
1361
|
+
var sqliteDatatypeFamilies = {
|
|
1362
|
+
text: {
|
|
1363
|
+
compareGroup: "text",
|
|
1364
|
+
castTargets: ["text", "numeric", "integer", "real", "boolean", "date", "time", "datetime", "json", "blob", "null"],
|
|
1365
|
+
traits: {
|
|
1366
|
+
textual: true,
|
|
1367
|
+
ordered: true
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
numeric: {
|
|
1371
|
+
compareGroup: "numeric",
|
|
1372
|
+
castTargets: ["numeric", "integer", "real", "text", "boolean", "date", "time", "datetime"],
|
|
1373
|
+
traits: {
|
|
1374
|
+
ordered: true
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
integer: {
|
|
1378
|
+
compareGroup: "numeric",
|
|
1379
|
+
castTargets: ["integer", "numeric", "real", "text", "boolean", "date", "time", "datetime"],
|
|
1380
|
+
traits: {
|
|
1381
|
+
ordered: true
|
|
1382
|
+
}
|
|
1383
|
+
},
|
|
1384
|
+
real: {
|
|
1385
|
+
compareGroup: "numeric",
|
|
1386
|
+
castTargets: ["real", "numeric", "integer", "text", "boolean"],
|
|
1387
|
+
traits: {
|
|
1388
|
+
ordered: true
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
boolean: {
|
|
1392
|
+
compareGroup: "boolean",
|
|
1393
|
+
castTargets: ["boolean", "integer", "numeric", "text"],
|
|
1394
|
+
traits: {}
|
|
1395
|
+
},
|
|
1396
|
+
date: {
|
|
1397
|
+
compareGroup: "date",
|
|
1398
|
+
castTargets: ["date", "time", "datetime", "text", "numeric", "integer"],
|
|
1399
|
+
traits: {
|
|
1400
|
+
ordered: true
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
time: {
|
|
1404
|
+
compareGroup: "time",
|
|
1405
|
+
castTargets: ["time", "date", "datetime", "text", "numeric", "integer"],
|
|
1406
|
+
traits: {
|
|
1407
|
+
ordered: true
|
|
1408
|
+
}
|
|
1409
|
+
},
|
|
1410
|
+
datetime: {
|
|
1411
|
+
compareGroup: "datetime",
|
|
1412
|
+
castTargets: ["datetime", "date", "time", "text", "numeric", "integer"],
|
|
1413
|
+
traits: {
|
|
1414
|
+
ordered: true
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
json: {
|
|
1418
|
+
compareGroup: "json",
|
|
1419
|
+
castTargets: ["json", "text"],
|
|
1420
|
+
traits: {}
|
|
1421
|
+
},
|
|
1422
|
+
blob: {
|
|
1423
|
+
compareGroup: "blob",
|
|
1424
|
+
castTargets: ["blob", "text"],
|
|
1425
|
+
traits: {}
|
|
1426
|
+
},
|
|
1427
|
+
null: {
|
|
1428
|
+
compareGroup: "null",
|
|
1429
|
+
castTargets: ["text", "numeric", "integer", "real", "boolean", "date", "time", "datetime", "json", "blob", "null"],
|
|
1430
|
+
traits: {}
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
var sqliteDatatypeKinds = {
|
|
1434
|
+
text: { family: "text", runtime: "string" },
|
|
1435
|
+
varchar: { family: "text", runtime: "string" },
|
|
1436
|
+
char: { family: "text", runtime: "string" },
|
|
1437
|
+
clob: { family: "text", runtime: "string" },
|
|
1438
|
+
int: { family: "integer", runtime: "number" },
|
|
1439
|
+
integer: { family: "integer", runtime: "number" },
|
|
1440
|
+
bigint: { family: "integer", runtime: "bigintString" },
|
|
1441
|
+
numeric: { family: "numeric", runtime: "decimalString" },
|
|
1442
|
+
decimal: { family: "numeric", runtime: "decimalString" },
|
|
1443
|
+
real: { family: "real", runtime: "number" },
|
|
1444
|
+
double: { family: "real", runtime: "number" },
|
|
1445
|
+
boolean: { family: "boolean", runtime: "boolean" },
|
|
1446
|
+
date: { family: "date", runtime: "localDate" },
|
|
1447
|
+
time: { family: "time", runtime: "localTime" },
|
|
1448
|
+
datetime: { family: "datetime", runtime: "localDateTime" },
|
|
1449
|
+
timestamp: { family: "datetime", runtime: "localDateTime" },
|
|
1450
|
+
json: { family: "json", runtime: "json" },
|
|
1451
|
+
blob: { family: "blob", runtime: "bytes" }
|
|
1452
|
+
};
|
|
1453
|
+
var sqliteSpecificDatatypeKeys = [
|
|
1454
|
+
"clob",
|
|
1455
|
+
"double"
|
|
1456
|
+
];
|
|
1457
|
+
var pickDatatypeConstructors = (module, keys) => Object.fromEntries(keys.map((key2) => [key2, module[key2]]));
|
|
1458
|
+
|
|
1459
|
+
// src/mysql/datatypes/spec.ts
|
|
1460
|
+
var mysqlDatatypeFamilies2 = mysqlDatatypeFamilies;
|
|
1461
|
+
var mysqlDatatypeKinds2 = mysqlDatatypeKinds;
|
|
598
1462
|
|
|
599
1463
|
// src/mysql/datatypes/index.ts
|
|
600
1464
|
var withMetadata = (kind) => {
|
|
601
|
-
const kindSpec =
|
|
602
|
-
const familySpec =
|
|
1465
|
+
const kindSpec = mysqlDatatypeKinds2[kind];
|
|
1466
|
+
const familySpec = mysqlDatatypeFamilies2[kindSpec.family];
|
|
603
1467
|
return {
|
|
604
1468
|
dialect: "mysql",
|
|
605
1469
|
kind,
|
|
@@ -607,6 +1471,7 @@ var withMetadata = (kind) => {
|
|
|
607
1471
|
runtime: kindSpec.runtime,
|
|
608
1472
|
compareGroup: familySpec?.compareGroup,
|
|
609
1473
|
castTargets: familySpec?.castTargets,
|
|
1474
|
+
implicitTargets: familySpec.implicitTargets,
|
|
610
1475
|
traits: familySpec?.traits
|
|
611
1476
|
};
|
|
612
1477
|
};
|
|
@@ -627,7 +1492,7 @@ var mysqlDatatypeModule = {
|
|
|
627
1492
|
}
|
|
628
1493
|
})
|
|
629
1494
|
};
|
|
630
|
-
for (const kind of Object.keys(
|
|
1495
|
+
for (const kind of Object.keys(mysqlDatatypeKinds2)) {
|
|
631
1496
|
mysqlDatatypeModule[kind] = () => withMetadata(kind);
|
|
632
1497
|
}
|
|
633
1498
|
mysqlDatatypeModule.json = () => ({
|
|
@@ -109637,7 +110502,7 @@ var mysqlKnownErrorClassesBySymbol = {
|
|
|
109637
110502
|
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
109638
110503
|
var unwrapMysqlDriverCause = (cause) => {
|
|
109639
110504
|
let current = cause;
|
|
109640
|
-
while (isRecord(current) && "_tag" in current &&
|
|
110505
|
+
while (isRecord(current) && "_tag" in current && "cause" in current) {
|
|
109641
110506
|
current = current.cause;
|
|
109642
110507
|
}
|
|
109643
110508
|
return current;
|
|
@@ -109785,65 +110650,33 @@ var narrowMysqlDriverErrorForReadQuery = (error) => {
|
|
|
109785
110650
|
// src/mysql/json.ts
|
|
109786
110651
|
var exports_json = {};
|
|
109787
110652
|
__export(exports_json, {
|
|
109788
|
-
wildcard: () => wildcard2,
|
|
109789
110653
|
typeOf: () => typeOf,
|
|
109790
|
-
traverseText: () => traverseText,
|
|
109791
|
-
traverse: () => traverse,
|
|
109792
|
-
toJsonb: () => toJsonb,
|
|
109793
|
-
toJson: () => toJson,
|
|
109794
|
-
text: () => text,
|
|
109795
110654
|
stripNulls: () => stripNulls,
|
|
109796
|
-
slice: () => slice2,
|
|
109797
|
-
set: () => set2,
|
|
109798
|
-
remove: () => remove,
|
|
109799
110655
|
pathMatch: () => pathMatch,
|
|
109800
|
-
|
|
109801
|
-
path: () => path2,
|
|
109802
|
-
merge: () => merge2,
|
|
109803
|
-
length: () => length,
|
|
109804
|
-
keys: () => keys,
|
|
109805
|
-
keyExists: () => keyExists,
|
|
109806
|
-
key: () => key2,
|
|
109807
|
-
json: () => json,
|
|
109808
|
-
insert: () => insert,
|
|
109809
|
-
index: () => index4,
|
|
109810
|
-
hasKey: () => hasKey,
|
|
109811
|
-
hasAnyKeys: () => hasAnyKeys,
|
|
109812
|
-
hasAllKeys: () => hasAllKeys,
|
|
109813
|
-
get: () => get,
|
|
109814
|
-
descend: () => descend2,
|
|
109815
|
-
delete_: () => delete_2,
|
|
109816
|
-
delete: () => delete_2,
|
|
109817
|
-
contains: () => contains,
|
|
109818
|
-
containedBy: () => containedBy,
|
|
109819
|
-
concat: () => concat,
|
|
109820
|
-
buildObject: () => buildObject,
|
|
109821
|
-
buildArray: () => buildArray,
|
|
109822
|
-
accessText: () => accessText,
|
|
109823
|
-
access: () => access
|
|
110656
|
+
length: () => length
|
|
109824
110657
|
});
|
|
109825
110658
|
|
|
109826
110659
|
// src/mysql/internal/dsl.ts
|
|
109827
|
-
import { pipeArguments as
|
|
110660
|
+
import { pipeArguments as pipeArguments7 } from "effect/Pipeable";
|
|
109828
110661
|
import * as Schema6 from "effect/Schema";
|
|
109829
110662
|
|
|
109830
110663
|
// src/internal/row-set.ts
|
|
109831
110664
|
var exports_row_set = {};
|
|
109832
110665
|
__export(exports_row_set, {
|
|
109833
|
-
TypeId: () =>
|
|
110666
|
+
TypeId: () => TypeId4
|
|
109834
110667
|
});
|
|
109835
|
-
var
|
|
110668
|
+
var TypeId4 = Symbol.for("effect-qb/Plan");
|
|
109836
110669
|
|
|
109837
110670
|
// src/internal/table.ts
|
|
109838
|
-
import { pipeArguments as
|
|
110671
|
+
import { pipeArguments as pipeArguments4 } from "effect/Pipeable";
|
|
109839
110672
|
|
|
109840
110673
|
// src/internal/schema-expression.ts
|
|
109841
110674
|
import { parse, toSql } from "pgsql-ast-parser";
|
|
109842
|
-
import { pipeArguments as
|
|
109843
|
-
var
|
|
110675
|
+
import { pipeArguments as pipeArguments3 } from "effect/Pipeable";
|
|
110676
|
+
var TypeId5 = Symbol.for("effect-qb/SchemaExpression");
|
|
109844
110677
|
var SchemaExpressionProto = {
|
|
109845
110678
|
pipe() {
|
|
109846
|
-
return
|
|
110679
|
+
return pipeArguments3(this, arguments);
|
|
109847
110680
|
}
|
|
109848
110681
|
};
|
|
109849
110682
|
var attachPipe2 = (value) => {
|
|
@@ -109851,35 +110684,35 @@ var attachPipe2 = (value) => {
|
|
|
109851
110684
|
configurable: true,
|
|
109852
110685
|
writable: true,
|
|
109853
110686
|
value: function() {
|
|
109854
|
-
return
|
|
110687
|
+
return pipeArguments3(value, arguments);
|
|
109855
110688
|
}
|
|
109856
110689
|
});
|
|
109857
110690
|
return value;
|
|
109858
110691
|
};
|
|
109859
|
-
var isSchemaExpression = (value) => typeof value === "object" && value !== null && (
|
|
110692
|
+
var isSchemaExpression = (value) => typeof value === "object" && value !== null && (TypeId5 in value);
|
|
109860
110693
|
var fromAst = (ast) => {
|
|
109861
110694
|
const expression = attachPipe2(Object.create(SchemaExpressionProto));
|
|
109862
|
-
expression[
|
|
110695
|
+
expression[TypeId5] = {
|
|
109863
110696
|
ast
|
|
109864
110697
|
};
|
|
109865
110698
|
return expression;
|
|
109866
110699
|
};
|
|
109867
110700
|
var fromSql = (sql) => {
|
|
109868
110701
|
const expression = attachPipe2(Object.create(SchemaExpressionProto));
|
|
109869
|
-
expression[
|
|
110702
|
+
expression[TypeId5] = {
|
|
109870
110703
|
sql: sql.trim()
|
|
109871
110704
|
};
|
|
109872
110705
|
return expression;
|
|
109873
110706
|
};
|
|
109874
110707
|
var parseExpression = (sql) => fromAst(parse(sql, "expr"));
|
|
109875
110708
|
var toAst = (expression) => {
|
|
109876
|
-
const ast = expression[
|
|
110709
|
+
const ast = expression[TypeId5].ast;
|
|
109877
110710
|
if (ast !== undefined) {
|
|
109878
110711
|
return ast;
|
|
109879
110712
|
}
|
|
109880
110713
|
return parse(render(expression), "expr");
|
|
109881
110714
|
};
|
|
109882
|
-
var render = (expression) => expression[
|
|
110715
|
+
var render = (expression) => expression[TypeId5].sql ?? toSql.expr(toAst(expression));
|
|
109883
110716
|
var normalize2 = (expression) => (() => {
|
|
109884
110717
|
const sql = render(expression);
|
|
109885
110718
|
try {
|
|
@@ -109974,7 +110807,7 @@ var collectInlineOptions = (fields2) => {
|
|
|
109974
110807
|
return options;
|
|
109975
110808
|
};
|
|
109976
110809
|
var resolvePrimaryKeyColumns = (fields2, declaredOptions) => {
|
|
109977
|
-
const inline = Object.entries(fields2).filter(([, column]) => column.metadata.primaryKey).map(([
|
|
110810
|
+
const inline = Object.entries(fields2).filter(([, column]) => column.metadata.primaryKey).map(([key2]) => key2);
|
|
109978
110811
|
const explicit = declaredOptions.flatMap((option) => {
|
|
109979
110812
|
if (typeof option !== "object" || option === null || !("kind" in option) || option.kind !== "primaryKey") {
|
|
109980
110813
|
return [];
|
|
@@ -110000,8 +110833,8 @@ var validateOptions = (tableName, fields2, options) => {
|
|
|
110000
110833
|
case "foreignKey": {
|
|
110001
110834
|
if (option.kind === "index") {
|
|
110002
110835
|
const keys = Array.isArray(option.keys) ? option.keys : [];
|
|
110003
|
-
for (const
|
|
110004
|
-
if (typeof
|
|
110836
|
+
for (const key2 of keys) {
|
|
110837
|
+
if (typeof key2 !== "object" || key2 === null || !("kind" in key2)) {
|
|
110005
110838
|
continue;
|
|
110006
110839
|
}
|
|
110007
110840
|
}
|
|
@@ -110048,10 +110881,10 @@ var fieldSchemaForVariant = (variant, column, tableName, columnName, primaryKeyS
|
|
|
110048
110881
|
var deriveSchema = (variant, tableName, fields2, primaryKeyColumns) => {
|
|
110049
110882
|
const primaryKeySet = new Set(primaryKeyColumns);
|
|
110050
110883
|
const structFields = {};
|
|
110051
|
-
for (const [
|
|
110052
|
-
const schema2 = fieldSchemaForVariant(variant, column, tableName,
|
|
110884
|
+
for (const [key2, column] of Object.entries(fields2)) {
|
|
110885
|
+
const schema2 = fieldSchemaForVariant(variant, column, tableName, key2, primaryKeySet);
|
|
110053
110886
|
if (schema2 !== undefined) {
|
|
110054
|
-
structFields[
|
|
110887
|
+
structFields[key2] = schema2;
|
|
110055
110888
|
}
|
|
110056
110889
|
}
|
|
110057
110890
|
return Schema5.Struct(structFields);
|
|
@@ -110061,7 +110894,7 @@ var deriveInsertSchema = (tableName, fields2, primaryKeyColumns) => deriveSchema
|
|
|
110061
110894
|
var deriveUpdateSchema = (tableName, fields2, primaryKeyColumns) => deriveSchema("update", tableName, fields2, primaryKeyColumns);
|
|
110062
110895
|
|
|
110063
110896
|
// src/internal/casing.ts
|
|
110064
|
-
var
|
|
110897
|
+
var TypeId6 = Symbol.for("effect-qb/Casing");
|
|
110065
110898
|
var merge = (base, override) => {
|
|
110066
110899
|
if (base === undefined) {
|
|
110067
110900
|
return override;
|
|
@@ -110102,15 +110935,16 @@ var apply = (style, name) => {
|
|
|
110102
110935
|
var applyCategory = (options, category, name) => apply(options?.[category], name);
|
|
110103
110936
|
|
|
110104
110937
|
// src/internal/table.ts
|
|
110105
|
-
var
|
|
110938
|
+
var TypeId7 = Symbol.for("effect-qb/Table");
|
|
110106
110939
|
var OptionsSymbol = Symbol.for("effect-qb/Table/normalizedOptions");
|
|
110107
110940
|
var options = Symbol.for("effect-qb/Table/declaredOptions");
|
|
110108
110941
|
var CacheSymbol = Symbol.for("effect-qb/Table/cache");
|
|
110109
110942
|
var SchemaCacheSymbol = Symbol.for("effect-qb/Table/schemaCache");
|
|
110110
110943
|
var DeclaredOptionsSymbol = Symbol.for("effect-qb/Table/factoryDeclaredOptions");
|
|
110944
|
+
var ResolveOptionSymbol = Symbol.for("effect-qb/Table/resolveOption");
|
|
110111
110945
|
var TableProto = {
|
|
110112
110946
|
pipe() {
|
|
110113
|
-
return
|
|
110947
|
+
return pipeArguments4(this, arguments);
|
|
110114
110948
|
}
|
|
110115
110949
|
};
|
|
110116
110950
|
var attachPipe3 = (value) => {
|
|
@@ -110118,21 +110952,50 @@ var attachPipe3 = (value) => {
|
|
|
110118
110952
|
configurable: true,
|
|
110119
110953
|
writable: true,
|
|
110120
110954
|
value: function() {
|
|
110121
|
-
return
|
|
110955
|
+
return pipeArguments4(value, arguments);
|
|
110122
110956
|
}
|
|
110123
110957
|
});
|
|
110124
110958
|
return value;
|
|
110125
110959
|
};
|
|
110960
|
+
var conflictArbitersFromOptions = (options2) => options2.flatMap((option) => {
|
|
110961
|
+
if (typeof option !== "object" || option === null) {
|
|
110962
|
+
return [];
|
|
110963
|
+
}
|
|
110964
|
+
if (!("columns" in option) || !Array.isArray(option.columns) || option.columns.length === 0) {
|
|
110965
|
+
return [];
|
|
110966
|
+
}
|
|
110967
|
+
switch (option.kind) {
|
|
110968
|
+
case "primaryKey":
|
|
110969
|
+
case "unique":
|
|
110970
|
+
return [{
|
|
110971
|
+
columns: option.columns,
|
|
110972
|
+
scope: "unconditional",
|
|
110973
|
+
name: option.name,
|
|
110974
|
+
constraint: true
|
|
110975
|
+
}];
|
|
110976
|
+
case "index":
|
|
110977
|
+
return option.unique === true ? [{
|
|
110978
|
+
columns: option.columns,
|
|
110979
|
+
scope: option.predicate === undefined ? "unconditional" : "partial",
|
|
110980
|
+
name: option.name,
|
|
110981
|
+
constraint: false
|
|
110982
|
+
}] : [];
|
|
110983
|
+
default:
|
|
110984
|
+
return [];
|
|
110985
|
+
}
|
|
110986
|
+
});
|
|
110126
110987
|
var buildArtifacts = (name, fields2, declaredOptions, schemaName, casing) => {
|
|
110127
110988
|
const normalizedOptions = [...collectInlineOptions(fields2), ...declaredOptions];
|
|
110128
110989
|
validateFieldDialects(name, fields2);
|
|
110129
110990
|
validateOptions(name, fields2, declaredOptions);
|
|
110130
110991
|
const primaryKey2 = resolvePrimaryKeyColumns(fields2, declaredOptions);
|
|
110131
|
-
const
|
|
110992
|
+
const conflictArbiters = conflictArbitersFromOptions(normalizedOptions);
|
|
110993
|
+
const columns = Object.fromEntries(Object.entries(fields2).map(([key2, column]) => [key2, bindColumn(name, key2, column, name, schemaName, casing)]));
|
|
110132
110994
|
return {
|
|
110133
110995
|
columns,
|
|
110134
110996
|
normalizedOptions,
|
|
110135
|
-
primaryKey: primaryKey2
|
|
110997
|
+
primaryKey: primaryKey2,
|
|
110998
|
+
conflictArbiters
|
|
110136
110999
|
};
|
|
110137
111000
|
};
|
|
110138
111001
|
var getSchemaCache = (table) => {
|
|
@@ -110148,7 +111011,7 @@ var getSchemaCache = (table) => {
|
|
|
110148
111011
|
return cache;
|
|
110149
111012
|
};
|
|
110150
111013
|
var deriveTableSchema = (table, variant) => {
|
|
110151
|
-
const state = table[
|
|
111014
|
+
const state = table[TypeId7];
|
|
110152
111015
|
switch (variant) {
|
|
110153
111016
|
case "select":
|
|
110154
111017
|
return deriveSelectSchema(state.name, state.fields, state.primaryKey);
|
|
@@ -110217,16 +111080,17 @@ var makeTable = (name, fields2, declaredOptions, baseName = name, kind = "schema
|
|
|
110217
111080
|
table.name = name;
|
|
110218
111081
|
table.columns = artifacts.columns;
|
|
110219
111082
|
defineSchemasGetter(table);
|
|
110220
|
-
table[
|
|
111083
|
+
table[TypeId7] = {
|
|
110221
111084
|
name,
|
|
110222
111085
|
baseName,
|
|
110223
111086
|
schemaName: resolvedSchemaName,
|
|
110224
111087
|
fields: fields2,
|
|
110225
111088
|
primaryKey: artifacts.primaryKey,
|
|
111089
|
+
conflictArbiters: artifacts.conflictArbiters,
|
|
110226
111090
|
kind,
|
|
110227
111091
|
casing
|
|
110228
111092
|
};
|
|
110229
|
-
table[
|
|
111093
|
+
table[TypeId4] = {
|
|
110230
111094
|
selection: artifacts.columns,
|
|
110231
111095
|
required: undefined,
|
|
110232
111096
|
available: {
|
|
@@ -110240,8 +111104,8 @@ var makeTable = (name, fields2, declaredOptions, baseName = name, kind = "schema
|
|
|
110240
111104
|
};
|
|
110241
111105
|
table[OptionsSymbol] = artifacts.normalizedOptions;
|
|
110242
111106
|
table[DeclaredOptionsSymbol] = declaredOptions;
|
|
110243
|
-
for (const [
|
|
110244
|
-
Object.defineProperty(table,
|
|
111107
|
+
for (const [key2, value] of Object.entries(artifacts.columns)) {
|
|
111108
|
+
Object.defineProperty(table, key2, {
|
|
110245
111109
|
enumerable: true,
|
|
110246
111110
|
value
|
|
110247
111111
|
});
|
|
@@ -110279,13 +111143,14 @@ var ensureClassArtifacts = (self) => {
|
|
|
110279
111143
|
if (cached) {
|
|
110280
111144
|
return cached;
|
|
110281
111145
|
}
|
|
110282
|
-
const state = self[
|
|
111146
|
+
const state = self[TypeId7];
|
|
110283
111147
|
const classOptions = self[options];
|
|
110284
111148
|
const table = applyDeclaredOptions(makeTable(state.name, state.fields, [], state.name, "schema", state.schemaName, state.schemaName === undefined || state.schemaName === "public" ? "default" : "explicit", state.casing), classOptions);
|
|
110285
111149
|
const artifacts = {
|
|
110286
111150
|
columns: table.columns,
|
|
110287
111151
|
normalizedOptions: table[OptionsSymbol],
|
|
110288
|
-
primaryKey: table[
|
|
111152
|
+
primaryKey: table[TypeId7].primaryKey,
|
|
111153
|
+
conflictArbiters: table[TypeId7].conflictArbiters
|
|
110289
111154
|
};
|
|
110290
111155
|
Object.defineProperty(self, CacheSymbol, {
|
|
110291
111156
|
configurable: true,
|
|
@@ -110294,42 +111159,58 @@ var ensureClassArtifacts = (self) => {
|
|
|
110294
111159
|
return artifacts;
|
|
110295
111160
|
};
|
|
110296
111161
|
var appendOption = (table, option) => {
|
|
110297
|
-
const state = table[
|
|
111162
|
+
const state = table[TypeId7];
|
|
110298
111163
|
return makeTable(state.name, state.fields, [...table[DeclaredOptionsSymbol], option], state.baseName, state.kind, state.schemaName, "explicit", state.casing);
|
|
110299
111164
|
};
|
|
110300
111165
|
var makeOption = (option) => {
|
|
110301
111166
|
return attachPipe3(Object.assign((table, ..._validation) => appendOption(table, option), { option }));
|
|
110302
111167
|
};
|
|
111168
|
+
var makeResolvedOption = (option, resolve) => {
|
|
111169
|
+
return attachPipe3(Object.assign((table, ..._validation) => appendOption(table, resolve(table)), {
|
|
111170
|
+
option,
|
|
111171
|
+
[ResolveOptionSymbol]: resolve
|
|
111172
|
+
}));
|
|
111173
|
+
};
|
|
110303
111174
|
var option = (spec) => makeOption(spec);
|
|
111175
|
+
var optionFromTable = (spec, resolve) => makeResolvedOption(spec, resolve);
|
|
111176
|
+
var resolveOption = (option2, table) => {
|
|
111177
|
+
const resolve = option2[ResolveOptionSymbol];
|
|
111178
|
+
return resolve === undefined ? option2.option : resolve(table);
|
|
111179
|
+
};
|
|
111180
|
+
var mapOption = (option2, map) => {
|
|
111181
|
+
const resolve = option2[ResolveOptionSymbol];
|
|
111182
|
+
return resolve === undefined ? makeOption(map(option2.option)) : makeResolvedOption(map(option2.option), (table) => map(resolve(table)));
|
|
111183
|
+
};
|
|
110304
111184
|
function make(name, fields2, schemaName) {
|
|
110305
111185
|
const resolvedSchemaName = arguments.length >= 3 ? schemaName : "public";
|
|
110306
111186
|
return makeTable(name, fields2, [], name, "schema", resolvedSchemaName, arguments.length >= 3 ? "explicit" : "default");
|
|
110307
111187
|
}
|
|
110308
111188
|
var withCasing = (table, casing) => {
|
|
110309
|
-
const state = table[
|
|
111189
|
+
const state = table[TypeId7];
|
|
110310
111190
|
return makeTable(state.name, state.fields, table[DeclaredOptionsSymbol], state.baseName, state.kind, state.schemaName, "explicit", merge(state.casing, casing));
|
|
110311
111191
|
};
|
|
110312
111192
|
var withSchema = (table, schemaName, schemaCasing) => {
|
|
110313
|
-
const state = table[
|
|
111193
|
+
const state = table[TypeId7];
|
|
110314
111194
|
return makeTable(state.name, state.fields, table[DeclaredOptionsSymbol], state.baseName, state.kind, schemaName, "explicit", merge(schemaCasing, state.casing));
|
|
110315
111195
|
};
|
|
110316
111196
|
var alias = (table, aliasName) => {
|
|
110317
|
-
const state = table[
|
|
110318
|
-
const columns = Object.fromEntries(Object.entries(state.fields).map(([
|
|
111197
|
+
const state = table[TypeId7];
|
|
111198
|
+
const columns = Object.fromEntries(Object.entries(state.fields).map(([key2, column]) => [key2, bindColumn(aliasName, key2, column, state.baseName, state.schemaName, state.casing)]));
|
|
110319
111199
|
const aliased = attachPipe3(Object.create(TableProto));
|
|
110320
111200
|
aliased.name = aliasName;
|
|
110321
111201
|
aliased.columns = columns;
|
|
110322
111202
|
defineSchemasGetter(aliased);
|
|
110323
|
-
aliased[
|
|
111203
|
+
aliased[TypeId7] = {
|
|
110324
111204
|
name: aliasName,
|
|
110325
111205
|
baseName: state.baseName,
|
|
110326
111206
|
schemaName: state.schemaName,
|
|
110327
111207
|
fields: state.fields,
|
|
110328
111208
|
primaryKey: state.primaryKey,
|
|
111209
|
+
conflictArbiters: state.conflictArbiters,
|
|
110329
111210
|
kind: "alias",
|
|
110330
111211
|
casing: state.casing
|
|
110331
111212
|
};
|
|
110332
|
-
aliased[
|
|
111213
|
+
aliased[TypeId4] = {
|
|
110333
111214
|
selection: columns,
|
|
110334
111215
|
required: undefined,
|
|
110335
111216
|
available: {
|
|
@@ -110339,12 +111220,12 @@ var alias = (table, aliasName) => {
|
|
|
110339
111220
|
baseName: state.baseName
|
|
110340
111221
|
}
|
|
110341
111222
|
},
|
|
110342
|
-
dialect: table[
|
|
111223
|
+
dialect: table[TypeId4].dialect
|
|
110343
111224
|
};
|
|
110344
111225
|
aliased[OptionsSymbol] = table[OptionsSymbol];
|
|
110345
111226
|
aliased[DeclaredOptionsSymbol] = table[DeclaredOptionsSymbol];
|
|
110346
|
-
for (const [
|
|
110347
|
-
Object.defineProperty(aliased,
|
|
111227
|
+
for (const [key2, value] of Object.entries(columns)) {
|
|
111228
|
+
Object.defineProperty(aliased, key2, {
|
|
110348
111229
|
enumerable: true,
|
|
110349
111230
|
value
|
|
110350
111231
|
});
|
|
@@ -110363,18 +111244,20 @@ function Class(name, schemaName) {
|
|
|
110363
111244
|
static get schemas() {
|
|
110364
111245
|
return schemasFor(this);
|
|
110365
111246
|
}
|
|
110366
|
-
static get [
|
|
111247
|
+
static get [TypeId7]() {
|
|
110367
111248
|
const declaredOptions = extractDeclaredOptions(this[options]);
|
|
111249
|
+
const normalizedOptions = [...collectInlineOptions(fields2), ...declaredOptions];
|
|
110368
111250
|
return {
|
|
110369
111251
|
name,
|
|
110370
111252
|
baseName: name,
|
|
110371
111253
|
schemaName: resolvedSchemaName,
|
|
110372
111254
|
fields: fields2,
|
|
110373
111255
|
primaryKey: resolvePrimaryKeyColumns(fields2, collectInlineOptions(fields2)),
|
|
111256
|
+
conflictArbiters: conflictArbitersFromOptions(normalizedOptions),
|
|
110374
111257
|
kind: "schema"
|
|
110375
111258
|
};
|
|
110376
111259
|
}
|
|
110377
|
-
static get [
|
|
111260
|
+
static get [TypeId4]() {
|
|
110378
111261
|
const artifacts = ensureClassArtifacts(this);
|
|
110379
111262
|
return {
|
|
110380
111263
|
selection: artifacts.columns,
|
|
@@ -110393,49 +111276,83 @@ function Class(name, schemaName) {
|
|
|
110393
111276
|
return ensureClassArtifacts(this).normalizedOptions;
|
|
110394
111277
|
}
|
|
110395
111278
|
static pipe() {
|
|
110396
|
-
return
|
|
111279
|
+
return pipeArguments4(this, arguments);
|
|
110397
111280
|
}
|
|
110398
111281
|
}
|
|
110399
|
-
for (const
|
|
110400
|
-
Object.defineProperty(TableClassBase,
|
|
111282
|
+
for (const key2 of Object.keys(fields2)) {
|
|
111283
|
+
Object.defineProperty(TableClassBase, key2, {
|
|
110401
111284
|
enumerable: true,
|
|
110402
111285
|
configurable: true,
|
|
110403
111286
|
get() {
|
|
110404
|
-
return ensureClassArtifacts(this).columns[
|
|
111287
|
+
return ensureClassArtifacts(this).columns[key2];
|
|
110405
111288
|
}
|
|
110406
111289
|
});
|
|
110407
111290
|
}
|
|
110408
111291
|
return TableClassBase;
|
|
110409
111292
|
};
|
|
110410
111293
|
}
|
|
110411
|
-
var
|
|
110412
|
-
|
|
110413
|
-
|
|
110414
|
-
|
|
110415
|
-
|
|
110416
|
-
|
|
110417
|
-
|
|
110418
|
-
|
|
110419
|
-
|
|
110420
|
-
|
|
110421
|
-
|
|
110422
|
-
}
|
|
110423
|
-
|
|
110424
|
-
|
|
110425
|
-
|
|
110426
|
-
|
|
110427
|
-
|
|
110428
|
-
|
|
110429
|
-
|
|
110430
|
-
columns:
|
|
110431
|
-
|
|
110432
|
-
|
|
110433
|
-
|
|
110434
|
-
|
|
110435
|
-
|
|
110436
|
-
|
|
110437
|
-
|
|
110438
|
-
|
|
111294
|
+
var selectionArray = (selection) => Array.isArray(selection) ? selection : [selection];
|
|
111295
|
+
var selectedColumnList = (selection) => selectionArray(selection).map((column) => column[BoundColumnTypeId].columnName);
|
|
111296
|
+
var referenceFromSelection = (selection) => {
|
|
111297
|
+
const columns = selectionArray(selection);
|
|
111298
|
+
const first = columns[0];
|
|
111299
|
+
const bound = first[BoundColumnTypeId];
|
|
111300
|
+
return {
|
|
111301
|
+
tableName: bound.baseTableName,
|
|
111302
|
+
schemaName: bound.schemaName,
|
|
111303
|
+
casing: bound.casing,
|
|
111304
|
+
columns: columns.map((column) => column[BoundColumnTypeId].columnName)
|
|
111305
|
+
};
|
|
111306
|
+
};
|
|
111307
|
+
function primaryKey2(columns) {
|
|
111308
|
+
return makeResolvedOption({
|
|
111309
|
+
kind: "primaryKey",
|
|
111310
|
+
columns: []
|
|
111311
|
+
}, (table) => ({
|
|
111312
|
+
kind: "primaryKey",
|
|
111313
|
+
columns: selectedColumnList(columns(table))
|
|
111314
|
+
}));
|
|
111315
|
+
}
|
|
111316
|
+
function unique2(columns) {
|
|
111317
|
+
return makeResolvedOption({
|
|
111318
|
+
kind: "unique",
|
|
111319
|
+
columns: []
|
|
111320
|
+
}, (table) => ({
|
|
111321
|
+
kind: "unique",
|
|
111322
|
+
columns: selectedColumnList(columns(table))
|
|
111323
|
+
}));
|
|
111324
|
+
}
|
|
111325
|
+
function index3(columns) {
|
|
111326
|
+
return makeResolvedOption({
|
|
111327
|
+
kind: "index",
|
|
111328
|
+
columns: []
|
|
111329
|
+
}, (table) => ({
|
|
111330
|
+
kind: "index",
|
|
111331
|
+
columns: selectedColumnList(columns(table))
|
|
111332
|
+
}));
|
|
111333
|
+
}
|
|
111334
|
+
function foreignKey2(columns, target) {
|
|
111335
|
+
return makeResolvedOption({
|
|
111336
|
+
kind: "foreignKey",
|
|
111337
|
+
columns: [],
|
|
111338
|
+
references: () => referenceFromSelection(target())
|
|
111339
|
+
}, (table) => ({
|
|
111340
|
+
kind: "foreignKey",
|
|
111341
|
+
columns: selectedColumnList(columns(table)),
|
|
111342
|
+
references: () => referenceFromSelection(target())
|
|
111343
|
+
}));
|
|
111344
|
+
}
|
|
111345
|
+
function check2(name, predicate) {
|
|
111346
|
+
const spec = {
|
|
111347
|
+
kind: "check",
|
|
111348
|
+
name,
|
|
111349
|
+
predicate
|
|
111350
|
+
};
|
|
111351
|
+
return typeof predicate === "function" ? makeResolvedOption(spec, (table) => ({
|
|
111352
|
+
...spec,
|
|
111353
|
+
predicate: predicate(table)
|
|
111354
|
+
})) : makeOption(spec);
|
|
111355
|
+
}
|
|
110439
111356
|
|
|
110440
111357
|
// src/internal/runtime/normalize.ts
|
|
110441
111358
|
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -110688,9 +111605,9 @@ var normalizeDbValue = (dbType, value) => {
|
|
|
110688
111605
|
throw new Error("Expected a record value");
|
|
110689
111606
|
}
|
|
110690
111607
|
const normalized = {};
|
|
110691
|
-
for (const [
|
|
110692
|
-
if (
|
|
110693
|
-
normalized[
|
|
111608
|
+
for (const [key2, fieldDbType] of Object.entries(dbType.fields)) {
|
|
111609
|
+
if (key2 in value) {
|
|
111610
|
+
normalized[key2] = normalizeDbValue(fieldDbType, value[key2]);
|
|
110694
111611
|
}
|
|
110695
111612
|
}
|
|
110696
111613
|
return normalized;
|
|
@@ -110747,10 +111664,10 @@ var normalizeDbValue = (dbType, value) => {
|
|
|
110747
111664
|
};
|
|
110748
111665
|
|
|
110749
111666
|
// src/internal/query.ts
|
|
110750
|
-
import { pipeArguments as
|
|
111667
|
+
import { pipeArguments as pipeArguments5 } from "effect/Pipeable";
|
|
110751
111668
|
|
|
110752
111669
|
// src/internal/query-ast.ts
|
|
110753
|
-
var
|
|
111670
|
+
var TypeId8 = Symbol.for("effect-qb/QueryAst");
|
|
110754
111671
|
|
|
110755
111672
|
// src/internal/predicate/runtime.ts
|
|
110756
111673
|
var trueFormula = () => ({ kind: "true" });
|
|
@@ -110775,17 +111692,17 @@ var cloneContext = (context) => ({
|
|
|
110775
111692
|
nonNullKeys: new Set(context.nonNullKeys),
|
|
110776
111693
|
nullKeys: new Set(context.nullKeys),
|
|
110777
111694
|
eqLiterals: new Map(context.eqLiterals),
|
|
110778
|
-
neqLiterals: new Map(Array.from(context.neqLiterals.entries(), ([
|
|
110779
|
-
literalSets: new Map(Array.from(context.literalSets.entries(), ([
|
|
111695
|
+
neqLiterals: new Map(Array.from(context.neqLiterals.entries(), ([key2, values]) => [key2, new Set(values)])),
|
|
111696
|
+
literalSets: new Map(Array.from(context.literalSets.entries(), ([key2, values]) => [key2, new Set(values)])),
|
|
110780
111697
|
sourceNames: new Set(context.sourceNames),
|
|
110781
111698
|
contradiction: context.contradiction,
|
|
110782
111699
|
unknown: context.unknown
|
|
110783
111700
|
});
|
|
110784
111701
|
var freezeContext = (context) => context;
|
|
110785
111702
|
var columnPredicateKey = (tableName, columnName) => JSON.stringify([tableName, columnName]);
|
|
110786
|
-
var columnPredicateKeyParts = (
|
|
110787
|
-
const jsonSeparator =
|
|
110788
|
-
const columnKey = jsonSeparator === -1 ?
|
|
111703
|
+
var columnPredicateKeyParts = (key2) => {
|
|
111704
|
+
const jsonSeparator = key2.indexOf("#json:");
|
|
111705
|
+
const columnKey = jsonSeparator === -1 ? key2 : key2.slice(0, jsonSeparator);
|
|
110789
111706
|
try {
|
|
110790
111707
|
const parsed = JSON.parse(columnKey);
|
|
110791
111708
|
return Array.isArray(parsed) && parsed.length === 2 && typeof parsed[0] === "string" && typeof parsed[1] === "string" ? [parsed[0], parsed[1]] : undefined;
|
|
@@ -110793,59 +111710,59 @@ var columnPredicateKeyParts = (key) => {
|
|
|
110793
111710
|
return;
|
|
110794
111711
|
}
|
|
110795
111712
|
};
|
|
110796
|
-
var sourceNameOfKey = (
|
|
110797
|
-
var addSourceName = (context,
|
|
110798
|
-
context.sourceNames.add(sourceNameOfKey(
|
|
111713
|
+
var sourceNameOfKey = (key2) => columnPredicateKeyParts(key2)?.[0] ?? key2.split(".", 1)[0] ?? key2;
|
|
111714
|
+
var addSourceName = (context, key2) => {
|
|
111715
|
+
context.sourceNames.add(sourceNameOfKey(key2));
|
|
110799
111716
|
};
|
|
110800
|
-
var addNonNull = (context,
|
|
110801
|
-
addSourceName(context,
|
|
110802
|
-
if (context.nullKeys.has(
|
|
111717
|
+
var addNonNull = (context, key2) => {
|
|
111718
|
+
addSourceName(context, key2);
|
|
111719
|
+
if (context.nullKeys.has(key2)) {
|
|
110803
111720
|
context.contradiction = true;
|
|
110804
111721
|
}
|
|
110805
|
-
context.nonNullKeys.add(
|
|
111722
|
+
context.nonNullKeys.add(key2);
|
|
110806
111723
|
};
|
|
110807
|
-
var addNull = (context,
|
|
110808
|
-
addSourceName(context,
|
|
110809
|
-
if (context.nonNullKeys.has(
|
|
111724
|
+
var addNull = (context, key2) => {
|
|
111725
|
+
addSourceName(context, key2);
|
|
111726
|
+
if (context.nonNullKeys.has(key2)) {
|
|
110810
111727
|
context.contradiction = true;
|
|
110811
111728
|
}
|
|
110812
|
-
context.nullKeys.add(
|
|
111729
|
+
context.nullKeys.add(key2);
|
|
110813
111730
|
};
|
|
110814
|
-
var addEqLiteral = (context,
|
|
110815
|
-
addNonNull(context,
|
|
110816
|
-
const existing = context.eqLiterals.get(
|
|
111731
|
+
var addEqLiteral = (context, key2, value) => {
|
|
111732
|
+
addNonNull(context, key2);
|
|
111733
|
+
const existing = context.eqLiterals.get(key2);
|
|
110817
111734
|
if (existing !== undefined && existing !== value) {
|
|
110818
111735
|
context.contradiction = true;
|
|
110819
111736
|
}
|
|
110820
|
-
const neqValues = context.neqLiterals.get(
|
|
111737
|
+
const neqValues = context.neqLiterals.get(key2);
|
|
110821
111738
|
if (neqValues?.has(value)) {
|
|
110822
111739
|
context.contradiction = true;
|
|
110823
111740
|
}
|
|
110824
|
-
const existingSet = context.literalSets.get(
|
|
111741
|
+
const existingSet = context.literalSets.get(key2);
|
|
110825
111742
|
if (existingSet !== undefined && !existingSet.has(value)) {
|
|
110826
111743
|
context.contradiction = true;
|
|
110827
111744
|
}
|
|
110828
|
-
context.eqLiterals.set(
|
|
110829
|
-
context.literalSets.set(
|
|
111745
|
+
context.eqLiterals.set(key2, value);
|
|
111746
|
+
context.literalSets.set(key2, new Set([value]));
|
|
110830
111747
|
};
|
|
110831
|
-
var addNeqLiteral = (context,
|
|
110832
|
-
addNonNull(context,
|
|
110833
|
-
if (context.eqLiterals.get(
|
|
111748
|
+
var addNeqLiteral = (context, key2, value) => {
|
|
111749
|
+
addNonNull(context, key2);
|
|
111750
|
+
if (context.eqLiterals.get(key2) === value) {
|
|
110834
111751
|
context.contradiction = true;
|
|
110835
111752
|
}
|
|
110836
|
-
const values = context.neqLiterals.get(
|
|
111753
|
+
const values = context.neqLiterals.get(key2) ?? new Set;
|
|
110837
111754
|
values.add(value);
|
|
110838
|
-
context.neqLiterals.set(
|
|
111755
|
+
context.neqLiterals.set(key2, values);
|
|
110839
111756
|
};
|
|
110840
|
-
var addLiteralSet = (context,
|
|
110841
|
-
addNonNull(context,
|
|
110842
|
-
const existingEq = context.eqLiterals.get(
|
|
111757
|
+
var addLiteralSet = (context, key2, values) => {
|
|
111758
|
+
addNonNull(context, key2);
|
|
111759
|
+
const existingEq = context.eqLiterals.get(key2);
|
|
110843
111760
|
if (existingEq !== undefined && !values.has(existingEq)) {
|
|
110844
111761
|
context.contradiction = true;
|
|
110845
111762
|
}
|
|
110846
|
-
const existing = context.literalSets.get(
|
|
110847
|
-
context.literalSets.set(
|
|
110848
|
-
if (context.literalSets.get(
|
|
111763
|
+
const existing = context.literalSets.get(key2);
|
|
111764
|
+
context.literalSets.set(key2, existing === undefined ? new Set(values) : new Set(Array.from(existing).filter((value) => values.has(value))));
|
|
111765
|
+
if (context.literalSets.get(key2)?.size === 0) {
|
|
110849
111766
|
context.contradiction = true;
|
|
110850
111767
|
}
|
|
110851
111768
|
};
|
|
@@ -110927,35 +111844,35 @@ var applyNegativeAtom = (context, atom) => {
|
|
|
110927
111844
|
};
|
|
110928
111845
|
var intersectEqLiterals = (left, right) => {
|
|
110929
111846
|
const result = new Map;
|
|
110930
|
-
for (const [
|
|
110931
|
-
if (right.get(
|
|
110932
|
-
result.set(
|
|
111847
|
+
for (const [key2, value] of left) {
|
|
111848
|
+
if (right.get(key2) === value) {
|
|
111849
|
+
result.set(key2, value);
|
|
110933
111850
|
}
|
|
110934
111851
|
}
|
|
110935
111852
|
return result;
|
|
110936
111853
|
};
|
|
110937
111854
|
var intersectNeqLiterals = (left, right) => {
|
|
110938
111855
|
const result = new Map;
|
|
110939
|
-
for (const [
|
|
110940
|
-
const rightValues = right.get(
|
|
111856
|
+
for (const [key2, leftValues] of left) {
|
|
111857
|
+
const rightValues = right.get(key2);
|
|
110941
111858
|
if (rightValues === undefined) {
|
|
110942
111859
|
continue;
|
|
110943
111860
|
}
|
|
110944
111861
|
const next = new Set(Array.from(leftValues).filter((value) => rightValues.has(value)));
|
|
110945
111862
|
if (next.size > 0) {
|
|
110946
|
-
result.set(
|
|
111863
|
+
result.set(key2, next);
|
|
110947
111864
|
}
|
|
110948
111865
|
}
|
|
110949
111866
|
return result;
|
|
110950
111867
|
};
|
|
110951
111868
|
var unionLiteralSets = (left, right) => {
|
|
110952
111869
|
const result = new Map;
|
|
110953
|
-
for (const [
|
|
110954
|
-
const rightValues = right.get(
|
|
111870
|
+
for (const [key2, leftValues] of left) {
|
|
111871
|
+
const rightValues = right.get(key2);
|
|
110955
111872
|
if (rightValues === undefined) {
|
|
110956
111873
|
continue;
|
|
110957
111874
|
}
|
|
110958
|
-
result.set(
|
|
111875
|
+
result.set(key2, new Set([...leftValues, ...rightValues]));
|
|
110959
111876
|
}
|
|
110960
111877
|
return result;
|
|
110961
111878
|
};
|
|
@@ -110967,8 +111884,8 @@ var intersectContexts = (left, right) => {
|
|
|
110967
111884
|
return cloneContext(left);
|
|
110968
111885
|
}
|
|
110969
111886
|
return {
|
|
110970
|
-
nonNullKeys: new Set(Array.from(left.nonNullKeys).filter((
|
|
110971
|
-
nullKeys: new Set(Array.from(left.nullKeys).filter((
|
|
111887
|
+
nonNullKeys: new Set(Array.from(left.nonNullKeys).filter((key2) => right.nonNullKeys.has(key2))),
|
|
111888
|
+
nullKeys: new Set(Array.from(left.nullKeys).filter((key2) => right.nullKeys.has(key2))),
|
|
110972
111889
|
eqLiterals: intersectEqLiterals(left.eqLiterals, right.eqLiterals),
|
|
110973
111890
|
neqLiterals: intersectNeqLiterals(left.neqLiterals, right.neqLiterals),
|
|
110974
111891
|
literalSets: unionLiteralSets(left.literalSets, right.literalSets),
|
|
@@ -111059,18 +111976,18 @@ var jsonPathPredicateKeyOfExpression = (value) => {
|
|
|
111059
111976
|
if (segments.length === 0 || segments.length > 8) {
|
|
111060
111977
|
return;
|
|
111061
111978
|
}
|
|
111062
|
-
const
|
|
111979
|
+
const path2 = [];
|
|
111063
111980
|
for (const segment of segments) {
|
|
111064
111981
|
if (typeof segment !== "object" || segment === null || segment.kind !== "key") {
|
|
111065
111982
|
return;
|
|
111066
111983
|
}
|
|
111067
|
-
|
|
111984
|
+
path2.push(segment.key);
|
|
111068
111985
|
}
|
|
111069
|
-
if (
|
|
111986
|
+
if (path2.length === 0) {
|
|
111070
111987
|
return;
|
|
111071
111988
|
}
|
|
111072
111989
|
const baseKey = columnKeyOfExpression(jsonAst.base);
|
|
111073
|
-
return baseKey === undefined ? undefined : `${baseKey}#json:${
|
|
111990
|
+
return baseKey === undefined ? undefined : `${baseKey}#json:${path2.map(escapeJsonPathPredicateKeySegment).join(".")}`;
|
|
111074
111991
|
}
|
|
111075
111992
|
default:
|
|
111076
111993
|
return;
|
|
@@ -111107,8 +112024,8 @@ var valueKeyOfLiteral = (value) => {
|
|
|
111107
112024
|
return "unknown";
|
|
111108
112025
|
};
|
|
111109
112026
|
var nonNullFactsOfExpression = (value) => {
|
|
111110
|
-
const
|
|
111111
|
-
return
|
|
112027
|
+
const key2 = predicateKeyOfExpression(value);
|
|
112028
|
+
return key2 === undefined ? undefined : atomFormula({ kind: "is-not-null", key: key2 });
|
|
111112
112029
|
};
|
|
111113
112030
|
var combineFacts = (left, right) => {
|
|
111114
112031
|
if (left === undefined) {
|
|
@@ -111319,12 +112236,12 @@ var formulaOfExpression = (value) => {
|
|
|
111319
112236
|
}
|
|
111320
112237
|
return unknownTag("literal:non-boolean");
|
|
111321
112238
|
case "isNull": {
|
|
111322
|
-
const
|
|
111323
|
-
return
|
|
112239
|
+
const key2 = predicateKeyOfExpression(ast.value);
|
|
112240
|
+
return key2 === undefined ? unknownTag("isNull:unsupported") : atomFormula({ kind: "is-null", key: key2 });
|
|
111324
112241
|
}
|
|
111325
112242
|
case "isNotNull": {
|
|
111326
|
-
const
|
|
111327
|
-
return
|
|
112243
|
+
const key2 = predicateKeyOfExpression(ast.value);
|
|
112244
|
+
return key2 === undefined ? unknownTag("isNotNull:unsupported") : atomFormula({ kind: "is-not-null", key: key2 });
|
|
111328
112245
|
}
|
|
111329
112246
|
case "not":
|
|
111330
112247
|
return notFormula(formulaOfExpression(ast.value));
|
|
@@ -111345,12 +112262,12 @@ var formulaOfExpression = (value) => {
|
|
|
111345
112262
|
if (left === undefined) {
|
|
111346
112263
|
return falseFormula();
|
|
111347
112264
|
}
|
|
111348
|
-
const
|
|
112265
|
+
const key2 = predicateKeyOfExpression(left);
|
|
111349
112266
|
const literalValues = rest.map((entry) => {
|
|
111350
112267
|
const entryAst = astOf(entry);
|
|
111351
112268
|
return entryAst.kind === "literal" && entryAst.value !== null ? valueKeyOfLiteral(entryAst.value) : undefined;
|
|
111352
112269
|
});
|
|
111353
|
-
return
|
|
112270
|
+
return key2 !== undefined && literalValues.every((entry) => entry !== undefined) ? atomFormula({ kind: "literal-set", key: key2, values: literalValues }) : anyFormula(rest.map((value2) => formulaOfEq(left, value2)));
|
|
111354
112271
|
}
|
|
111355
112272
|
case "notIn": {
|
|
111356
112273
|
const [left, ...rest] = ast.values;
|
|
@@ -111383,12 +112300,12 @@ var guaranteedSourceNames = (assumptions) => analyzeFormula(assumptions).sourceN
|
|
|
111383
112300
|
// src/internal/query.ts
|
|
111384
112301
|
var ExpressionProto = {
|
|
111385
112302
|
pipe() {
|
|
111386
|
-
return
|
|
112303
|
+
return pipeArguments5(this, arguments);
|
|
111387
112304
|
}
|
|
111388
112305
|
};
|
|
111389
112306
|
var PlanProto = {
|
|
111390
112307
|
pipe() {
|
|
111391
|
-
return
|
|
112308
|
+
return pipeArguments5(this, arguments);
|
|
111392
112309
|
}
|
|
111393
112310
|
};
|
|
111394
112311
|
var QueryTypeId = Symbol.for("effect-qb/Query/internal");
|
|
@@ -111401,13 +112318,13 @@ var mergeAggregationManyRuntime = (values) => values.reduce((current, value) =>
|
|
|
111401
112318
|
var mergeNullabilityRuntime = (left, right = "never") => left === "always" || right === "always" ? "always" : left === "maybe" || right === "maybe" ? "maybe" : "never";
|
|
111402
112319
|
var mergeNullabilityManyRuntime = (values) => values.reduce((current, value) => mergeNullabilityRuntime(current, value[TypeId].nullability), "never");
|
|
111403
112320
|
var mergeManyDependencies = (values) => values.reduce((current, value) => mergeDependencies(current, value[TypeId].dependencies), {});
|
|
111404
|
-
var
|
|
112321
|
+
var makeExpression2 = (state, ast) => {
|
|
111405
112322
|
const expression = Object.create(ExpressionProto);
|
|
111406
112323
|
Object.defineProperty(expression, "pipe", {
|
|
111407
112324
|
configurable: true,
|
|
111408
112325
|
writable: true,
|
|
111409
112326
|
value: function() {
|
|
111410
|
-
return
|
|
112327
|
+
return pipeArguments5(expression, arguments);
|
|
111411
112328
|
}
|
|
111412
112329
|
});
|
|
111413
112330
|
expression[TypeId] = {
|
|
@@ -111429,11 +112346,11 @@ var makePlan = (state, ast, _assumptions, _capabilities, _statement, _target, _i
|
|
|
111429
112346
|
configurable: true,
|
|
111430
112347
|
writable: true,
|
|
111431
112348
|
value: function() {
|
|
111432
|
-
return
|
|
112349
|
+
return pipeArguments5(plan, arguments);
|
|
111433
112350
|
}
|
|
111434
112351
|
});
|
|
111435
|
-
plan[
|
|
111436
|
-
plan[
|
|
112352
|
+
plan[TypeId4] = state;
|
|
112353
|
+
plan[TypeId8] = ast;
|
|
111437
112354
|
plan[QueryTypeId] = {
|
|
111438
112355
|
required: undefined,
|
|
111439
112356
|
availableNames: undefined,
|
|
@@ -111447,7 +112364,7 @@ var makePlan = (state, ast, _assumptions, _capabilities, _statement, _target, _i
|
|
|
111447
112364
|
};
|
|
111448
112365
|
return plan;
|
|
111449
112366
|
};
|
|
111450
|
-
var getAst = (plan) => plan[
|
|
112367
|
+
var getAst = (plan) => plan[TypeId8];
|
|
111451
112368
|
var getQueryState = (plan) => plan[QueryTypeId];
|
|
111452
112369
|
var extractRequiredRuntime = (selection) => {
|
|
111453
112370
|
const required = new Set;
|
|
@@ -111494,8 +112411,8 @@ var presenceWitnessesOfSourceLike = (source) => {
|
|
|
111494
112411
|
if (typeof source !== "object" || source === null) {
|
|
111495
112412
|
return [];
|
|
111496
112413
|
}
|
|
111497
|
-
if (
|
|
111498
|
-
collectPresenceWitnesses(source[
|
|
112414
|
+
if (TypeId7 in source) {
|
|
112415
|
+
collectPresenceWitnesses(source[TypeId4].selection, output);
|
|
111499
112416
|
return [...output];
|
|
111500
112417
|
}
|
|
111501
112418
|
if ("columns" in source) {
|
|
@@ -111507,7 +112424,7 @@ var directAbsentSourceNames = (available, assumptions) => {
|
|
|
111507
112424
|
const nullKeys = guaranteedNullKeys(assumptions);
|
|
111508
112425
|
const absent = new Set;
|
|
111509
112426
|
for (const [name, source] of Object.entries(available)) {
|
|
111510
|
-
if (source._presenceWitnesses?.some((
|
|
112427
|
+
if (source._presenceWitnesses?.some((key2) => nullKeys.has(key2))) {
|
|
111511
112428
|
absent.add(name);
|
|
111512
112429
|
continue;
|
|
111513
112430
|
}
|
|
@@ -111584,51 +112501,6 @@ var resolveImplicationScope = (available, initialAssumptions) => {
|
|
|
111584
112501
|
};
|
|
111585
112502
|
};
|
|
111586
112503
|
|
|
111587
|
-
// src/internal/json/path.ts
|
|
111588
|
-
var SegmentTypeId = Symbol.for("effect-qb/JsonPathSegment");
|
|
111589
|
-
var TypeId8 = Symbol.for("effect-qb/JsonPath");
|
|
111590
|
-
var makeSegment = (segment) => segment;
|
|
111591
|
-
var key = (value) => makeSegment({
|
|
111592
|
-
[SegmentTypeId]: {
|
|
111593
|
-
kind: "key"
|
|
111594
|
-
},
|
|
111595
|
-
kind: "key",
|
|
111596
|
-
key: value
|
|
111597
|
-
});
|
|
111598
|
-
var index3 = (value) => makeSegment({
|
|
111599
|
-
[SegmentTypeId]: {
|
|
111600
|
-
kind: "index"
|
|
111601
|
-
},
|
|
111602
|
-
kind: "index",
|
|
111603
|
-
index: value
|
|
111604
|
-
});
|
|
111605
|
-
var wildcard = () => makeSegment({
|
|
111606
|
-
[SegmentTypeId]: {
|
|
111607
|
-
kind: "wildcard"
|
|
111608
|
-
},
|
|
111609
|
-
kind: "wildcard"
|
|
111610
|
-
});
|
|
111611
|
-
var slice = (start, end) => makeSegment({
|
|
111612
|
-
[SegmentTypeId]: {
|
|
111613
|
-
kind: "slice"
|
|
111614
|
-
},
|
|
111615
|
-
kind: "slice",
|
|
111616
|
-
start,
|
|
111617
|
-
end
|
|
111618
|
-
});
|
|
111619
|
-
var descend = () => makeSegment({
|
|
111620
|
-
[SegmentTypeId]: {
|
|
111621
|
-
kind: "descend"
|
|
111622
|
-
},
|
|
111623
|
-
kind: "descend"
|
|
111624
|
-
});
|
|
111625
|
-
var path = (...segments) => ({
|
|
111626
|
-
[TypeId8]: {
|
|
111627
|
-
segments
|
|
111628
|
-
},
|
|
111629
|
-
segments
|
|
111630
|
-
});
|
|
111631
|
-
|
|
111632
112504
|
// src/internal/grouping-key.ts
|
|
111633
112505
|
var subqueryPlanIds = new WeakMap;
|
|
111634
112506
|
var nextSubqueryPlanId = 0;
|
|
@@ -111662,8 +112534,8 @@ var literalGroupingKey = (value) => {
|
|
|
111662
112534
|
return `literal:${JSON.stringify(value)}`;
|
|
111663
112535
|
}
|
|
111664
112536
|
};
|
|
111665
|
-
var
|
|
111666
|
-
var expressionGroupingKey = (value) =>
|
|
112537
|
+
var isExpression2 = (value) => value !== null && typeof value === "object" && (TypeId in value);
|
|
112538
|
+
var expressionGroupingKey = (value) => isExpression2(value) ? groupingKeyOfExpression(value) : "missing";
|
|
111667
112539
|
var requiredExpressionGroupingKey = (_functionName, value) => groupingKeyOfExpression(value);
|
|
111668
112540
|
var requiredBinaryExpressionGroupingKey = (_functionName, left, right) => `${groupingKeyOfExpression(left)},${groupingKeyOfExpression(right)}`;
|
|
111669
112541
|
var functionCallArgsGroupingKey = (args) => args.map(groupingKeyOfExpression).join(",");
|
|
@@ -111719,7 +112591,7 @@ var jsonPathGroupingKey = (segments) => {
|
|
|
111719
112591
|
}
|
|
111720
112592
|
return segments.map(jsonSegmentGroupingKey).join(",");
|
|
111721
112593
|
};
|
|
111722
|
-
var isJsonPath = (value) => value !== null && typeof value === "object" && (
|
|
112594
|
+
var isJsonPath = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
111723
112595
|
var jsonOpaquePathGroupingKey = (value) => {
|
|
111724
112596
|
if (isJsonPath(value)) {
|
|
111725
112597
|
return `jsonpath:${jsonPathGroupingKey(value.segments)}`;
|
|
@@ -111727,7 +112599,7 @@ var jsonOpaquePathGroupingKey = (value) => {
|
|
|
111727
112599
|
if (typeof value === "string") {
|
|
111728
112600
|
return `jsonpath:${escapeGroupingText(value)}`;
|
|
111729
112601
|
}
|
|
111730
|
-
if (
|
|
112602
|
+
if (isExpression2(value)) {
|
|
111731
112603
|
return `jsonpath:${groupingKeyOfExpression(value)}`;
|
|
111732
112604
|
}
|
|
111733
112605
|
return "jsonpath:unknown";
|
|
@@ -111990,7 +112862,7 @@ var makeDslTransactionDdlRuntime = (ctx) => {
|
|
|
111990
112862
|
selection: {},
|
|
111991
112863
|
required: [],
|
|
111992
112864
|
available: {},
|
|
111993
|
-
dialect: target[
|
|
112865
|
+
dialect: target[TypeId4].dialect
|
|
111994
112866
|
}, {
|
|
111995
112867
|
kind: "createTable",
|
|
111996
112868
|
select: {},
|
|
@@ -112018,7 +112890,7 @@ var makeDslTransactionDdlRuntime = (ctx) => {
|
|
|
112018
112890
|
selection: {},
|
|
112019
112891
|
required: [],
|
|
112020
112892
|
available: {},
|
|
112021
|
-
dialect: target[
|
|
112893
|
+
dialect: target[TypeId4].dialect
|
|
112022
112894
|
}, {
|
|
112023
112895
|
kind: "dropTable",
|
|
112024
112896
|
select: {},
|
|
@@ -112049,7 +112921,7 @@ var makeDslTransactionDdlRuntime = (ctx) => {
|
|
|
112049
112921
|
selection: {},
|
|
112050
112922
|
required: [],
|
|
112051
112923
|
available: {},
|
|
112052
|
-
dialect: target[
|
|
112924
|
+
dialect: target[TypeId4].dialect
|
|
112053
112925
|
}, {
|
|
112054
112926
|
kind: "createIndex",
|
|
112055
112927
|
select: {},
|
|
@@ -112082,7 +112954,7 @@ var makeDslTransactionDdlRuntime = (ctx) => {
|
|
|
112082
112954
|
selection: {},
|
|
112083
112955
|
required: [],
|
|
112084
112956
|
available: {},
|
|
112085
|
-
dialect: target[
|
|
112957
|
+
dialect: target[TypeId4].dialect
|
|
112086
112958
|
}, {
|
|
112087
112959
|
kind: "dropIndex",
|
|
112088
112960
|
select: {},
|
|
@@ -112136,7 +113008,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112136
113008
|
baseName: sourceBaseName
|
|
112137
113009
|
}
|
|
112138
113010
|
},
|
|
112139
|
-
dialect: target[
|
|
113011
|
+
dialect: target[TypeId4].dialect
|
|
112140
113012
|
}, {
|
|
112141
113013
|
kind: "insert",
|
|
112142
113014
|
select: {},
|
|
@@ -112156,7 +113028,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112156
113028
|
}, undefined, "write", "insert", target, insertState);
|
|
112157
113029
|
};
|
|
112158
113030
|
const attachInsertSource = (plan, source) => {
|
|
112159
|
-
const current = plan[
|
|
113031
|
+
const current = plan[TypeId4];
|
|
112160
113032
|
const currentAst = ctx.getAst(plan);
|
|
112161
113033
|
const currentQuery = ctx.getQueryState(plan);
|
|
112162
113034
|
const target = currentQuery.target;
|
|
@@ -112196,11 +113068,11 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112196
113068
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement, currentQuery.target, "ready");
|
|
112197
113069
|
}
|
|
112198
113070
|
const sourcePlan = source;
|
|
112199
|
-
const selection = sourcePlan[
|
|
113071
|
+
const selection = sourcePlan[TypeId4].selection;
|
|
112200
113072
|
const columns = ctx.normalizeInsertSelectColumns(selection);
|
|
112201
113073
|
return ctx.makePlan({
|
|
112202
113074
|
selection: current.selection,
|
|
112203
|
-
required: ctx.currentRequiredList(sourcePlan[
|
|
113075
|
+
required: ctx.currentRequiredList(sourcePlan[TypeId4].required),
|
|
112204
113076
|
available: current.available,
|
|
112205
113077
|
dialect: current.dialect
|
|
112206
113078
|
}, {
|
|
@@ -112214,7 +113086,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112214
113086
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement, currentQuery.target, "ready");
|
|
112215
113087
|
};
|
|
112216
113088
|
const onConflict = (target, options2 = {}) => (plan) => {
|
|
112217
|
-
const current = plan[
|
|
113089
|
+
const current = plan[TypeId4];
|
|
112218
113090
|
const currentAst = ctx.getAst(plan);
|
|
112219
113091
|
const currentQuery = ctx.getQueryState(plan);
|
|
112220
113092
|
const insertTarget = currentAst.into.source;
|
|
@@ -112258,7 +113130,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112258
113130
|
selection: {},
|
|
112259
113131
|
required,
|
|
112260
113132
|
available: ctx.mutationAvailableSources(target),
|
|
112261
|
-
dialect: primaryTarget.source[
|
|
113133
|
+
dialect: primaryTarget.source[TypeId4].dialect
|
|
112262
113134
|
}, {
|
|
112263
113135
|
kind: "update",
|
|
112264
113136
|
select: {},
|
|
@@ -112290,7 +113162,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112290
113162
|
baseName: sourceBaseName
|
|
112291
113163
|
}
|
|
112292
113164
|
},
|
|
112293
|
-
dialect: target[
|
|
113165
|
+
dialect: target[TypeId4].dialect
|
|
112294
113166
|
}, {
|
|
112295
113167
|
kind: "insert",
|
|
112296
113168
|
select: {},
|
|
@@ -112324,7 +113196,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112324
113196
|
selection: {},
|
|
112325
113197
|
required: [],
|
|
112326
113198
|
available: ctx.mutationAvailableSources(target),
|
|
112327
|
-
dialect: primaryTarget.source[
|
|
113199
|
+
dialect: primaryTarget.source[TypeId4].dialect
|
|
112328
113200
|
}, {
|
|
112329
113201
|
kind: "delete",
|
|
112330
113202
|
select: {},
|
|
@@ -112345,7 +113217,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112345
113217
|
selection: {},
|
|
112346
113218
|
required: [],
|
|
112347
113219
|
available: {},
|
|
112348
|
-
dialect: target[
|
|
113220
|
+
dialect: target[TypeId4].dialect
|
|
112349
113221
|
}, {
|
|
112350
113222
|
kind: "truncate",
|
|
112351
113223
|
select: {},
|
|
@@ -112399,7 +113271,7 @@ var makeDslMutationRuntime = (ctx) => {
|
|
|
112399
113271
|
baseName: usingBaseName
|
|
112400
113272
|
}
|
|
112401
113273
|
},
|
|
112402
|
-
dialect: target[
|
|
113274
|
+
dialect: target[TypeId4].dialect
|
|
112403
113275
|
}, {
|
|
112404
113276
|
kind: "merge",
|
|
112405
113277
|
select: {},
|
|
@@ -112462,7 +113334,7 @@ var renderMysqlMutationLockMode = (mode, _statement) => {
|
|
|
112462
113334
|
var makeDslPlanRuntime = (ctx) => {
|
|
112463
113335
|
const sourceRequiredList = (source) => typeof source === "object" && source !== null && ("required" in source) ? ctx.currentRequiredList(source.required) : [];
|
|
112464
113336
|
const buildSetOperation = (kind, all, left, right) => {
|
|
112465
|
-
const leftState = left[
|
|
113337
|
+
const leftState = left[TypeId4];
|
|
112466
113338
|
const leftAst = ctx.getAst(left);
|
|
112467
113339
|
const basePlan = leftAst.kind === "set" ? leftAst.setBase ?? left : left;
|
|
112468
113340
|
const leftOperations = leftAst.kind === "set" ? [...leftAst.setOperations ?? []] : [];
|
|
@@ -112470,7 +113342,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112470
113342
|
selection: leftState.selection,
|
|
112471
113343
|
required: undefined,
|
|
112472
113344
|
available: {},
|
|
112473
|
-
dialect: leftState.dialect ?? right[
|
|
113345
|
+
dialect: leftState.dialect ?? right[TypeId4].dialect
|
|
112474
113346
|
}, {
|
|
112475
113347
|
kind: "set",
|
|
112476
113348
|
select: leftState.selection,
|
|
@@ -112491,7 +113363,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112491
113363
|
}, undefined, undefined, "set");
|
|
112492
113364
|
};
|
|
112493
113365
|
const where = (predicate) => (plan) => {
|
|
112494
|
-
const current = plan[
|
|
113366
|
+
const current = plan[TypeId4];
|
|
112495
113367
|
const currentAst = ctx.getAst(plan);
|
|
112496
113368
|
const currentQuery = ctx.getQueryState(plan);
|
|
112497
113369
|
const predicateExpression = ctx.toDialectExpression(predicate);
|
|
@@ -112510,7 +113382,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112510
113382
|
}, ctx.assumeFormulaTrue(currentQuery.assumptions, ctx.formulaOfExpressionRuntime(predicateExpression)), currentQuery.capabilities, currentQuery.statement);
|
|
112511
113383
|
};
|
|
112512
113384
|
const from = (source) => (plan) => {
|
|
112513
|
-
const current = plan[
|
|
113385
|
+
const current = plan[TypeId4];
|
|
112514
113386
|
const currentAst = ctx.getAst(plan);
|
|
112515
113387
|
const currentQuery = ctx.getQueryState(plan);
|
|
112516
113388
|
if (currentQuery.statement === "insert") {
|
|
@@ -112577,7 +113449,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112577
113449
|
return plan;
|
|
112578
113450
|
};
|
|
112579
113451
|
const having = (predicate) => (plan) => {
|
|
112580
|
-
const current = plan[
|
|
113452
|
+
const current = plan[TypeId4];
|
|
112581
113453
|
const currentAst = ctx.getAst(plan);
|
|
112582
113454
|
const currentQuery = ctx.getQueryState(plan);
|
|
112583
113455
|
const predicateExpression = ctx.toDialectExpression(predicate);
|
|
@@ -112596,7 +113468,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112596
113468
|
}, ctx.assumeFormulaTrue(currentQuery.assumptions, ctx.formulaOfExpressionRuntime(predicateExpression)), currentQuery.capabilities, currentQuery.statement);
|
|
112597
113469
|
};
|
|
112598
113470
|
const crossJoin = (table) => (plan) => {
|
|
112599
|
-
const current = plan[
|
|
113471
|
+
const current = plan[TypeId4];
|
|
112600
113472
|
const currentAst = ctx.getAst(plan);
|
|
112601
113473
|
const currentQuery = ctx.getQueryState(plan);
|
|
112602
113474
|
const { sourceName, sourceBaseName } = ctx.sourceDetails(table);
|
|
@@ -112616,7 +113488,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112616
113488
|
selection: current.selection,
|
|
112617
113489
|
required: [...ctx.currentRequiredList(current.required), ...sourceRequired].filter((name, index4, values) => !(name in nextAvailable) && values.indexOf(name) === index4),
|
|
112618
113490
|
available: nextAvailable,
|
|
112619
|
-
dialect: current.dialect ?? table[
|
|
113491
|
+
dialect: current.dialect ?? table[TypeId4]?.dialect ?? table.dialect
|
|
112620
113492
|
}, {
|
|
112621
113493
|
...currentAst,
|
|
112622
113494
|
joins: [...currentAst.joins, {
|
|
@@ -112628,7 +113500,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112628
113500
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement);
|
|
112629
113501
|
};
|
|
112630
113502
|
const join = (kind, table, on) => (plan) => {
|
|
112631
|
-
const current = plan[
|
|
113503
|
+
const current = plan[TypeId4];
|
|
112632
113504
|
const currentAst = ctx.getAst(plan);
|
|
112633
113505
|
const currentQuery = ctx.getQueryState(plan);
|
|
112634
113506
|
const onExpression = ctx.toDialectExpression(on);
|
|
@@ -112670,7 +113542,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112670
113542
|
}, kind === "inner" ? ctx.assumeFormulaTrue(currentQuery.assumptions, onFormula) : currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement);
|
|
112671
113543
|
};
|
|
112672
113544
|
const orderBy = (value, direction = "asc") => (plan) => {
|
|
112673
|
-
const current = plan[
|
|
113545
|
+
const current = plan[TypeId4];
|
|
112674
113546
|
const currentAst = ctx.getAst(plan);
|
|
112675
113547
|
const currentQuery = ctx.getQueryState(plan);
|
|
112676
113548
|
const expression = ctx.toDialectExpression(value);
|
|
@@ -112690,7 +113562,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112690
113562
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement);
|
|
112691
113563
|
};
|
|
112692
113564
|
const lock = (mode, options2 = {}) => (plan) => {
|
|
112693
|
-
const current = plan[
|
|
113565
|
+
const current = plan[TypeId4];
|
|
112694
113566
|
const currentAst = ctx.getAst(plan);
|
|
112695
113567
|
const currentQuery = ctx.getQueryState(plan);
|
|
112696
113568
|
return ctx.makePlan({
|
|
@@ -112709,7 +113581,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112709
113581
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement);
|
|
112710
113582
|
};
|
|
112711
113583
|
const distinct = () => (plan) => {
|
|
112712
|
-
const current = plan[
|
|
113584
|
+
const current = plan[TypeId4];
|
|
112713
113585
|
const currentAst = ctx.getAst(plan);
|
|
112714
113586
|
const currentQuery = ctx.getQueryState(plan);
|
|
112715
113587
|
return ctx.makePlan({
|
|
@@ -112723,7 +113595,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112723
113595
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement);
|
|
112724
113596
|
};
|
|
112725
113597
|
const limit = (value) => (plan) => {
|
|
112726
|
-
const current = plan[
|
|
113598
|
+
const current = plan[TypeId4];
|
|
112727
113599
|
const currentAst = ctx.getAst(plan);
|
|
112728
113600
|
const currentQuery = ctx.getQueryState(plan);
|
|
112729
113601
|
const expression = ctx.toDialectNumericExpression(value);
|
|
@@ -112739,7 +113611,7 @@ var makeDslPlanRuntime = (ctx) => {
|
|
|
112739
113611
|
}, currentQuery.assumptions, currentQuery.capabilities, currentQuery.statement);
|
|
112740
113612
|
};
|
|
112741
113613
|
const offset = (value) => (plan) => {
|
|
112742
|
-
const current = plan[
|
|
113614
|
+
const current = plan[TypeId4];
|
|
112743
113615
|
const currentAst = ctx.getAst(plan);
|
|
112744
113616
|
const currentQuery = ctx.getQueryState(plan);
|
|
112745
113617
|
const expression = ctx.toDialectNumericExpression(value);
|
|
@@ -112837,7 +113709,7 @@ var makeDslQueryRuntime = (ctx) => {
|
|
|
112837
113709
|
}, undefined, "read", "select");
|
|
112838
113710
|
};
|
|
112839
113711
|
const groupBy = (...values2) => (plan) => {
|
|
112840
|
-
const current = plan[
|
|
113712
|
+
const current = plan[TypeId4];
|
|
112841
113713
|
const currentAst = ctx.getAst(plan);
|
|
112842
113714
|
const currentQuery = ctx.getQueryState(plan);
|
|
112843
113715
|
const required = [...values2.flatMap((value) => Object.keys(value[TypeId].dependencies))].filter((name, index4, list) => !(name in current.available) && list.indexOf(name) === index4);
|
|
@@ -112853,7 +113725,7 @@ var makeDslQueryRuntime = (ctx) => {
|
|
|
112853
113725
|
};
|
|
112854
113726
|
const returning = (selection) => {
|
|
112855
113727
|
return (plan) => {
|
|
112856
|
-
const current = plan[
|
|
113728
|
+
const current = plan[TypeId4];
|
|
112857
113729
|
const currentAst = ctx.getAst(plan);
|
|
112858
113730
|
const currentQuery = ctx.getQueryState(plan);
|
|
112859
113731
|
return ctx.makePlan({
|
|
@@ -112878,14 +113750,14 @@ var makeDslQueryRuntime = (ctx) => {
|
|
|
112878
113750
|
};
|
|
112879
113751
|
|
|
112880
113752
|
// src/internal/derived-table.ts
|
|
112881
|
-
import { pipeArguments as
|
|
113753
|
+
import { pipeArguments as pipeArguments6 } from "effect/Pipeable";
|
|
112882
113754
|
|
|
112883
113755
|
// src/internal/projection-alias.ts
|
|
112884
113756
|
var TypeId9 = Symbol.for("effect-qb/ProjectionAlias");
|
|
112885
113757
|
|
|
112886
113758
|
// src/internal/projections.ts
|
|
112887
113759
|
var aliasFromPath = (path2) => path2.join("__");
|
|
112888
|
-
var
|
|
113760
|
+
var isExpression3 = (value) => typeof value === "object" && value !== null && (TypeId in value);
|
|
112889
113761
|
var projectionAliasOf = (expression) => (TypeId9 in expression) ? expression[TypeId9].alias : undefined;
|
|
112890
113762
|
var pathKeyOf = (path2) => JSON.stringify(path2);
|
|
112891
113763
|
var formatProjectionPath = (path2) => path2.join(".");
|
|
@@ -112894,7 +113766,7 @@ var flattenSelection = (selection, path2 = []) => {
|
|
|
112894
113766
|
const fields2 = [];
|
|
112895
113767
|
for (const [key2, value] of Object.entries(selection)) {
|
|
112896
113768
|
const nextPath = [...path2, key2];
|
|
112897
|
-
if (
|
|
113769
|
+
if (isExpression3(value)) {
|
|
112898
113770
|
fields2.push({
|
|
112899
113771
|
path: nextPath,
|
|
112900
113772
|
expression: value,
|
|
@@ -112934,7 +113806,7 @@ var validateProjections = (projections) => {
|
|
|
112934
113806
|
// src/internal/derived-table.ts
|
|
112935
113807
|
var DerivedProto = {
|
|
112936
113808
|
pipe() {
|
|
112937
|
-
return
|
|
113809
|
+
return pipeArguments6(this, arguments);
|
|
112938
113810
|
}
|
|
112939
113811
|
};
|
|
112940
113812
|
var attachPipe4 = (value) => {
|
|
@@ -112942,7 +113814,7 @@ var attachPipe4 = (value) => {
|
|
|
112942
113814
|
configurable: true,
|
|
112943
113815
|
writable: true,
|
|
112944
113816
|
value: function() {
|
|
112945
|
-
return
|
|
113817
|
+
return pipeArguments6(value, arguments);
|
|
112946
113818
|
}
|
|
112947
113819
|
});
|
|
112948
113820
|
return value;
|
|
@@ -112968,7 +113840,7 @@ var reboundedColumns = (plan, alias2) => {
|
|
|
112968
113840
|
const projections = flattenSelection(ast.select);
|
|
112969
113841
|
for (const projection of projections) {
|
|
112970
113842
|
const expression = projection.expression;
|
|
112971
|
-
setPath(selection, projection.path,
|
|
113843
|
+
setPath(selection, projection.path, makeExpression2({
|
|
112972
113844
|
runtime: undefined,
|
|
112973
113845
|
dbType: expression[TypeId].dbType,
|
|
112974
113846
|
runtimeSchema: expression[TypeId].runtimeSchema,
|
|
@@ -112993,7 +113865,7 @@ var makeDerivedSource = (plan, alias2) => {
|
|
|
112993
113865
|
derived.kind = "derived";
|
|
112994
113866
|
derived.name = alias2;
|
|
112995
113867
|
derived.baseName = alias2;
|
|
112996
|
-
derived.dialect = plan[
|
|
113868
|
+
derived.dialect = plan[TypeId4].dialect;
|
|
112997
113869
|
derived.plan = plan;
|
|
112998
113870
|
derived.required = undefined;
|
|
112999
113871
|
derived.columns = columns;
|
|
@@ -113006,7 +113878,7 @@ var makeCteSource = (plan, alias2, recursive = false) => {
|
|
|
113006
113878
|
cte.kind = "cte";
|
|
113007
113879
|
cte.name = alias2;
|
|
113008
113880
|
cte.baseName = alias2;
|
|
113009
|
-
cte.dialect = plan[
|
|
113881
|
+
cte.dialect = plan[TypeId4].dialect;
|
|
113010
113882
|
cte.plan = plan;
|
|
113011
113883
|
cte.recursive = recursive;
|
|
113012
113884
|
cte.required = undefined;
|
|
@@ -113020,9 +113892,9 @@ var makeLateralSource = (plan, alias2) => {
|
|
|
113020
113892
|
lateral.kind = "lateral";
|
|
113021
113893
|
lateral.name = alias2;
|
|
113022
113894
|
lateral.baseName = alias2;
|
|
113023
|
-
lateral.dialect = plan[
|
|
113895
|
+
lateral.dialect = plan[TypeId4].dialect;
|
|
113024
113896
|
lateral.plan = plan;
|
|
113025
|
-
lateral.required = currentRequiredList(plan[
|
|
113897
|
+
lateral.required = currentRequiredList(plan[TypeId4].required);
|
|
113026
113898
|
lateral.columns = columns;
|
|
113027
113899
|
return lateral;
|
|
113028
113900
|
};
|
|
@@ -113046,16 +113918,19 @@ var profile = {
|
|
|
113046
113918
|
};
|
|
113047
113919
|
var ValuesInputProto = {
|
|
113048
113920
|
pipe() {
|
|
113049
|
-
return
|
|
113921
|
+
return pipeArguments7(this, arguments);
|
|
113050
113922
|
}
|
|
113051
113923
|
};
|
|
113052
113924
|
var literalSchemaOf = (value) => {
|
|
113053
113925
|
if (value === null || value instanceof Date) {
|
|
113054
113926
|
return;
|
|
113055
113927
|
}
|
|
113928
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
113929
|
+
return;
|
|
113930
|
+
}
|
|
113056
113931
|
return Schema6.Literal(value);
|
|
113057
113932
|
};
|
|
113058
|
-
var literal = (value) =>
|
|
113933
|
+
var literal = (value) => makeExpression2({
|
|
113059
113934
|
runtime: undefined,
|
|
113060
113935
|
dbType: value === null ? profile.nullDb : value instanceof Date ? profile.timestampDb : typeof value === "string" ? profile.textDb : typeof value === "number" ? profile.numericDb : profile.boolDb,
|
|
113061
113936
|
runtimeSchema: literalSchemaOf(value),
|
|
@@ -113079,7 +113954,7 @@ var retargetLiteralExpression = (value, target) => {
|
|
|
113079
113954
|
return value;
|
|
113080
113955
|
}
|
|
113081
113956
|
const targetState = target[TypeId];
|
|
113082
|
-
return
|
|
113957
|
+
return makeExpression2({
|
|
113083
113958
|
runtime: value[TypeId].runtime,
|
|
113084
113959
|
dbType: targetState.dbType,
|
|
113085
113960
|
runtimeSchema: targetState.runtimeSchema,
|
|
@@ -113113,7 +113988,7 @@ var extractRequiredFromDialectNumericInputRuntime = (value) => {
|
|
|
113113
113988
|
};
|
|
113114
113989
|
var buildBinaryPredicate = (left, right, kind, nullability = "maybe") => {
|
|
113115
113990
|
const [leftExpression, rightExpression] = alignBinaryPredicateExpressions(toDialectExpression(left), toDialectExpression(right));
|
|
113116
|
-
return
|
|
113991
|
+
return makeExpression2({
|
|
113117
113992
|
runtime: true,
|
|
113118
113993
|
dbType: profile.boolDb,
|
|
113119
113994
|
nullability,
|
|
@@ -113193,11 +114068,11 @@ var isJsonExpressionValue = (value) => isExpressionValue(value) && (() => {
|
|
|
113193
114068
|
const dbType = value[TypeId].dbType;
|
|
113194
114069
|
return dbType.variant === "json" || dbType.kind === "json" || dbType.kind === "jsonb";
|
|
113195
114070
|
})();
|
|
113196
|
-
var isJsonPathValue = (value) => value !== null && typeof value === "object" && (
|
|
114071
|
+
var isJsonPathValue = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
113197
114072
|
var normalizeJsonPathInput = (value) => isJsonPathValue(value) ? value.segments : [value];
|
|
113198
114073
|
var isExactJsonSegmentValue = (segment) => segment.kind === "key" || segment.kind === "index";
|
|
113199
114074
|
var isExactJsonPathValue = (segments) => segments.every(isExactJsonSegmentValue);
|
|
113200
|
-
var buildJsonNodeExpression = (expressions, state, ast) =>
|
|
114075
|
+
var buildJsonNodeExpression = (expressions, state, ast) => makeExpression2({
|
|
113201
114076
|
runtime: state.runtime,
|
|
113202
114077
|
dbType: state.dbType,
|
|
113203
114078
|
nullability: state.nullability,
|
|
@@ -113207,7 +114082,7 @@ var buildJsonNodeExpression = (expressions, state, ast) => makeExpression({
|
|
|
113207
114082
|
}, ast);
|
|
113208
114083
|
var jsonDbTypeOf = (base) => base[TypeId].dbType;
|
|
113209
114084
|
var resolveJsonMergeDbType = (...values) => values.some((value) => value[TypeId].dbType.kind === "jsonb") ? jsonbDb : jsonDb;
|
|
113210
|
-
var makeJsonLiteralExpression = (value, dbType = jsonDb) =>
|
|
114085
|
+
var makeJsonLiteralExpression = (value, dbType = jsonDb) => makeExpression2({
|
|
113211
114086
|
runtime: value,
|
|
113212
114087
|
dbType,
|
|
113213
114088
|
nullability: value === null ? "always" : "never",
|
|
@@ -113542,7 +114417,7 @@ var jsonPathMatch = (base, query) => {
|
|
|
113542
114417
|
};
|
|
113543
114418
|
var json = {
|
|
113544
114419
|
key,
|
|
113545
|
-
index
|
|
114420
|
+
index,
|
|
113546
114421
|
wildcard,
|
|
113547
114422
|
slice,
|
|
113548
114423
|
descend,
|
|
@@ -113578,7 +114453,7 @@ var json = {
|
|
|
113578
114453
|
};
|
|
113579
114454
|
var jsonb = {
|
|
113580
114455
|
key,
|
|
113581
|
-
index
|
|
114456
|
+
index,
|
|
113582
114457
|
wildcard,
|
|
113583
114458
|
slice,
|
|
113584
114459
|
descend,
|
|
@@ -113629,7 +114504,7 @@ var toMutationValueExpression = (value, column) => {
|
|
|
113629
114504
|
const ast = expression[TypeId2];
|
|
113630
114505
|
if (ast.kind === "literal") {
|
|
113631
114506
|
const normalizedValue2 = normalizeMutationValue(ast.value);
|
|
113632
|
-
return
|
|
114507
|
+
return makeExpression2({
|
|
113633
114508
|
runtime: normalizedValue2,
|
|
113634
114509
|
dbType: columnState.dbType,
|
|
113635
114510
|
runtimeSchema: columnState.runtimeSchema,
|
|
@@ -113646,7 +114521,7 @@ var toMutationValueExpression = (value, column) => {
|
|
|
113646
114521
|
return retargetLiteralExpression(value, column);
|
|
113647
114522
|
}
|
|
113648
114523
|
const normalizedValue = normalizeMutationValue(value);
|
|
113649
|
-
return
|
|
114524
|
+
return makeExpression2({
|
|
113650
114525
|
runtime: normalizedValue,
|
|
113651
114526
|
dbType: columnState.dbType,
|
|
113652
114527
|
runtimeSchema: columnState.runtimeSchema,
|
|
@@ -113661,15 +114536,15 @@ var toMutationValueExpression = (value, column) => {
|
|
|
113661
114536
|
});
|
|
113662
114537
|
};
|
|
113663
114538
|
var targetSourceDetails = (table) => {
|
|
113664
|
-
const sourceName = table[
|
|
113665
|
-
const sourceBaseName = table[
|
|
114539
|
+
const sourceName = table[TypeId7].name;
|
|
114540
|
+
const sourceBaseName = table[TypeId7].baseName;
|
|
113666
114541
|
return {
|
|
113667
114542
|
sourceName,
|
|
113668
114543
|
sourceBaseName
|
|
113669
114544
|
};
|
|
113670
114545
|
};
|
|
113671
114546
|
var sourceDetails = (source) => {
|
|
113672
|
-
if (
|
|
114547
|
+
if (TypeId7 in source) {
|
|
113673
114548
|
return targetSourceDetails(source);
|
|
113674
114549
|
}
|
|
113675
114550
|
const record2 = source;
|
|
@@ -113682,7 +114557,7 @@ var makeColumnReferenceSelection = (alias2, selection) => {
|
|
|
113682
114557
|
const columns = {};
|
|
113683
114558
|
for (const [columnName, expression] of Object.entries(selection)) {
|
|
113684
114559
|
const state = expression[TypeId];
|
|
113685
|
-
columns[columnName] =
|
|
114560
|
+
columns[columnName] = makeExpression2({
|
|
113686
114561
|
runtime: undefined,
|
|
113687
114562
|
dbType: state.dbType,
|
|
113688
114563
|
runtimeSchema: state.runtimeSchema,
|
|
@@ -113736,7 +114611,7 @@ var buildMutationAssignments = (target, values) => {
|
|
|
113736
114611
|
}
|
|
113737
114612
|
const valueMap = values;
|
|
113738
114613
|
return targets.flatMap((table) => {
|
|
113739
|
-
const targetName = table[
|
|
114614
|
+
const targetName = table[TypeId7].name;
|
|
113740
114615
|
const scopedValues = valueMap[targetName] ?? {};
|
|
113741
114616
|
const columns = table;
|
|
113742
114617
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
@@ -113902,59 +114777,28 @@ var {
|
|
|
113902
114777
|
normalizeColumnList,
|
|
113903
114778
|
defaultIndexName
|
|
113904
114779
|
});
|
|
114780
|
+
|
|
113905
114781
|
// src/mysql/json.ts
|
|
113906
|
-
var key2 = json.key;
|
|
113907
|
-
var index4 = json.index;
|
|
113908
|
-
var wildcard2 = json.wildcard;
|
|
113909
|
-
var slice2 = json.slice;
|
|
113910
|
-
var descend2 = json.descend;
|
|
113911
|
-
var path2 = json.path;
|
|
113912
|
-
var get = json.get;
|
|
113913
|
-
var access = json.access;
|
|
113914
|
-
var traverse = json.traverse;
|
|
113915
|
-
var text = json.text;
|
|
113916
|
-
var accessText = json.accessText;
|
|
113917
|
-
var traverseText = json.traverseText;
|
|
113918
|
-
var contains = json.contains;
|
|
113919
|
-
var containedBy = json.containedBy;
|
|
113920
|
-
var hasKey = json.hasKey;
|
|
113921
|
-
var keyExists = json.keyExists;
|
|
113922
|
-
var hasAnyKeys = json.hasAnyKeys;
|
|
113923
|
-
var hasAllKeys = json.hasAllKeys;
|
|
113924
|
-
var delete_2 = json.delete;
|
|
113925
|
-
var remove = json.remove;
|
|
113926
|
-
var set2 = json.set;
|
|
113927
|
-
var insert = json.insert;
|
|
113928
|
-
var concat = json.concat;
|
|
113929
|
-
var merge2 = json.merge;
|
|
113930
|
-
var buildObject = json.buildObject;
|
|
113931
|
-
var buildArray = json.buildArray;
|
|
113932
|
-
var toJson = json.toJson;
|
|
113933
|
-
var toJsonb = json.toJsonb;
|
|
113934
114782
|
var typeOf = json.typeOf;
|
|
113935
114783
|
var length = json.length;
|
|
113936
|
-
var keys = json.keys;
|
|
113937
114784
|
var stripNulls = json.stripNulls;
|
|
113938
|
-
var pathExists = json.pathExists;
|
|
113939
114785
|
var pathMatch = json.pathMatch;
|
|
113940
114786
|
// src/mysql/executor.ts
|
|
113941
114787
|
var exports_executor2 = {};
|
|
113942
114788
|
__export(exports_executor2, {
|
|
113943
114789
|
withTransaction: () => withTransaction2,
|
|
113944
|
-
withSavepoint: () => withSavepoint2,
|
|
113945
114790
|
make: () => make4,
|
|
113946
114791
|
driver: () => driver2,
|
|
113947
114792
|
custom: () => custom3
|
|
113948
114793
|
});
|
|
113949
114794
|
import * as Effect2 from "effect/Effect";
|
|
113950
|
-
import * as SqlClient3 from "
|
|
114795
|
+
import * as SqlClient3 from "effect/unstable/sql/SqlClient";
|
|
113951
114796
|
import * as Stream2 from "effect/Stream";
|
|
113952
114797
|
|
|
113953
114798
|
// src/internal/executor.ts
|
|
113954
114799
|
var exports_executor = {};
|
|
113955
114800
|
__export(exports_executor, {
|
|
113956
114801
|
withTransaction: () => withTransaction,
|
|
113957
|
-
withSavepoint: () => withSavepoint,
|
|
113958
114802
|
streamFromSqlClient: () => streamFromSqlClient,
|
|
113959
114803
|
remapRows: () => remapRows,
|
|
113960
114804
|
makeRowDecoder: () => makeRowDecoder,
|
|
@@ -113968,9 +114812,10 @@ __export(exports_executor, {
|
|
|
113968
114812
|
});
|
|
113969
114813
|
import * as Chunk from "effect/Chunk";
|
|
113970
114814
|
import * as Effect from "effect/Effect";
|
|
114815
|
+
import * as Exit from "effect/Exit";
|
|
113971
114816
|
import * as Option from "effect/Option";
|
|
113972
114817
|
import * as Schema9 from "effect/Schema";
|
|
113973
|
-
import * as SqlClient from "
|
|
114818
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
113974
114819
|
import * as Stream from "effect/Stream";
|
|
113975
114820
|
|
|
113976
114821
|
// src/internal/runtime/driver-value-mapping.ts
|
|
@@ -114017,9 +114862,9 @@ var mappingCandidates = (context) => {
|
|
|
114017
114862
|
runtimeTag === undefined ? undefined : context.valueMappings?.[runtimeTag]
|
|
114018
114863
|
];
|
|
114019
114864
|
};
|
|
114020
|
-
var findMapping = (context,
|
|
114865
|
+
var findMapping = (context, key2) => {
|
|
114021
114866
|
for (const candidate of mappingCandidates(context)) {
|
|
114022
|
-
const value = candidate?.[
|
|
114867
|
+
const value = candidate?.[key2];
|
|
114023
114868
|
if (value !== undefined) {
|
|
114024
114869
|
return value;
|
|
114025
114870
|
}
|
|
@@ -114147,7 +114992,7 @@ var renderJsonSelectSql = (sql, context) => {
|
|
|
114147
114992
|
import * as Schema8 from "effect/Schema";
|
|
114148
114993
|
import * as SchemaAST from "effect/SchemaAST";
|
|
114149
114994
|
var schemaCache = new WeakMap;
|
|
114150
|
-
var FiniteNumberSchema = Schema8.Number.
|
|
114995
|
+
var FiniteNumberSchema = Schema8.Number.check(Schema8.isFinite());
|
|
114151
114996
|
var runtimeSchemaForTag = (tag) => {
|
|
114152
114997
|
switch (tag) {
|
|
114153
114998
|
case "string":
|
|
@@ -114175,14 +115020,11 @@ var runtimeSchemaForTag = (tag) => {
|
|
|
114175
115020
|
case "decimalString":
|
|
114176
115021
|
return DecimalStringSchema;
|
|
114177
115022
|
case "bytes":
|
|
114178
|
-
return Schema8.
|
|
115023
|
+
return Schema8.Uint8Array;
|
|
114179
115024
|
case "array":
|
|
114180
115025
|
return Schema8.Array(Schema8.Unknown);
|
|
114181
115026
|
case "record":
|
|
114182
|
-
return Schema8.Record(
|
|
114183
|
-
key: Schema8.String,
|
|
114184
|
-
value: Schema8.Unknown
|
|
114185
|
-
});
|
|
115027
|
+
return Schema8.Record(Schema8.String, Schema8.Unknown);
|
|
114186
115028
|
case "null":
|
|
114187
115029
|
return Schema8.Null;
|
|
114188
115030
|
case "unknown":
|
|
@@ -114200,7 +115042,7 @@ var runtimeSchemaForDbType = (dbType) => {
|
|
|
114200
115042
|
return Schema8.Array(runtimeSchemaForDbType(dbType.element) ?? Schema8.Unknown);
|
|
114201
115043
|
}
|
|
114202
115044
|
if ("fields" in dbType) {
|
|
114203
|
-
const fields2 = Object.fromEntries(Object.entries(dbType.fields).map(([
|
|
115045
|
+
const fields2 = Object.fromEntries(Object.entries(dbType.fields).map(([key2, field]) => [key2, runtimeSchemaForDbType(field) ?? Schema8.Unknown]));
|
|
114204
115046
|
return Schema8.Struct(fields2);
|
|
114205
115047
|
}
|
|
114206
115048
|
if ("variant" in dbType && dbType.variant === "json") {
|
|
@@ -114220,27 +115062,23 @@ var unionAst = (asts) => {
|
|
|
114220
115062
|
if (asts.length === 1) {
|
|
114221
115063
|
return asts[0];
|
|
114222
115064
|
}
|
|
114223
|
-
return SchemaAST.Union
|
|
115065
|
+
return new SchemaAST.Union(asts, "anyOf");
|
|
114224
115066
|
};
|
|
114225
|
-
var propertyAstOf = (ast,
|
|
115067
|
+
var propertyAstOf = (ast, key2) => {
|
|
114226
115068
|
switch (ast._tag) {
|
|
114227
|
-
case "Transformation":
|
|
114228
|
-
return propertyAstOf(SchemaAST.typeAST(ast), key3);
|
|
114229
|
-
case "Refinement":
|
|
114230
|
-
return propertyAstOf(ast.from, key3);
|
|
114231
115069
|
case "Suspend":
|
|
114232
|
-
return propertyAstOf(ast.
|
|
114233
|
-
case "
|
|
114234
|
-
const property = ast.propertySignatures.find((entry) => entry.name ===
|
|
115070
|
+
return propertyAstOf(ast.thunk(), key2);
|
|
115071
|
+
case "Objects": {
|
|
115072
|
+
const property = ast.propertySignatures.find((entry) => entry.name === key2);
|
|
114235
115073
|
if (property !== undefined) {
|
|
114236
115074
|
return property.type;
|
|
114237
115075
|
}
|
|
114238
|
-
const
|
|
114239
|
-
return
|
|
115076
|
+
const index4 = ast.indexSignatures.find((entry) => entry.parameter._tag === "String");
|
|
115077
|
+
return index4?.type;
|
|
114240
115078
|
}
|
|
114241
115079
|
case "Union": {
|
|
114242
115080
|
const values2 = ast.types.flatMap((member) => {
|
|
114243
|
-
const next = propertyAstOf(member,
|
|
115081
|
+
const next = propertyAstOf(member, key2);
|
|
114244
115082
|
return next === undefined ? [] : [next];
|
|
114245
115083
|
});
|
|
114246
115084
|
return unionAst(values2);
|
|
@@ -114249,27 +115087,23 @@ var propertyAstOf = (ast, key3) => {
|
|
|
114249
115087
|
return;
|
|
114250
115088
|
}
|
|
114251
115089
|
};
|
|
114252
|
-
var numberAstOf = (ast,
|
|
115090
|
+
var numberAstOf = (ast, index4) => {
|
|
114253
115091
|
switch (ast._tag) {
|
|
114254
|
-
case "Transformation":
|
|
114255
|
-
return numberAstOf(SchemaAST.typeAST(ast), index5);
|
|
114256
|
-
case "Refinement":
|
|
114257
|
-
return numberAstOf(ast.from, index5);
|
|
114258
115092
|
case "Suspend":
|
|
114259
|
-
return numberAstOf(ast.
|
|
114260
|
-
case "
|
|
114261
|
-
const element = ast.elements[
|
|
115093
|
+
return numberAstOf(ast.thunk(), index4);
|
|
115094
|
+
case "Arrays": {
|
|
115095
|
+
const element = ast.elements[index4];
|
|
114262
115096
|
if (element !== undefined) {
|
|
114263
|
-
return element
|
|
115097
|
+
return element;
|
|
114264
115098
|
}
|
|
114265
115099
|
if (ast.rest.length === 0) {
|
|
114266
115100
|
return;
|
|
114267
115101
|
}
|
|
114268
|
-
return unionAst(ast.rest
|
|
115102
|
+
return unionAst(ast.rest);
|
|
114269
115103
|
}
|
|
114270
115104
|
case "Union": {
|
|
114271
115105
|
const values2 = ast.types.flatMap((member) => {
|
|
114272
|
-
const next = numberAstOf(member,
|
|
115106
|
+
const next = numberAstOf(member, index4);
|
|
114273
115107
|
return next === undefined ? [] : [next];
|
|
114274
115108
|
});
|
|
114275
115109
|
return unionAst(values2);
|
|
@@ -114280,7 +115114,7 @@ var numberAstOf = (ast, index5) => {
|
|
|
114280
115114
|
};
|
|
114281
115115
|
var exactJsonSegments = (segments) => segments.every((segment) => segment.kind === "key" || segment.kind === "index");
|
|
114282
115116
|
var schemaAstAtExactJsonPath = (schema2, segments) => {
|
|
114283
|
-
let current =
|
|
115117
|
+
let current = schema2.ast;
|
|
114284
115118
|
for (const segment of segments) {
|
|
114285
115119
|
if (segment.kind === "key") {
|
|
114286
115120
|
const property = propertyAstOf(current, segment.key);
|
|
@@ -114310,28 +115144,28 @@ var unionSchemas = (schemas) => {
|
|
|
114310
115144
|
if (resolved.length === 1) {
|
|
114311
115145
|
return resolved[0];
|
|
114312
115146
|
}
|
|
114313
|
-
return Schema8.Union(
|
|
115147
|
+
return Schema8.Union(resolved);
|
|
114314
115148
|
};
|
|
114315
115149
|
var firstSelectedExpression = (plan) => {
|
|
114316
115150
|
const selection = getAst(plan).select;
|
|
114317
115151
|
return flattenSelection(selection)[0]?.expression;
|
|
114318
115152
|
};
|
|
114319
115153
|
var isJsonCompatibleAst = (ast) => {
|
|
115154
|
+
ast = SchemaAST.toType(ast);
|
|
114320
115155
|
switch (ast._tag) {
|
|
114321
|
-
case "
|
|
114322
|
-
case "
|
|
114323
|
-
case "
|
|
114324
|
-
case "
|
|
114325
|
-
case "
|
|
115156
|
+
case "String":
|
|
115157
|
+
case "Number":
|
|
115158
|
+
case "Boolean":
|
|
115159
|
+
case "Null":
|
|
115160
|
+
case "Arrays":
|
|
115161
|
+
case "Objects":
|
|
114326
115162
|
return true;
|
|
114327
115163
|
case "Literal":
|
|
114328
|
-
return
|
|
115164
|
+
return typeof ast.literal === "string" || typeof ast.literal === "number" || typeof ast.literal === "boolean";
|
|
114329
115165
|
case "Union":
|
|
114330
115166
|
return ast.types.every(isJsonCompatibleAst);
|
|
114331
|
-
case "Transformation":
|
|
114332
|
-
return isJsonCompatibleAst(SchemaAST.typeAST(ast));
|
|
114333
115167
|
case "Suspend":
|
|
114334
|
-
return isJsonCompatibleAst(ast.
|
|
115168
|
+
return isJsonCompatibleAst(ast.thunk());
|
|
114335
115169
|
default:
|
|
114336
115170
|
return false;
|
|
114337
115171
|
}
|
|
@@ -114340,14 +115174,14 @@ var jsonCompatibleSchema = (schema2) => {
|
|
|
114340
115174
|
if (schema2 === undefined) {
|
|
114341
115175
|
return;
|
|
114342
115176
|
}
|
|
114343
|
-
const ast = SchemaAST.
|
|
115177
|
+
const ast = SchemaAST.toType(schema2.ast);
|
|
114344
115178
|
return isJsonCompatibleAst(ast) ? schema2 : JsonValueSchema;
|
|
114345
115179
|
};
|
|
114346
115180
|
var buildStructSchema = (entries, context) => {
|
|
114347
115181
|
const fields2 = Object.fromEntries(entries.map((entry) => [entry.key, expressionRuntimeSchema(entry.value, context) ?? JsonValueSchema]));
|
|
114348
115182
|
return Schema8.Struct(fields2);
|
|
114349
115183
|
};
|
|
114350
|
-
var buildTupleSchema = (values2, context) => Schema8.Tuple(
|
|
115184
|
+
var buildTupleSchema = (values2, context) => Schema8.Tuple(values2.map((value) => expressionRuntimeSchema(value, context) ?? JsonValueSchema));
|
|
114351
115185
|
var deriveCaseSchema = (ast, context) => {
|
|
114352
115186
|
if (context === undefined) {
|
|
114353
115187
|
return unionSchemas([
|
|
@@ -114500,20 +115334,20 @@ var expressionRuntimeSchema = (expression, context) => {
|
|
|
114500
115334
|
};
|
|
114501
115335
|
|
|
114502
115336
|
// src/internal/executor.ts
|
|
114503
|
-
var setPath2 = (target,
|
|
115337
|
+
var setPath2 = (target, path2, value) => {
|
|
114504
115338
|
let current = target;
|
|
114505
|
-
for (let
|
|
114506
|
-
const
|
|
114507
|
-
const existing = current[
|
|
115339
|
+
for (let index4 = 0;index4 < path2.length - 1; index4++) {
|
|
115340
|
+
const key2 = path2[index4];
|
|
115341
|
+
const existing = current[key2];
|
|
114508
115342
|
if (typeof existing === "object" && existing !== null && !Array.isArray(existing)) {
|
|
114509
115343
|
current = existing;
|
|
114510
115344
|
continue;
|
|
114511
115345
|
}
|
|
114512
115346
|
const next = {};
|
|
114513
|
-
current[
|
|
115347
|
+
current[key2] = next;
|
|
114514
115348
|
current = next;
|
|
114515
115349
|
}
|
|
114516
|
-
current[
|
|
115350
|
+
current[path2[path2.length - 1]] = value;
|
|
114517
115351
|
};
|
|
114518
115352
|
var hasWriteStatement = (statement) => statement === "insert" || statement === "update" || statement === "delete" || statement === "truncate" || statement === "merge" || statement === "transaction" || statement === "commit" || statement === "rollback" || statement === "savepoint" || statement === "rollbackTo" || statement === "releaseSavepoint" || statement === "createTable" || statement === "createIndex" || statement === "dropIndex" || statement === "dropTable";
|
|
114519
115353
|
var hasWriteCapabilityInSource = (source) => typeof source === "object" && source !== null && ("plan" in source) ? hasWriteCapability(source.plan) : false;
|
|
@@ -114553,24 +115387,31 @@ var remapRows = (query, rows) => rows.map((row) => {
|
|
|
114553
115387
|
}
|
|
114554
115388
|
return decoded;
|
|
114555
115389
|
});
|
|
114556
|
-
var makeRowDecodeError = (rendered, projection, expression, raw, stage, cause, normalized) =>
|
|
114557
|
-
|
|
114558
|
-
|
|
114559
|
-
|
|
114560
|
-
|
|
114561
|
-
|
|
114562
|
-
|
|
114563
|
-
|
|
114564
|
-
|
|
114565
|
-
|
|
114566
|
-
|
|
114567
|
-
|
|
114568
|
-
|
|
114569
|
-
|
|
114570
|
-
|
|
114571
|
-
|
|
114572
|
-
|
|
114573
|
-
|
|
115390
|
+
var makeRowDecodeError = (rendered, projection, expression, raw, stage, cause, normalized) => {
|
|
115391
|
+
const schemaError = Schema9.isSchemaError(cause) ? {
|
|
115392
|
+
message: cause.message,
|
|
115393
|
+
issue: cause.issue
|
|
115394
|
+
} : undefined;
|
|
115395
|
+
return {
|
|
115396
|
+
_tag: "RowDecodeError",
|
|
115397
|
+
message: stage === "normalize" ? `Failed to normalize projection '${projection.alias}'` : `Failed to decode projection '${projection.alias}' against its runtime schema`,
|
|
115398
|
+
dialect: rendered.dialect,
|
|
115399
|
+
query: {
|
|
115400
|
+
sql: rendered.sql,
|
|
115401
|
+
params: rendered.params
|
|
115402
|
+
},
|
|
115403
|
+
projection: {
|
|
115404
|
+
alias: projection.alias,
|
|
115405
|
+
path: projection.path
|
|
115406
|
+
},
|
|
115407
|
+
dbType: expression[TypeId].dbType,
|
|
115408
|
+
raw,
|
|
115409
|
+
normalized,
|
|
115410
|
+
stage,
|
|
115411
|
+
cause,
|
|
115412
|
+
...schemaError === undefined ? {} : { schemaError }
|
|
115413
|
+
};
|
|
115414
|
+
};
|
|
114574
115415
|
var hasOptionalSourceDependency = (expression, scope) => {
|
|
114575
115416
|
const state = expression[TypeId];
|
|
114576
115417
|
return Object.keys(state.dependencies).some((sourceName) => !scope.absentSourceNames.has(sourceName) && scope.sourceModes.get(sourceName) === "optional");
|
|
@@ -114582,11 +115423,11 @@ var effectiveRuntimeNullability = (expression, scope) => {
|
|
|
114582
115423
|
return "always";
|
|
114583
115424
|
}
|
|
114584
115425
|
if (ast.kind === "column") {
|
|
114585
|
-
const
|
|
114586
|
-
if (scope.absentSourceNames.has(ast.tableName) || scope.nullKeys.has(
|
|
115426
|
+
const key2 = columnPredicateKey(ast.tableName, ast.columnName);
|
|
115427
|
+
if (scope.absentSourceNames.has(ast.tableName) || scope.nullKeys.has(key2)) {
|
|
114587
115428
|
return "always";
|
|
114588
115429
|
}
|
|
114589
|
-
if (scope.nonNullKeys.has(
|
|
115430
|
+
if (scope.nonNullKeys.has(key2)) {
|
|
114590
115431
|
return "never";
|
|
114591
115432
|
}
|
|
114592
115433
|
}
|
|
@@ -114613,8 +115454,8 @@ var decodeProjectionValue = (rendered, projection, expression, raw, scope, drive
|
|
|
114613
115454
|
driverValueMapping: expression[TypeId].driverValueMapping,
|
|
114614
115455
|
valueMappings
|
|
114615
115456
|
});
|
|
114616
|
-
} catch (
|
|
114617
|
-
throw makeRowDecodeError(rendered, projection, expression, raw, "normalize",
|
|
115457
|
+
} catch (cause2) {
|
|
115458
|
+
throw makeRowDecodeError(rendered, projection, expression, raw, "normalize", cause2);
|
|
114618
115459
|
}
|
|
114619
115460
|
}
|
|
114620
115461
|
const nullability = effectiveRuntimeNullability(expression, scope);
|
|
@@ -114640,18 +115481,22 @@ var decodeProjectionValue = (rendered, projection, expression, raw, scope, drive
|
|
|
114640
115481
|
if (Schema9.is(schema2)(normalized)) {
|
|
114641
115482
|
return normalized;
|
|
114642
115483
|
}
|
|
114643
|
-
|
|
114644
|
-
|
|
114645
|
-
|
|
114646
|
-
throw makeRowDecodeError(rendered, projection, expression, raw, "schema", cause, normalized);
|
|
115484
|
+
const decoded = Schema9.decodeUnknownExit(schema2)(normalized);
|
|
115485
|
+
if (Exit.isSuccess(decoded)) {
|
|
115486
|
+
return decoded.value;
|
|
114647
115487
|
}
|
|
115488
|
+
const cause = Option.match(Exit.findErrorOption(decoded), {
|
|
115489
|
+
onNone: () => decoded.cause,
|
|
115490
|
+
onSome: (schemaError) => schemaError
|
|
115491
|
+
});
|
|
115492
|
+
throw makeRowDecodeError(rendered, projection, expression, raw, "schema", cause, normalized);
|
|
114648
115493
|
};
|
|
114649
115494
|
var makeRowDecoder = (rendered, plan, options2 = {}) => {
|
|
114650
115495
|
const projections = flattenSelection(getAst(plan).select);
|
|
114651
115496
|
const byPath = new Map(projections.map((projection) => [JSON.stringify(projection.path), projection.expression]));
|
|
114652
115497
|
const driverMode = options2.driverMode ?? "raw";
|
|
114653
115498
|
const valueMappings = options2.valueMappings ?? rendered.valueMappings;
|
|
114654
|
-
const scope = resolveImplicationScope(plan[
|
|
115499
|
+
const scope = resolveImplicationScope(plan[TypeId4].available, getQueryState(plan).assumptions);
|
|
114655
115500
|
return (row) => {
|
|
114656
115501
|
const decoded = {};
|
|
114657
115502
|
for (const projection of rendered.projections) {
|
|
@@ -114669,7 +115514,7 @@ var makeRowDecoder = (rendered, plan, options2 = {}) => {
|
|
|
114669
115514
|
};
|
|
114670
115515
|
var decodeChunk = (rendered, plan, rows, options2 = {}) => {
|
|
114671
115516
|
const decodeRow = makeRowDecoder(rendered, plan, options2);
|
|
114672
|
-
return Chunk.
|
|
115517
|
+
return Chunk.fromIterable(Chunk.toReadonlyArray(rows).map((row) => decodeRow(row)));
|
|
114673
115518
|
};
|
|
114674
115519
|
var decodeRows = (rendered, plan, rows, options2 = {}) => {
|
|
114675
115520
|
const decodeRow = makeRowDecoder(rendered, plan, options2);
|
|
@@ -114707,12 +115552,12 @@ var fromDriver = (renderer, sqlDriver) => {
|
|
|
114707
115552
|
},
|
|
114708
115553
|
stream(plan) {
|
|
114709
115554
|
const rendered = renderer.render(plan);
|
|
114710
|
-
return Stream.
|
|
115555
|
+
return Stream.mapArray(sqlDriver.stream(rendered), (rows) => remapRows(rendered, rows));
|
|
114711
115556
|
}
|
|
114712
115557
|
};
|
|
114713
115558
|
return executor;
|
|
114714
115559
|
};
|
|
114715
|
-
var streamFromSqlClient = (query) => Stream.
|
|
115560
|
+
var streamFromSqlClient = (query) => Stream.unwrap(Effect.flatMap(SqlClient.SqlClient, (sql) => Effect.flatMap(Effect.serviceOption(sql.transactionService), Option.match({
|
|
114716
115561
|
onNone: () => sql.reserve,
|
|
114717
115562
|
onSome: ([connection]) => Effect.succeed(connection)
|
|
114718
115563
|
})).pipe(Effect.map((connection) => connection.executeStream(query.sql, [...query.params], undefined)))));
|
|
@@ -114721,12 +115566,11 @@ var fromSqlClient = (renderer) => fromDriver(renderer, driver(renderer.dialect,
|
|
|
114721
115566
|
stream: (query) => streamFromSqlClient(query)
|
|
114722
115567
|
}));
|
|
114723
115568
|
var withTransaction = (effect) => Effect.flatMap(SqlClient.SqlClient, (sql) => sql.withTransaction(effect));
|
|
114724
|
-
var withSavepoint = (effect) => Effect.flatMap(SqlClient.SqlClient, (sql) => sql.withTransaction(effect));
|
|
114725
115569
|
|
|
114726
115570
|
// src/internal/renderer.ts
|
|
114727
115571
|
var TypeId10 = Symbol.for("effect-qb/Renderer");
|
|
114728
|
-
var projectionPathKey = (
|
|
114729
|
-
var formatProjectionPath2 = (
|
|
115572
|
+
var projectionPathKey = (path2) => JSON.stringify(path2);
|
|
115573
|
+
var formatProjectionPath2 = (path2) => path2.join(".");
|
|
114730
115574
|
var validateProjectionPathsMatchSelection = (plan, projections) => {
|
|
114731
115575
|
const expected = flattenSelection(getAst(plan).select);
|
|
114732
115576
|
const expectedPaths = new Set(expected.map((projection) => projectionPathKey(projection.path)));
|
|
@@ -114785,14 +115629,15 @@ var renderDbTypeName = (value) => value;
|
|
|
114785
115629
|
// src/internal/dialect-renderers/mysql.ts
|
|
114786
115630
|
import * as Schema10 from "effect/Schema";
|
|
114787
115631
|
var renderDbType = (dialect, dbType) => {
|
|
114788
|
-
|
|
114789
|
-
return "char(36)";
|
|
114790
|
-
}
|
|
114791
|
-
return renderDbTypeName(dbType.kind);
|
|
115632
|
+
return renderDbTypeName(renderPortableDatatypeDdlType(dialect.name, dbType.kind) ?? dbType.kind);
|
|
114792
115633
|
};
|
|
114793
115634
|
var isArrayDbType = (dbType) => ("element" in dbType);
|
|
114794
115635
|
var renderCastType = (dialect, dbType) => {
|
|
114795
115636
|
const kind = dbType?.kind;
|
|
115637
|
+
const portableType = renderPortableDatatypeCastType(dialect.name, kind);
|
|
115638
|
+
if (portableType !== undefined) {
|
|
115639
|
+
return renderDbTypeName(portableType);
|
|
115640
|
+
}
|
|
114796
115641
|
if (dialect.name !== "mysql") {
|
|
114797
115642
|
return renderDbTypeName(kind);
|
|
114798
115643
|
}
|
|
@@ -114861,7 +115706,7 @@ var renderMysqlMutationLimit = (expression, state, dialect) => {
|
|
|
114861
115706
|
}
|
|
114862
115707
|
return renderExpression(expression, state, dialect);
|
|
114863
115708
|
};
|
|
114864
|
-
var casingForTable = (table, state) => merge(state.casing, table[
|
|
115709
|
+
var casingForTable = (table, state) => merge(state.casing, table[TypeId7].casing);
|
|
114865
115710
|
var casedColumnName = (columnName, state, tableName) => {
|
|
114866
115711
|
if (tableName !== undefined) {
|
|
114867
115712
|
const mapped = state.sourceNames?.get(tableName)?.columns.get(columnName);
|
|
@@ -114873,7 +115718,7 @@ var casedColumnName = (columnName, state, tableName) => {
|
|
|
114873
115718
|
};
|
|
114874
115719
|
var casedTableReferenceName = (tableName, state) => state.sourceNames?.get(tableName)?.tableName ?? applyCategory(state.casing, "tables", tableName);
|
|
114875
115720
|
var quoteColumn = (columnName, state, dialect, tableName) => dialect.quoteIdentifier(casedColumnName(columnName, state, tableName));
|
|
114876
|
-
var stateWithTableCasing = (state, source) => typeof source === "object" && source !== null && (
|
|
115721
|
+
var stateWithTableCasing = (state, source) => typeof source === "object" && source !== null && (TypeId7 in source) ? { ...state, casing: casingForTable(source, state) } : state;
|
|
114877
115722
|
var referenceCasing = (reference, state) => merge(state.casing, reference.casing);
|
|
114878
115723
|
var renderReferenceTable = (reference, state, dialect) => {
|
|
114879
115724
|
const casing = referenceCasing(reference, state);
|
|
@@ -114886,9 +115731,9 @@ var registerSourceReference = (source, tableName, state) => {
|
|
|
114886
115731
|
if (typeof source !== "object" || source === null) {
|
|
114887
115732
|
return;
|
|
114888
115733
|
}
|
|
114889
|
-
if (
|
|
115734
|
+
if (TypeId7 in source) {
|
|
114890
115735
|
const table = source;
|
|
114891
|
-
const tableState = table[
|
|
115736
|
+
const tableState = table[TypeId7];
|
|
114892
115737
|
const casing = casingForTable(table, state);
|
|
114893
115738
|
const renderedTableName = tableState.kind === "alias" ? tableName : applyCategory(casing, "tables", tableState.baseName);
|
|
114894
115739
|
const columns = new Map(Object.keys(tableState.fields).map((columnName) => [
|
|
@@ -114956,11 +115801,11 @@ var renderCreateTableSql = (targetSource, state, dialect, ifNotExists) => {
|
|
|
114956
115801
|
const normalizedIfNotExists = normalizeStatementFlag(ifNotExists);
|
|
114957
115802
|
const table = targetSource.source;
|
|
114958
115803
|
const tableCasing = casingForTable(table, state);
|
|
114959
|
-
const fields2 = table[
|
|
115804
|
+
const fields2 = table[TypeId7].fields;
|
|
114960
115805
|
const definitions = Object.entries(fields2).map(([columnName, column]) => renderColumnDefinition(dialect, state, columnName, column, targetSource.tableName, tableCasing));
|
|
114961
115806
|
const options2 = table[OptionsSymbol];
|
|
114962
115807
|
const tableOptions = Array.isArray(options2) ? options2 : [options2];
|
|
114963
|
-
validateOptions(table[
|
|
115808
|
+
validateOptions(table[TypeId7].name, fields2, tableOptions);
|
|
114964
115809
|
for (const option2 of tableOptions) {
|
|
114965
115810
|
if (typeof option2 !== "object" || option2 === null || !("kind" in option2)) {
|
|
114966
115811
|
continue;
|
|
@@ -115022,7 +115867,7 @@ var renderDropIndexSql = (targetSource, ddl, state, dialect) => {
|
|
|
115022
115867
|
const tableCasing = casingForTable(table, state);
|
|
115023
115868
|
return dialect.name === "postgres" ? `drop index${ifExists ? " if exists" : ""} ${dialect.quoteIdentifier(applyCategory(tableCasing, "indexes", name))}` : `drop index ${dialect.quoteIdentifier(applyCategory(tableCasing, "indexes", name))} on ${renderSourceReference(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)}`;
|
|
115024
115869
|
};
|
|
115025
|
-
var
|
|
115870
|
+
var isExpression4 = (value) => value !== null && typeof value === "object" && (TypeId in value);
|
|
115026
115871
|
var isJsonDbType2 = (dbType) => {
|
|
115027
115872
|
if (dbType.kind === "jsonb" || dbType.kind === "json") {
|
|
115028
115873
|
return true;
|
|
@@ -115033,7 +115878,7 @@ var isJsonDbType2 = (dbType) => {
|
|
|
115033
115878
|
const variant = dbType.variant;
|
|
115034
115879
|
return variant === "json" || variant === "jsonb";
|
|
115035
115880
|
};
|
|
115036
|
-
var
|
|
115881
|
+
var isJsonExpression2 = (value) => isExpression4(value) && isJsonDbType2(value[TypeId].dbType);
|
|
115037
115882
|
var expectValueExpression = (_functionName, value) => value;
|
|
115038
115883
|
var expectBinaryExpressions = (_functionName, left, right) => [left, right];
|
|
115039
115884
|
var renderBinaryExpression = (functionName, operator, left, right, state, dialect) => {
|
|
@@ -115050,7 +115895,7 @@ var unsupportedJsonFeature = (dialect, feature) => {
|
|
|
115050
115895
|
throw error;
|
|
115051
115896
|
};
|
|
115052
115897
|
var extractJsonBase = (node) => node.value ?? node.base ?? node.input ?? node.left ?? node.target;
|
|
115053
|
-
var isJsonPathValue2 = (value) => value !== null && typeof value === "object" && (
|
|
115898
|
+
var isJsonPathValue2 = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
115054
115899
|
var isOptionalJsonPathNumber = (value) => value === undefined || typeof value === "number" && Number.isFinite(value);
|
|
115055
115900
|
var isJsonPathSegment = (segment) => {
|
|
115056
115901
|
if (typeof segment === "string") {
|
|
@@ -115066,8 +115911,8 @@ var isJsonPathSegment = (segment) => {
|
|
|
115066
115911
|
case "key":
|
|
115067
115912
|
return typeof segment.key === "string";
|
|
115068
115913
|
case "index": {
|
|
115069
|
-
const
|
|
115070
|
-
return typeof
|
|
115914
|
+
const index4 = segment.index;
|
|
115915
|
+
return typeof index4 === "number" && Number.isFinite(index4);
|
|
115071
115916
|
}
|
|
115072
115917
|
case "wildcard":
|
|
115073
115918
|
case "descend":
|
|
@@ -115088,12 +115933,12 @@ var validateJsonPathSegments = (segments) => {
|
|
|
115088
115933
|
return segments;
|
|
115089
115934
|
};
|
|
115090
115935
|
var extractJsonPathSegments = (node) => {
|
|
115091
|
-
const
|
|
115092
|
-
if (isJsonPathValue2(
|
|
115093
|
-
return validateJsonPathSegments(
|
|
115936
|
+
const path2 = node.path ?? node.segments ?? node.keys;
|
|
115937
|
+
if (isJsonPathValue2(path2)) {
|
|
115938
|
+
return validateJsonPathSegments(path2.segments);
|
|
115094
115939
|
}
|
|
115095
|
-
if (Array.isArray(
|
|
115096
|
-
return validateJsonPathSegments(
|
|
115940
|
+
if (Array.isArray(path2)) {
|
|
115941
|
+
return validateJsonPathSegments(path2);
|
|
115097
115942
|
}
|
|
115098
115943
|
if (node.segments !== undefined) {
|
|
115099
115944
|
return validateJsonPathSegments(node.segments);
|
|
@@ -115107,7 +115952,7 @@ var extractJsonPathSegments = (node) => {
|
|
|
115107
115952
|
return [key(segment)];
|
|
115108
115953
|
}
|
|
115109
115954
|
if (typeof segment === "number") {
|
|
115110
|
-
return [
|
|
115955
|
+
return [index(segment)];
|
|
115111
115956
|
}
|
|
115112
115957
|
if (segment !== null && typeof segment === "object" && SegmentTypeId in segment) {
|
|
115113
115958
|
return [segment];
|
|
@@ -115144,7 +115989,7 @@ var renderJsonPathSegment = (segment) => {
|
|
|
115144
115989
|
throw new Error("Unsupported JSON path segment");
|
|
115145
115990
|
}
|
|
115146
115991
|
};
|
|
115147
|
-
var renderMySqlJsonIndex = (
|
|
115992
|
+
var renderMySqlJsonIndex = (index4) => index4 >= 0 ? String(index4) : index4 === -1 ? "last" : `last-${Math.abs(index4) - 1}`;
|
|
115148
115993
|
var renderMySqlJsonPathSegment = (segment) => {
|
|
115149
115994
|
if (typeof segment === "number") {
|
|
115150
115995
|
return `[${renderMySqlJsonIndex(segment)}]`;
|
|
@@ -115161,11 +116006,11 @@ var renderMySqlJsonPathSegment = (segment) => {
|
|
|
115161
116006
|
return renderJsonPathSegment(segment);
|
|
115162
116007
|
};
|
|
115163
116008
|
var renderJsonPathStringLiteral = (segments, renderSegment = renderJsonPathSegment) => {
|
|
115164
|
-
let
|
|
116009
|
+
let path2 = "$";
|
|
115165
116010
|
for (const segment of segments) {
|
|
115166
|
-
|
|
116011
|
+
path2 += renderSegment(segment);
|
|
115167
116012
|
}
|
|
115168
|
-
return
|
|
116013
|
+
return path2;
|
|
115169
116014
|
};
|
|
115170
116015
|
var renderMySqlJsonPath = (segments, state, dialect) => dialect.renderLiteral(renderJsonPathStringLiteral(segments, renderMySqlJsonPathSegment), state);
|
|
115171
116016
|
var isJsonArrayIndexSegment = (segment) => typeof segment === "number" || typeof segment === "object" && segment !== null && segment.kind === "index";
|
|
@@ -115217,7 +116062,7 @@ var renderPostgresJsonAccessStep = (segment, textMode, state, dialect) => {
|
|
|
115217
116062
|
}
|
|
115218
116063
|
};
|
|
115219
116064
|
var renderPostgresJsonValue = (value, state, dialect) => {
|
|
115220
|
-
if (!
|
|
116065
|
+
if (!isExpression4(value)) {
|
|
115221
116066
|
throw new Error("Expected a JSON expression");
|
|
115222
116067
|
}
|
|
115223
116068
|
const rendered = renderExpression(value, state, dialect);
|
|
@@ -115274,7 +116119,7 @@ var renderJsonOpaquePath = (value, state, dialect) => {
|
|
|
115274
116119
|
}
|
|
115275
116120
|
return dialect.renderLiteral(value, state);
|
|
115276
116121
|
}
|
|
115277
|
-
if (
|
|
116122
|
+
if (isExpression4(value)) {
|
|
115278
116123
|
const ast = value[TypeId2];
|
|
115279
116124
|
if (ast.kind === "literal" && typeof ast.value === "string" && ast.value.trim().length === 0) {
|
|
115280
116125
|
throw new Error("SQL/JSON path input must be a non-empty string");
|
|
@@ -115324,8 +116169,8 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115324
116169
|
const base = extractJsonBase(ast);
|
|
115325
116170
|
const segments = extractJsonPathSegments(ast);
|
|
115326
116171
|
const exact = segments.every((segment) => segment.kind === "key" || segment.kind === "index");
|
|
115327
|
-
const postgresExpressionKind = dialect.name === "postgres" &&
|
|
115328
|
-
const postgresBaseKind = dialect.name === "postgres" &&
|
|
116172
|
+
const postgresExpressionKind = dialect.name === "postgres" && isJsonExpression2(expression) ? renderPostgresJsonKind(expression) : undefined;
|
|
116173
|
+
const postgresBaseKind = dialect.name === "postgres" && isJsonExpression2(base) ? renderPostgresJsonKind(base) : undefined;
|
|
115329
116174
|
switch (kind) {
|
|
115330
116175
|
case "jsonGet":
|
|
115331
116176
|
case "jsonPath":
|
|
@@ -115335,7 +116180,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115335
116180
|
case "jsonPathText":
|
|
115336
116181
|
case "jsonAccessText":
|
|
115337
116182
|
case "jsonTraverseText": {
|
|
115338
|
-
if (!
|
|
116183
|
+
if (!isExpression4(base) || segments.length === 0) {
|
|
115339
116184
|
return;
|
|
115340
116185
|
}
|
|
115341
116186
|
const baseSql = renderExpression(base, state, dialect);
|
|
@@ -115358,24 +116203,24 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115358
116203
|
case "jsonKeyExists":
|
|
115359
116204
|
case "jsonHasAnyKeys":
|
|
115360
116205
|
case "jsonHasAllKeys": {
|
|
115361
|
-
if (!
|
|
116206
|
+
if (!isExpression4(base)) {
|
|
115362
116207
|
return;
|
|
115363
116208
|
}
|
|
115364
116209
|
const baseSql = dialect.name === "postgres" ? renderPostgresJsonValue(base, state, dialect) : renderExpression(base, state, dialect);
|
|
115365
|
-
const
|
|
115366
|
-
if (
|
|
116210
|
+
const keys = extractJsonKeys(ast, segments);
|
|
116211
|
+
if (keys.length === 0) {
|
|
115367
116212
|
return;
|
|
115368
116213
|
}
|
|
115369
|
-
if (
|
|
116214
|
+
if (keys.some((key2) => typeof key2 !== "string" || key2.length === 0)) {
|
|
115370
116215
|
throw new Error("json key predicates require string keys");
|
|
115371
116216
|
}
|
|
115372
|
-
const keyNames =
|
|
116217
|
+
const keyNames = keys;
|
|
115373
116218
|
if (dialect.name === "postgres") {
|
|
115374
116219
|
if (kind === "jsonHasAnyKeys") {
|
|
115375
|
-
return `(${baseSql} ?| array[${keyNames.map((
|
|
116220
|
+
return `(${baseSql} ?| array[${keyNames.map((key2) => renderPostgresTextLiteral(key2, state, dialect)).join(", ")}])`;
|
|
115376
116221
|
}
|
|
115377
116222
|
if (kind === "jsonHasAllKeys") {
|
|
115378
|
-
return `(${baseSql} ?& array[${keyNames.map((
|
|
116223
|
+
return `(${baseSql} ?& array[${keyNames.map((key2) => renderPostgresTextLiteral(key2, state, dialect)).join(", ")}])`;
|
|
115379
116224
|
}
|
|
115380
116225
|
return `(${baseSql} ? ${renderPostgresTextLiteral(keyNames[0], state, dialect)})`;
|
|
115381
116226
|
}
|
|
@@ -115389,7 +116234,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115389
116234
|
}
|
|
115390
116235
|
case "jsonConcat":
|
|
115391
116236
|
case "jsonMerge": {
|
|
115392
|
-
if (!
|
|
116237
|
+
if (!isExpression4(ast.left) || !isExpression4(ast.right)) {
|
|
115393
116238
|
return;
|
|
115394
116239
|
}
|
|
115395
116240
|
if (dialect.name === "postgres") {
|
|
@@ -115426,7 +116271,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115426
116271
|
return;
|
|
115427
116272
|
}
|
|
115428
116273
|
case "jsonToJson":
|
|
115429
|
-
if (!
|
|
116274
|
+
if (!isExpression4(base)) {
|
|
115430
116275
|
return;
|
|
115431
116276
|
}
|
|
115432
116277
|
if (dialect.name === "postgres") {
|
|
@@ -115437,7 +116282,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115437
116282
|
}
|
|
115438
116283
|
return;
|
|
115439
116284
|
case "jsonToJsonb":
|
|
115440
|
-
if (!
|
|
116285
|
+
if (!isExpression4(base)) {
|
|
115441
116286
|
return;
|
|
115442
116287
|
}
|
|
115443
116288
|
if (dialect.name === "postgres") {
|
|
@@ -115448,7 +116293,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115448
116293
|
}
|
|
115449
116294
|
return;
|
|
115450
116295
|
case "jsonTypeOf":
|
|
115451
|
-
if (!
|
|
116296
|
+
if (!isExpression4(base)) {
|
|
115452
116297
|
return;
|
|
115453
116298
|
}
|
|
115454
116299
|
if (dialect.name === "postgres") {
|
|
@@ -115460,7 +116305,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115460
116305
|
}
|
|
115461
116306
|
return;
|
|
115462
116307
|
case "jsonLength":
|
|
115463
|
-
if (!
|
|
116308
|
+
if (!isExpression4(base)) {
|
|
115464
116309
|
return;
|
|
115465
116310
|
}
|
|
115466
116311
|
if (dialect.name === "postgres") {
|
|
@@ -115475,7 +116320,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115475
116320
|
}
|
|
115476
116321
|
return;
|
|
115477
116322
|
case "jsonKeys":
|
|
115478
|
-
if (!
|
|
116323
|
+
if (!isExpression4(base)) {
|
|
115479
116324
|
return;
|
|
115480
116325
|
}
|
|
115481
116326
|
if (dialect.name === "postgres") {
|
|
@@ -115489,7 +116334,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115489
116334
|
}
|
|
115490
116335
|
return;
|
|
115491
116336
|
case "jsonStripNulls":
|
|
115492
|
-
if (!
|
|
116337
|
+
if (!isExpression4(base)) {
|
|
115493
116338
|
return;
|
|
115494
116339
|
}
|
|
115495
116340
|
if (dialect.name === "postgres") {
|
|
@@ -115500,7 +116345,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115500
116345
|
case "jsonDelete":
|
|
115501
116346
|
case "jsonDeletePath":
|
|
115502
116347
|
case "jsonRemove": {
|
|
115503
|
-
if (!
|
|
116348
|
+
if (!isExpression4(base) || segments.length === 0) {
|
|
115504
116349
|
return;
|
|
115505
116350
|
}
|
|
115506
116351
|
if (dialect.name === "postgres") {
|
|
@@ -115519,11 +116364,11 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115519
116364
|
}
|
|
115520
116365
|
case "jsonSet":
|
|
115521
116366
|
case "jsonInsert": {
|
|
115522
|
-
if (!
|
|
116367
|
+
if (!isExpression4(base) || segments.length === 0) {
|
|
115523
116368
|
return;
|
|
115524
116369
|
}
|
|
115525
116370
|
const nextValue = extractJsonValue(ast);
|
|
115526
|
-
if (!
|
|
116371
|
+
if (!isExpression4(nextValue)) {
|
|
115527
116372
|
return;
|
|
115528
116373
|
}
|
|
115529
116374
|
const createMissing = ast.createMissing === true;
|
|
@@ -115549,39 +116394,39 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115549
116394
|
return;
|
|
115550
116395
|
}
|
|
115551
116396
|
case "jsonPathExists": {
|
|
115552
|
-
if (!
|
|
116397
|
+
if (!isExpression4(base)) {
|
|
115553
116398
|
return;
|
|
115554
116399
|
}
|
|
115555
|
-
const
|
|
115556
|
-
if (
|
|
116400
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
116401
|
+
if (path2 === undefined) {
|
|
115557
116402
|
return;
|
|
115558
116403
|
}
|
|
115559
116404
|
if (dialect.name === "postgres") {
|
|
115560
|
-
return `(${renderPostgresJsonValue(base, state, dialect)} @? ${renderJsonOpaquePath(
|
|
116405
|
+
return `(${renderPostgresJsonValue(base, state, dialect)} @? ${renderJsonOpaquePath(path2, state, dialect)})`;
|
|
115561
116406
|
}
|
|
115562
116407
|
if (dialect.name === "mysql") {
|
|
115563
|
-
return `json_contains_path(${renderExpression(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath(
|
|
116408
|
+
return `json_contains_path(${renderExpression(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath(path2, state, dialect)})`;
|
|
115564
116409
|
}
|
|
115565
116410
|
return;
|
|
115566
116411
|
}
|
|
115567
116412
|
case "jsonPathMatch": {
|
|
115568
|
-
if (!
|
|
116413
|
+
if (!isExpression4(base)) {
|
|
115569
116414
|
return;
|
|
115570
116415
|
}
|
|
115571
|
-
const
|
|
115572
|
-
if (
|
|
116416
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
116417
|
+
if (path2 === undefined) {
|
|
115573
116418
|
return;
|
|
115574
116419
|
}
|
|
115575
116420
|
if (dialect.name === "postgres") {
|
|
115576
|
-
return `(${renderPostgresJsonValue(base, state, dialect)} @@ ${renderJsonOpaquePath(
|
|
116421
|
+
return `(${renderPostgresJsonValue(base, state, dialect)} @@ ${renderJsonOpaquePath(path2, state, dialect)})`;
|
|
115577
116422
|
}
|
|
115578
116423
|
unsupportedJsonFeature(dialect, "jsonPathMatch");
|
|
115579
116424
|
}
|
|
115580
116425
|
}
|
|
115581
116426
|
return;
|
|
115582
116427
|
};
|
|
115583
|
-
var selectionProjections = (selection) => flattenSelection(selection).map(({ path:
|
|
115584
|
-
path:
|
|
116428
|
+
var selectionProjections = (selection) => flattenSelection(selection).map(({ path: path2, alias: alias2 }) => ({
|
|
116429
|
+
path: path2,
|
|
115585
116430
|
alias: alias2
|
|
115586
116431
|
}));
|
|
115587
116432
|
var renderMutationAssignment = (entry, state, dialect, targetTableName) => {
|
|
@@ -115721,18 +116566,18 @@ var renderQueryAst = (ast, state, dialect, options2 = {}) => {
|
|
|
115721
116566
|
const columns = insertSource.columns.map((column) => quoteColumn(column, state, dialect, targetSource.tableName)).join(", ");
|
|
115722
116567
|
if (dialect.name === "postgres") {
|
|
115723
116568
|
const table = targetSource.source;
|
|
115724
|
-
const fields2 = table[
|
|
116569
|
+
const fields2 = table[TypeId7].fields;
|
|
115725
116570
|
const rendered = insertSource.values.map((entry) => `cast(${dialect.renderLiteral(encodeArrayValues(entry.values, fields2[entry.columnName], state, dialect), state)} as ${renderCastType(dialect, fields2[entry.columnName].metadata.dbType)}[])`).join(", ");
|
|
115726
116571
|
sql += ` (${columns}) select * from unnest(${rendered})`;
|
|
115727
116572
|
} else {
|
|
115728
116573
|
const table = targetSource.source;
|
|
115729
|
-
const fields2 = table[
|
|
116574
|
+
const fields2 = table[TypeId7].fields;
|
|
115730
116575
|
const encodedValues = insertSource.values.map((entry) => ({
|
|
115731
116576
|
columnName: entry.columnName,
|
|
115732
116577
|
values: encodeArrayValues(entry.values, fields2[entry.columnName], state, dialect)
|
|
115733
116578
|
}));
|
|
115734
116579
|
const rowCount = encodedValues[0]?.values.length ?? 0;
|
|
115735
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
116580
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => `(${encodedValues.map((entry) => dialect.renderLiteral(entry.values[index4], state)).join(", ")})`).join(", ");
|
|
115736
116581
|
sql += ` (${columns}) values ${rows}`;
|
|
115737
116582
|
}
|
|
115738
116583
|
} else {
|
|
@@ -115890,25 +116735,25 @@ var renderQueryAst = (ast, state, dialect, options2 = {}) => {
|
|
|
115890
116735
|
const mergeAst = ast;
|
|
115891
116736
|
const targetSource = mergeAst.target;
|
|
115892
116737
|
const usingSource = mergeAst.using;
|
|
115893
|
-
const
|
|
115894
|
-
sql = `merge into ${renderSourceReference(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)} using ${renderSourceReference(usingSource.source, usingSource.tableName, usingSource.baseTableName, state, dialect)} on ${renderExpression(
|
|
115895
|
-
if (
|
|
116738
|
+
const merge2 = mergeAst.merge;
|
|
116739
|
+
sql = `merge into ${renderSourceReference(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)} using ${renderSourceReference(usingSource.source, usingSource.tableName, usingSource.baseTableName, state, dialect)} on ${renderExpression(merge2.on, state, dialect)}`;
|
|
116740
|
+
if (merge2.whenMatched) {
|
|
115896
116741
|
sql += " when matched";
|
|
115897
|
-
if (
|
|
115898
|
-
sql += ` and ${renderExpression(
|
|
116742
|
+
if (merge2.whenMatched.predicate) {
|
|
116743
|
+
sql += ` and ${renderExpression(merge2.whenMatched.predicate, state, dialect)}`;
|
|
115899
116744
|
}
|
|
115900
|
-
if (
|
|
116745
|
+
if (merge2.whenMatched.kind === "delete") {
|
|
115901
116746
|
sql += " then delete";
|
|
115902
116747
|
} else {
|
|
115903
|
-
sql += ` then update set ${
|
|
116748
|
+
sql += ` then update set ${merge2.whenMatched.values.map((entry) => `${dialect.quoteIdentifier(entry.columnName)} = ${renderExpression(entry.value, state, dialect)}`).join(", ")}`;
|
|
115904
116749
|
}
|
|
115905
116750
|
}
|
|
115906
|
-
if (
|
|
116751
|
+
if (merge2.whenNotMatched) {
|
|
115907
116752
|
sql += " when not matched";
|
|
115908
|
-
if (
|
|
115909
|
-
sql += ` and ${renderExpression(
|
|
116753
|
+
if (merge2.whenNotMatched.predicate) {
|
|
116754
|
+
sql += ` and ${renderExpression(merge2.whenNotMatched.predicate, state, dialect)}`;
|
|
115910
116755
|
}
|
|
115911
|
-
sql += ` then insert (${
|
|
116756
|
+
sql += ` then insert (${merge2.whenNotMatched.values.map((entry) => dialect.quoteIdentifier(entry.columnName)).join(", ")}) values (${merge2.whenNotMatched.values.map((entry) => renderExpression(entry.value, state, dialect)).join(", ")})`;
|
|
115912
116757
|
}
|
|
115913
116758
|
break;
|
|
115914
116759
|
}
|
|
@@ -115969,7 +116814,7 @@ var renderSourceReference = (source, tableName, baseTableName, state, dialect) =
|
|
|
115969
116814
|
};
|
|
115970
116815
|
const renderUnnestRows = (arrays, columnNames) => {
|
|
115971
116816
|
const rowCount = arrays[columnNames[0]].length;
|
|
115972
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
116817
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => Object.fromEntries(columnNames.map((columnName) => [columnName, arrays[columnName][index4]])));
|
|
115973
116818
|
return renderSelectRows(rows, columnNames);
|
|
115974
116819
|
};
|
|
115975
116820
|
if (typeof source === "object" && source !== null && "kind" in source && source.kind === "cte") {
|
|
@@ -116024,10 +116869,10 @@ var renderSourceReference = (source, tableName, baseTableName, state, dialect) =
|
|
|
116024
116869
|
const columnNames = Object.keys(tableFunction.columns);
|
|
116025
116870
|
return `${functionName}(${tableFunction.args.map((arg) => renderExpression(arg, state, dialect)).join(", ")}) as ${dialect.quoteIdentifier(tableFunction.name)}(${columnNames.map((columnName) => dialect.quoteIdentifier(columnName)).join(", ")})`;
|
|
116026
116871
|
}
|
|
116027
|
-
const schemaName = typeof source === "object" && source !== null &&
|
|
116028
|
-
if (typeof source === "object" && source !== null &&
|
|
116872
|
+
const schemaName = typeof source === "object" && source !== null && TypeId7 in source ? source[TypeId7].schemaName : undefined;
|
|
116873
|
+
if (typeof source === "object" && source !== null && TypeId7 in source) {
|
|
116029
116874
|
const table = source;
|
|
116030
|
-
const tableState = table[
|
|
116875
|
+
const tableState = table[TypeId7];
|
|
116031
116876
|
const casing = casingForTable(table, state);
|
|
116032
116877
|
const renderedTableName = tableState.kind === "alias" ? tableName : applyCategory(casing, "tables", baseTableName);
|
|
116033
116878
|
const renderedBaseName = applyCategory(casing, "tables", baseTableName);
|
|
@@ -116120,11 +116965,11 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116120
116965
|
case "contains": {
|
|
116121
116966
|
const [leftExpression, rightExpression] = expectBinaryExpressions("contains", ast.left, ast.right);
|
|
116122
116967
|
if (dialect.name === "postgres") {
|
|
116123
|
-
const left =
|
|
116124
|
-
const right =
|
|
116968
|
+
const left = isJsonExpression2(leftExpression) ? renderPostgresJsonValue(leftExpression, state, dialect) : renderExpression(leftExpression, state, dialect);
|
|
116969
|
+
const right = isJsonExpression2(rightExpression) ? renderPostgresJsonValue(rightExpression, state, dialect) : renderExpression(rightExpression, state, dialect);
|
|
116125
116970
|
return `(${left} @> ${right})`;
|
|
116126
116971
|
}
|
|
116127
|
-
if (dialect.name === "mysql" &&
|
|
116972
|
+
if (dialect.name === "mysql" && isJsonExpression2(leftExpression) && isJsonExpression2(rightExpression)) {
|
|
116128
116973
|
return `json_contains(${renderJsonInputExpression(leftExpression, state, dialect)}, ${renderJsonInputExpression(rightExpression, state, dialect)})`;
|
|
116129
116974
|
}
|
|
116130
116975
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -116132,11 +116977,11 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116132
116977
|
case "containedBy": {
|
|
116133
116978
|
const [leftExpression, rightExpression] = expectBinaryExpressions("containedBy", ast.left, ast.right);
|
|
116134
116979
|
if (dialect.name === "postgres") {
|
|
116135
|
-
const left =
|
|
116136
|
-
const right =
|
|
116980
|
+
const left = isJsonExpression2(leftExpression) ? renderPostgresJsonValue(leftExpression, state, dialect) : renderExpression(leftExpression, state, dialect);
|
|
116981
|
+
const right = isJsonExpression2(rightExpression) ? renderPostgresJsonValue(rightExpression, state, dialect) : renderExpression(rightExpression, state, dialect);
|
|
116137
116982
|
return `(${left} <@ ${right})`;
|
|
116138
116983
|
}
|
|
116139
|
-
if (dialect.name === "mysql" &&
|
|
116984
|
+
if (dialect.name === "mysql" && isJsonExpression2(leftExpression) && isJsonExpression2(rightExpression)) {
|
|
116140
116985
|
return `json_contains(${renderJsonInputExpression(rightExpression, state, dialect)}, ${renderJsonInputExpression(leftExpression, state, dialect)})`;
|
|
116141
116986
|
}
|
|
116142
116987
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -116144,11 +116989,11 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116144
116989
|
case "overlaps": {
|
|
116145
116990
|
const [leftExpression, rightExpression] = expectBinaryExpressions("overlaps", ast.left, ast.right);
|
|
116146
116991
|
if (dialect.name === "postgres") {
|
|
116147
|
-
const left =
|
|
116148
|
-
const right =
|
|
116992
|
+
const left = isJsonExpression2(leftExpression) ? renderPostgresJsonValue(leftExpression, state, dialect) : renderExpression(leftExpression, state, dialect);
|
|
116993
|
+
const right = isJsonExpression2(rightExpression) ? renderPostgresJsonValue(rightExpression, state, dialect) : renderExpression(rightExpression, state, dialect);
|
|
116149
116994
|
return `(${left} && ${right})`;
|
|
116150
116995
|
}
|
|
116151
|
-
if (dialect.name === "mysql" &&
|
|
116996
|
+
if (dialect.name === "mysql" && isJsonExpression2(leftExpression) && isJsonExpression2(rightExpression)) {
|
|
116152
116997
|
return `json_overlaps(${renderJsonInputExpression(leftExpression, state, dialect)}, ${renderJsonInputExpression(rightExpression, state, dialect)})`;
|
|
116153
116998
|
}
|
|
116154
116999
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -116225,14 +117070,15 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116225
117070
|
// src/internal/dialect-renderers/postgres.ts
|
|
116226
117071
|
import * as Schema11 from "effect/Schema";
|
|
116227
117072
|
var renderDbType2 = (dialect, dbType) => {
|
|
116228
|
-
|
|
116229
|
-
return "bytea";
|
|
116230
|
-
}
|
|
116231
|
-
return renderDbTypeName(dbType.kind);
|
|
117073
|
+
return renderDbTypeName(renderPortableDatatypeDdlType(dialect.name, dbType.kind) ?? dbType.kind);
|
|
116232
117074
|
};
|
|
116233
117075
|
var isArrayDbType2 = (dbType) => ("element" in dbType);
|
|
116234
117076
|
var renderCastType2 = (dialect, dbType) => {
|
|
116235
117077
|
const kind = dbType?.kind;
|
|
117078
|
+
const portableType = renderPortableDatatypeCastType(dialect.name, kind);
|
|
117079
|
+
if (portableType !== undefined) {
|
|
117080
|
+
return renderDbTypeName(portableType);
|
|
117081
|
+
}
|
|
116236
117082
|
if (dialect.name !== "mysql") {
|
|
116237
117083
|
return renderDbTypeName(kind);
|
|
116238
117084
|
}
|
|
@@ -116254,13 +117100,13 @@ var renderCastType2 = (dialect, dbType) => {
|
|
|
116254
117100
|
return renderDbTypeName(kind);
|
|
116255
117101
|
}
|
|
116256
117102
|
};
|
|
116257
|
-
var casingForTable2 = (table, state) => merge(state.casing, table[
|
|
117103
|
+
var casingForTable2 = (table, state) => merge(state.casing, table[TypeId7].casing);
|
|
116258
117104
|
var casedTableName = (table, state) => {
|
|
116259
|
-
const tableState = table[
|
|
117105
|
+
const tableState = table[TypeId7];
|
|
116260
117106
|
return applyCategory(casingForTable2(table, state), "tables", tableState.baseName);
|
|
116261
117107
|
};
|
|
116262
117108
|
var casedSchemaName = (table, state) => {
|
|
116263
|
-
const schemaName = table[
|
|
117109
|
+
const schemaName = table[TypeId7].schemaName;
|
|
116264
117110
|
return schemaName === undefined ? undefined : applyCategory(casingForTable2(table, state), "schemas", schemaName);
|
|
116265
117111
|
};
|
|
116266
117112
|
var casedColumnName2 = (columnName, state, tableName) => {
|
|
@@ -116274,7 +117120,7 @@ var casedColumnName2 = (columnName, state, tableName) => {
|
|
|
116274
117120
|
};
|
|
116275
117121
|
var casedTableReferenceName2 = (tableName, state) => state.sourceNames?.get(tableName)?.tableName ?? applyCategory(state.casing, "tables", tableName);
|
|
116276
117122
|
var quoteColumn2 = (columnName, state, dialect, tableName) => dialect.quoteIdentifier(casedColumnName2(columnName, state, tableName));
|
|
116277
|
-
var stateWithTableCasing2 = (state, source) => typeof source === "object" && source !== null && (
|
|
117123
|
+
var stateWithTableCasing2 = (state, source) => typeof source === "object" && source !== null && (TypeId7 in source) ? { ...state, casing: casingForTable2(source, state) } : state;
|
|
116278
117124
|
var referenceCasing2 = (reference, state) => merge(state.casing, reference.casing);
|
|
116279
117125
|
var renderReferenceTable2 = (reference, state, dialect) => {
|
|
116280
117126
|
const casing = referenceCasing2(reference, state);
|
|
@@ -116287,9 +117133,9 @@ var registerSourceReference2 = (source, tableName, state) => {
|
|
|
116287
117133
|
if (typeof source !== "object" || source === null) {
|
|
116288
117134
|
return;
|
|
116289
117135
|
}
|
|
116290
|
-
if (
|
|
117136
|
+
if (TypeId7 in source) {
|
|
116291
117137
|
const table = source;
|
|
116292
|
-
const tableState = table[
|
|
117138
|
+
const tableState = table[TypeId7];
|
|
116293
117139
|
const casing = casingForTable2(table, state);
|
|
116294
117140
|
const renderedTableName = tableState.kind === "alias" ? tableName : applyCategory(casing, "tables", tableState.baseName);
|
|
116295
117141
|
const columns = new Map(Object.keys(tableState.fields).map((columnName) => [
|
|
@@ -116403,11 +117249,11 @@ var renderCreateTableSql2 = (targetSource, state, dialect, ifNotExists) => {
|
|
|
116403
117249
|
}
|
|
116404
117250
|
const table = targetSource.source;
|
|
116405
117251
|
const tableCasing = casingForTable2(table, state);
|
|
116406
|
-
const fields2 = table[
|
|
117252
|
+
const fields2 = table[TypeId7].fields;
|
|
116407
117253
|
const definitions = Object.entries(fields2).map(([columnName, column]) => renderColumnDefinition2(dialect, state, columnName, column, targetSource.tableName, tableCasing));
|
|
116408
117254
|
const options2 = table[OptionsSymbol];
|
|
116409
117255
|
const tableOptions = Array.isArray(options2) ? options2 : [options2];
|
|
116410
|
-
validateOptions(table[
|
|
117256
|
+
validateOptions(table[TypeId7].name, fields2, tableOptions);
|
|
116411
117257
|
for (const option2 of tableOptions) {
|
|
116412
117258
|
if (typeof option2 !== "object" || option2 === null || !("kind" in option2)) {
|
|
116413
117259
|
continue;
|
|
@@ -116466,8 +117312,8 @@ var renderDropIndexSql2 = (targetSource, ddl, state, dialect) => {
|
|
|
116466
117312
|
throw new Error(`Unsupported ${dialect.name} drop index options`);
|
|
116467
117313
|
}
|
|
116468
117314
|
if (dialect.name === "postgres") {
|
|
116469
|
-
const table2 = typeof targetSource.source === "object" && targetSource.source !== null &&
|
|
116470
|
-
const schemaName = table2?.[
|
|
117315
|
+
const table2 = typeof targetSource.source === "object" && targetSource.source !== null && TypeId7 in targetSource.source ? targetSource.source : undefined;
|
|
117316
|
+
const schemaName = table2?.[TypeId7].schemaName;
|
|
116471
117317
|
const tableCasing2 = table2 === undefined ? state.casing : casingForTable2(table2, state);
|
|
116472
117318
|
const renderedSchemaName = table2 === undefined ? schemaName : casedSchemaName(table2, state);
|
|
116473
117319
|
const renderedIndexName = applyCategory(tableCasing2, "indexes", name);
|
|
@@ -116478,7 +117324,7 @@ var renderDropIndexSql2 = (targetSource, ddl, state, dialect) => {
|
|
|
116478
117324
|
const tableCasing = casingForTable2(table, state);
|
|
116479
117325
|
return `drop index ${dialect.quoteIdentifier(applyCategory(tableCasing, "indexes", name))} on ${renderSourceReference2(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)}`;
|
|
116480
117326
|
};
|
|
116481
|
-
var
|
|
117327
|
+
var isExpression5 = (value) => value !== null && typeof value === "object" && (TypeId in value);
|
|
116482
117328
|
var isJsonDbType3 = (dbType) => {
|
|
116483
117329
|
if (dbType.kind === "jsonb" || dbType.kind === "json") {
|
|
116484
117330
|
return true;
|
|
@@ -116489,7 +117335,7 @@ var isJsonDbType3 = (dbType) => {
|
|
|
116489
117335
|
const variant = dbType.variant;
|
|
116490
117336
|
return variant === "json" || variant === "jsonb";
|
|
116491
117337
|
};
|
|
116492
|
-
var
|
|
117338
|
+
var isJsonExpression3 = (value) => isExpression5(value) && isJsonDbType3(value[TypeId].dbType);
|
|
116493
117339
|
var expectValueExpression2 = (_functionName, value) => value;
|
|
116494
117340
|
var expectBinaryExpressions2 = (_functionName, left, right) => [left, right];
|
|
116495
117341
|
var renderBinaryExpression2 = (functionName, operator, left, right, state, dialect) => {
|
|
@@ -116536,7 +117382,7 @@ var unsupportedJsonFeature2 = (dialect, feature) => {
|
|
|
116536
117382
|
throw error;
|
|
116537
117383
|
};
|
|
116538
117384
|
var extractJsonBase2 = (node) => node.value ?? node.base ?? node.input ?? node.left ?? node.target;
|
|
116539
|
-
var isJsonPathValue3 = (value) => value !== null && typeof value === "object" && (
|
|
117385
|
+
var isJsonPathValue3 = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
116540
117386
|
var isOptionalJsonPathNumber2 = (value) => value === undefined || typeof value === "number" && Number.isFinite(value);
|
|
116541
117387
|
var isJsonPathSegment2 = (segment) => {
|
|
116542
117388
|
if (typeof segment === "string") {
|
|
@@ -116552,8 +117398,8 @@ var isJsonPathSegment2 = (segment) => {
|
|
|
116552
117398
|
case "key":
|
|
116553
117399
|
return typeof segment.key === "string";
|
|
116554
117400
|
case "index": {
|
|
116555
|
-
const
|
|
116556
|
-
return typeof
|
|
117401
|
+
const index4 = segment.index;
|
|
117402
|
+
return typeof index4 === "number" && Number.isFinite(index4);
|
|
116557
117403
|
}
|
|
116558
117404
|
case "wildcard":
|
|
116559
117405
|
case "descend":
|
|
@@ -116574,12 +117420,12 @@ var validateJsonPathSegments2 = (segments) => {
|
|
|
116574
117420
|
return segments;
|
|
116575
117421
|
};
|
|
116576
117422
|
var extractJsonPathSegments2 = (node) => {
|
|
116577
|
-
const
|
|
116578
|
-
if (isJsonPathValue3(
|
|
116579
|
-
return validateJsonPathSegments2(
|
|
117423
|
+
const path2 = node.path ?? node.segments ?? node.keys;
|
|
117424
|
+
if (isJsonPathValue3(path2)) {
|
|
117425
|
+
return validateJsonPathSegments2(path2.segments);
|
|
116580
117426
|
}
|
|
116581
|
-
if (Array.isArray(
|
|
116582
|
-
return validateJsonPathSegments2(
|
|
117427
|
+
if (Array.isArray(path2)) {
|
|
117428
|
+
return validateJsonPathSegments2(path2);
|
|
116583
117429
|
}
|
|
116584
117430
|
if (node.segments !== undefined) {
|
|
116585
117431
|
return validateJsonPathSegments2(node.segments);
|
|
@@ -116593,7 +117439,7 @@ var extractJsonPathSegments2 = (node) => {
|
|
|
116593
117439
|
return [key(segment)];
|
|
116594
117440
|
}
|
|
116595
117441
|
if (typeof segment === "number") {
|
|
116596
|
-
return [
|
|
117442
|
+
return [index(segment)];
|
|
116597
117443
|
}
|
|
116598
117444
|
if (segment !== null && typeof segment === "object" && SegmentTypeId in segment) {
|
|
116599
117445
|
return [segment];
|
|
@@ -116631,11 +117477,11 @@ var renderJsonPathSegment2 = (segment) => {
|
|
|
116631
117477
|
}
|
|
116632
117478
|
};
|
|
116633
117479
|
var renderJsonPathStringLiteral2 = (segments) => {
|
|
116634
|
-
let
|
|
117480
|
+
let path2 = "$";
|
|
116635
117481
|
for (const segment of segments) {
|
|
116636
|
-
|
|
117482
|
+
path2 += renderJsonPathSegment2(segment);
|
|
116637
117483
|
}
|
|
116638
|
-
return
|
|
117484
|
+
return path2;
|
|
116639
117485
|
};
|
|
116640
117486
|
var renderMySqlJsonPath2 = (segments, state, dialect) => dialect.renderLiteral(renderJsonPathStringLiteral2(segments), state);
|
|
116641
117487
|
var renderPostgresJsonPathArray2 = (segments, state, dialect) => `array[${segments.map((segment) => {
|
|
@@ -116666,7 +117512,7 @@ var renderPostgresJsonAccessStep2 = (segment, textMode, state, dialect) => {
|
|
|
116666
117512
|
}
|
|
116667
117513
|
};
|
|
116668
117514
|
var renderPostgresJsonValue2 = (value, state, dialect) => {
|
|
116669
|
-
if (!
|
|
117515
|
+
if (!isExpression5(value)) {
|
|
116670
117516
|
throw new Error("Expected a JSON expression");
|
|
116671
117517
|
}
|
|
116672
117518
|
const rendered = renderExpression2(value, state, dialect);
|
|
@@ -116710,7 +117556,7 @@ var renderJsonOpaquePath2 = (value, state, dialect) => {
|
|
|
116710
117556
|
}
|
|
116711
117557
|
return dialect.renderLiteral(value, state);
|
|
116712
117558
|
}
|
|
116713
|
-
if (
|
|
117559
|
+
if (isExpression5(value)) {
|
|
116714
117560
|
const ast = value[TypeId2];
|
|
116715
117561
|
if (ast.kind === "literal" && typeof ast.value === "string" && ast.value.trim().length === 0) {
|
|
116716
117562
|
throw new Error("SQL/JSON path input must be a non-empty string");
|
|
@@ -116760,8 +117606,8 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116760
117606
|
const base = extractJsonBase2(ast);
|
|
116761
117607
|
const segments = extractJsonPathSegments2(ast);
|
|
116762
117608
|
const exact = segments.every((segment) => segment.kind === "key" || segment.kind === "index");
|
|
116763
|
-
const postgresExpressionKind = dialect.name === "postgres" &&
|
|
116764
|
-
const postgresBaseKind = dialect.name === "postgres" &&
|
|
117609
|
+
const postgresExpressionKind = dialect.name === "postgres" && isJsonExpression3(expression) ? renderPostgresJsonKind2(expression) : undefined;
|
|
117610
|
+
const postgresBaseKind = dialect.name === "postgres" && isJsonExpression3(base) ? renderPostgresJsonKind2(base) : undefined;
|
|
116765
117611
|
switch (kind) {
|
|
116766
117612
|
case "jsonGet":
|
|
116767
117613
|
case "jsonPath":
|
|
@@ -116771,7 +117617,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116771
117617
|
case "jsonPathText":
|
|
116772
117618
|
case "jsonAccessText":
|
|
116773
117619
|
case "jsonTraverseText": {
|
|
116774
|
-
if (!
|
|
117620
|
+
if (!isExpression5(base) || segments.length === 0) {
|
|
116775
117621
|
return;
|
|
116776
117622
|
}
|
|
116777
117623
|
const baseSql = renderExpression2(base, state, dialect);
|
|
@@ -116794,24 +117640,24 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116794
117640
|
case "jsonKeyExists":
|
|
116795
117641
|
case "jsonHasAnyKeys":
|
|
116796
117642
|
case "jsonHasAllKeys": {
|
|
116797
|
-
if (!
|
|
117643
|
+
if (!isExpression5(base)) {
|
|
116798
117644
|
return;
|
|
116799
117645
|
}
|
|
116800
117646
|
const baseSql = dialect.name === "postgres" ? renderPostgresJsonValue2(base, state, dialect) : renderExpression2(base, state, dialect);
|
|
116801
|
-
const
|
|
116802
|
-
if (
|
|
117647
|
+
const keys = extractJsonKeys2(ast, segments);
|
|
117648
|
+
if (keys.length === 0) {
|
|
116803
117649
|
return;
|
|
116804
117650
|
}
|
|
116805
|
-
if (
|
|
117651
|
+
if (keys.some((key2) => typeof key2 !== "string" || key2.length === 0)) {
|
|
116806
117652
|
throw new Error("json key predicates require string keys");
|
|
116807
117653
|
}
|
|
116808
|
-
const keyNames =
|
|
117654
|
+
const keyNames = keys;
|
|
116809
117655
|
if (dialect.name === "postgres") {
|
|
116810
117656
|
if (kind === "jsonHasAnyKeys") {
|
|
116811
|
-
return `(${baseSql} ?| array[${keyNames.map((
|
|
117657
|
+
return `(${baseSql} ?| array[${keyNames.map((key2) => renderPostgresTextLiteral2(key2, state, dialect)).join(", ")}])`;
|
|
116812
117658
|
}
|
|
116813
117659
|
if (kind === "jsonHasAllKeys") {
|
|
116814
|
-
return `(${baseSql} ?& array[${keyNames.map((
|
|
117660
|
+
return `(${baseSql} ?& array[${keyNames.map((key2) => renderPostgresTextLiteral2(key2, state, dialect)).join(", ")}])`;
|
|
116815
117661
|
}
|
|
116816
117662
|
return `(${baseSql} ? ${renderPostgresTextLiteral2(keyNames[0], state, dialect)})`;
|
|
116817
117663
|
}
|
|
@@ -116824,7 +117670,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116824
117670
|
}
|
|
116825
117671
|
case "jsonConcat":
|
|
116826
117672
|
case "jsonMerge": {
|
|
116827
|
-
if (!
|
|
117673
|
+
if (!isExpression5(ast.left) || !isExpression5(ast.right)) {
|
|
116828
117674
|
return;
|
|
116829
117675
|
}
|
|
116830
117676
|
if (dialect.name === "postgres") {
|
|
@@ -116861,7 +117707,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116861
117707
|
return;
|
|
116862
117708
|
}
|
|
116863
117709
|
case "jsonToJson":
|
|
116864
|
-
if (!
|
|
117710
|
+
if (!isExpression5(base)) {
|
|
116865
117711
|
return;
|
|
116866
117712
|
}
|
|
116867
117713
|
if (dialect.name === "postgres") {
|
|
@@ -116872,7 +117718,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116872
117718
|
}
|
|
116873
117719
|
return;
|
|
116874
117720
|
case "jsonToJsonb":
|
|
116875
|
-
if (!
|
|
117721
|
+
if (!isExpression5(base)) {
|
|
116876
117722
|
return;
|
|
116877
117723
|
}
|
|
116878
117724
|
if (dialect.name === "postgres") {
|
|
@@ -116883,7 +117729,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116883
117729
|
}
|
|
116884
117730
|
return;
|
|
116885
117731
|
case "jsonTypeOf":
|
|
116886
|
-
if (!
|
|
117732
|
+
if (!isExpression5(base)) {
|
|
116887
117733
|
return;
|
|
116888
117734
|
}
|
|
116889
117735
|
if (dialect.name === "postgres") {
|
|
@@ -116895,7 +117741,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116895
117741
|
}
|
|
116896
117742
|
return;
|
|
116897
117743
|
case "jsonLength":
|
|
116898
|
-
if (!
|
|
117744
|
+
if (!isExpression5(base)) {
|
|
116899
117745
|
return;
|
|
116900
117746
|
}
|
|
116901
117747
|
if (dialect.name === "postgres") {
|
|
@@ -116910,7 +117756,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116910
117756
|
}
|
|
116911
117757
|
return;
|
|
116912
117758
|
case "jsonKeys":
|
|
116913
|
-
if (!
|
|
117759
|
+
if (!isExpression5(base)) {
|
|
116914
117760
|
return;
|
|
116915
117761
|
}
|
|
116916
117762
|
if (dialect.name === "postgres") {
|
|
@@ -116924,7 +117770,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116924
117770
|
}
|
|
116925
117771
|
return;
|
|
116926
117772
|
case "jsonStripNulls":
|
|
116927
|
-
if (!
|
|
117773
|
+
if (!isExpression5(base)) {
|
|
116928
117774
|
return;
|
|
116929
117775
|
}
|
|
116930
117776
|
if (dialect.name === "postgres") {
|
|
@@ -116935,7 +117781,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116935
117781
|
case "jsonDelete":
|
|
116936
117782
|
case "jsonDeletePath":
|
|
116937
117783
|
case "jsonRemove": {
|
|
116938
|
-
if (!
|
|
117784
|
+
if (!isExpression5(base) || segments.length === 0) {
|
|
116939
117785
|
return;
|
|
116940
117786
|
}
|
|
116941
117787
|
if (dialect.name === "postgres") {
|
|
@@ -116953,11 +117799,11 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116953
117799
|
}
|
|
116954
117800
|
case "jsonSet":
|
|
116955
117801
|
case "jsonInsert": {
|
|
116956
|
-
if (!
|
|
117802
|
+
if (!isExpression5(base) || segments.length === 0) {
|
|
116957
117803
|
return;
|
|
116958
117804
|
}
|
|
116959
117805
|
const nextValue = extractJsonValue2(ast);
|
|
116960
|
-
if (!
|
|
117806
|
+
if (!isExpression5(nextValue)) {
|
|
116961
117807
|
return;
|
|
116962
117808
|
}
|
|
116963
117809
|
const createMissing = ast.createMissing === true;
|
|
@@ -116974,39 +117820,39 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116974
117820
|
return;
|
|
116975
117821
|
}
|
|
116976
117822
|
case "jsonPathExists": {
|
|
116977
|
-
if (!
|
|
117823
|
+
if (!isExpression5(base)) {
|
|
116978
117824
|
return;
|
|
116979
117825
|
}
|
|
116980
|
-
const
|
|
116981
|
-
if (
|
|
117826
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
117827
|
+
if (path2 === undefined) {
|
|
116982
117828
|
return;
|
|
116983
117829
|
}
|
|
116984
117830
|
if (dialect.name === "postgres") {
|
|
116985
|
-
return `(${renderPostgresJsonValue2(base, state, dialect)} @? ${renderJsonOpaquePath2(
|
|
117831
|
+
return `(${renderPostgresJsonValue2(base, state, dialect)} @? ${renderJsonOpaquePath2(path2, state, dialect)})`;
|
|
116986
117832
|
}
|
|
116987
117833
|
if (dialect.name === "mysql") {
|
|
116988
|
-
return `json_contains_path(${renderExpression2(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath2(
|
|
117834
|
+
return `json_contains_path(${renderExpression2(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath2(path2, state, dialect)})`;
|
|
116989
117835
|
}
|
|
116990
117836
|
return;
|
|
116991
117837
|
}
|
|
116992
117838
|
case "jsonPathMatch": {
|
|
116993
|
-
if (!
|
|
117839
|
+
if (!isExpression5(base)) {
|
|
116994
117840
|
return;
|
|
116995
117841
|
}
|
|
116996
|
-
const
|
|
116997
|
-
if (
|
|
117842
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
117843
|
+
if (path2 === undefined) {
|
|
116998
117844
|
return;
|
|
116999
117845
|
}
|
|
117000
117846
|
if (dialect.name === "postgres") {
|
|
117001
|
-
return `(${renderPostgresJsonValue2(base, state, dialect)} @@ ${renderJsonOpaquePath2(
|
|
117847
|
+
return `(${renderPostgresJsonValue2(base, state, dialect)} @@ ${renderJsonOpaquePath2(path2, state, dialect)})`;
|
|
117002
117848
|
}
|
|
117003
117849
|
unsupportedJsonFeature2(dialect, "jsonPathMatch");
|
|
117004
117850
|
}
|
|
117005
117851
|
}
|
|
117006
117852
|
return;
|
|
117007
117853
|
};
|
|
117008
|
-
var selectionProjections2 = (selection) => flattenSelection(selection).map(({ path:
|
|
117009
|
-
path:
|
|
117854
|
+
var selectionProjections2 = (selection) => flattenSelection(selection).map(({ path: path2, alias: alias2 }) => ({
|
|
117855
|
+
path: path2,
|
|
117010
117856
|
alias: alias2
|
|
117011
117857
|
}));
|
|
117012
117858
|
var renderMutationAssignment2 = (entry, state, dialect, targetTableName) => {
|
|
@@ -117087,9 +117933,9 @@ var validateDistinctOnOrdering = (distinctOn2, orderBy2) => {
|
|
|
117087
117933
|
}
|
|
117088
117934
|
const remainingDistinctKeys = new Set(distinctOn2.map(groupingKeyOfExpression));
|
|
117089
117935
|
for (const order of orderBy2) {
|
|
117090
|
-
const
|
|
117091
|
-
if (remainingDistinctKeys.has(
|
|
117092
|
-
remainingDistinctKeys.delete(
|
|
117936
|
+
const key2 = groupingKeyOfExpression(order.value);
|
|
117937
|
+
if (remainingDistinctKeys.has(key2)) {
|
|
117938
|
+
remainingDistinctKeys.delete(key2);
|
|
117093
117939
|
continue;
|
|
117094
117940
|
}
|
|
117095
117941
|
if (remainingDistinctKeys.size > 0) {
|
|
@@ -117184,12 +118030,12 @@ var renderQueryAst2 = (ast, state, dialect, options2 = {}) => {
|
|
|
117184
118030
|
const columns = insertSource.columns.map((column) => quoteColumn2(column, state, dialect, targetSource.tableName)).join(", ");
|
|
117185
118031
|
if (dialect.name === "postgres") {
|
|
117186
118032
|
const table = targetSource.source;
|
|
117187
|
-
const fields2 = table[
|
|
118033
|
+
const fields2 = table[TypeId7].fields;
|
|
117188
118034
|
const rendered = insertSource.values.map((entry) => `cast(${dialect.renderLiteral(encodeArrayValues2(entry.values, fields2[entry.columnName], state, dialect), state)} as ${renderCastType2(dialect, fields2[entry.columnName].metadata.dbType)}[])`).join(", ");
|
|
117189
118035
|
sql += ` (${columns}) select * from unnest(${rendered})`;
|
|
117190
118036
|
} else {
|
|
117191
118037
|
const rowCount = insertSource.values[0]?.values.length ?? 0;
|
|
117192
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
118038
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => `(${insertSource.values.map((entry) => dialect.renderLiteral(entry.values[index4], state, targetSource.source[TypeId7].fields[entry.columnName][TypeId])).join(", ")})`).join(", ");
|
|
117193
118039
|
sql += ` (${columns}) values ${rows}`;
|
|
117194
118040
|
}
|
|
117195
118041
|
} else {
|
|
@@ -117343,27 +118189,27 @@ var renderQueryAst2 = (ast, state, dialect, options2 = {}) => {
|
|
|
117343
118189
|
const mergeAst = ast;
|
|
117344
118190
|
const targetSource = mergeAst.target;
|
|
117345
118191
|
const usingSource = mergeAst.using;
|
|
117346
|
-
const
|
|
117347
|
-
sql = `merge into ${renderSourceReference2(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)} using ${renderSourceReference2(usingSource.source, usingSource.tableName, usingSource.baseTableName, state, dialect)} on ${renderExpression2(
|
|
117348
|
-
if (
|
|
117349
|
-
const matchedKind =
|
|
118192
|
+
const merge2 = mergeAst.merge;
|
|
118193
|
+
sql = `merge into ${renderSourceReference2(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)} using ${renderSourceReference2(usingSource.source, usingSource.tableName, usingSource.baseTableName, state, dialect)} on ${renderExpression2(merge2.on, state, dialect)}`;
|
|
118194
|
+
if (merge2.whenMatched) {
|
|
118195
|
+
const matchedKind = merge2.whenMatched.kind === "delete" ? "delete" : "update";
|
|
117350
118196
|
sql += " when matched";
|
|
117351
|
-
if (
|
|
117352
|
-
sql += ` and ${renderExpression2(
|
|
118197
|
+
if (merge2.whenMatched.predicate) {
|
|
118198
|
+
sql += ` and ${renderExpression2(merge2.whenMatched.predicate, state, dialect)}`;
|
|
117353
118199
|
}
|
|
117354
118200
|
if (matchedKind === "delete") {
|
|
117355
118201
|
sql += " then delete";
|
|
117356
118202
|
} else {
|
|
117357
|
-
const matchedUpdate =
|
|
118203
|
+
const matchedUpdate = merge2.whenMatched;
|
|
117358
118204
|
sql += ` then update set ${matchedUpdate.values.map((entry) => `${quoteColumn2(entry.columnName, state, dialect, targetSource.tableName)} = ${renderExpression2(entry.value, state, dialect)}`).join(", ")}`;
|
|
117359
118205
|
}
|
|
117360
118206
|
}
|
|
117361
|
-
if (
|
|
118207
|
+
if (merge2.whenNotMatched) {
|
|
117362
118208
|
sql += " when not matched";
|
|
117363
|
-
if (
|
|
117364
|
-
sql += ` and ${renderExpression2(
|
|
118209
|
+
if (merge2.whenNotMatched.predicate) {
|
|
118210
|
+
sql += ` and ${renderExpression2(merge2.whenNotMatched.predicate, state, dialect)}`;
|
|
117365
118211
|
}
|
|
117366
|
-
sql += ` then insert (${
|
|
118212
|
+
sql += ` then insert (${merge2.whenNotMatched.values.map((entry) => quoteColumn2(entry.columnName, state, dialect, targetSource.tableName)).join(", ")}) values (${merge2.whenNotMatched.values.map((entry) => renderExpression2(entry.value, state, dialect)).join(", ")})`;
|
|
117367
118213
|
}
|
|
117368
118214
|
break;
|
|
117369
118215
|
}
|
|
@@ -117427,7 +118273,7 @@ var renderSourceReference2 = (source, tableName, baseTableName, state, dialect)
|
|
|
117427
118273
|
};
|
|
117428
118274
|
const renderUnnestRows = (arrays, columnNames) => {
|
|
117429
118275
|
const rowCount = arrays[columnNames[0]].length;
|
|
117430
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
118276
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => Object.fromEntries(columnNames.map((columnName) => [columnName, arrays[columnName][index4]])));
|
|
117431
118277
|
return renderSelectRows(rows, columnNames);
|
|
117432
118278
|
};
|
|
117433
118279
|
if (typeof source === "object" && source !== null && "kind" in source && source.kind === "cte") {
|
|
@@ -117477,11 +118323,11 @@ var renderSourceReference2 = (source, tableName, baseTableName, state, dialect)
|
|
|
117477
118323
|
const columnNames = Object.keys(tableFunction.columns);
|
|
117478
118324
|
return `${functionName}(${tableFunction.args.map((arg) => renderExpression2(arg, state, dialect)).join(", ")}) as ${dialect.quoteIdentifier(tableFunction.name)}(${columnNames.map((columnName) => dialect.quoteIdentifier(columnName)).join(", ")})`;
|
|
117479
118325
|
}
|
|
117480
|
-
const schemaName = typeof source === "object" && source !== null &&
|
|
117481
|
-
if (typeof source === "object" && source !== null &&
|
|
118326
|
+
const schemaName = typeof source === "object" && source !== null && TypeId7 in source ? casedSchemaName(source, state) : undefined;
|
|
118327
|
+
if (typeof source === "object" && source !== null && TypeId7 in source) {
|
|
117482
118328
|
const table = source;
|
|
117483
118329
|
const renderedBaseName = casedTableName(table, state);
|
|
117484
|
-
const renderedTableName = table[
|
|
118330
|
+
const renderedTableName = table[TypeId7].kind === "alias" ? tableName : renderedBaseName;
|
|
117485
118331
|
return dialect.renderTableReference(renderedTableName, renderedBaseName, schemaName);
|
|
117486
118332
|
}
|
|
117487
118333
|
return dialect.renderTableReference(applyCategory(state.casing, "tables", tableName), applyCategory(state.casing, "tables", baseTableName), schemaName);
|
|
@@ -117588,11 +118434,11 @@ var renderExpression2 = (expression, state, dialect) => {
|
|
|
117588
118434
|
const [leftExpression, rightExpression] = expectBinaryExpressions2("contains", ast.left, ast.right);
|
|
117589
118435
|
if (dialect.name === "postgres") {
|
|
117590
118436
|
assertCompatiblePostgresRangeOperands(leftExpression, rightExpression);
|
|
117591
|
-
const left =
|
|
117592
|
-
const right =
|
|
118437
|
+
const left = isJsonExpression3(leftExpression) ? renderPostgresJsonValue2(leftExpression, state, dialect) : renderExpression2(leftExpression, state, dialect);
|
|
118438
|
+
const right = isJsonExpression3(rightExpression) ? renderPostgresJsonValue2(rightExpression, state, dialect) : renderExpression2(rightExpression, state, dialect);
|
|
117593
118439
|
return `(${left} @> ${right})`;
|
|
117594
118440
|
}
|
|
117595
|
-
if (dialect.name === "mysql" &&
|
|
118441
|
+
if (dialect.name === "mysql" && isJsonExpression3(leftExpression) && isJsonExpression3(rightExpression)) {
|
|
117596
118442
|
return `json_contains(${renderExpression2(leftExpression, state, dialect)}, ${renderExpression2(rightExpression, state, dialect)})`;
|
|
117597
118443
|
}
|
|
117598
118444
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -117601,11 +118447,11 @@ var renderExpression2 = (expression, state, dialect) => {
|
|
|
117601
118447
|
const [leftExpression, rightExpression] = expectBinaryExpressions2("containedBy", ast.left, ast.right);
|
|
117602
118448
|
if (dialect.name === "postgres") {
|
|
117603
118449
|
assertCompatiblePostgresRangeOperands(leftExpression, rightExpression);
|
|
117604
|
-
const left =
|
|
117605
|
-
const right =
|
|
118450
|
+
const left = isJsonExpression3(leftExpression) ? renderPostgresJsonValue2(leftExpression, state, dialect) : renderExpression2(leftExpression, state, dialect);
|
|
118451
|
+
const right = isJsonExpression3(rightExpression) ? renderPostgresJsonValue2(rightExpression, state, dialect) : renderExpression2(rightExpression, state, dialect);
|
|
117606
118452
|
return `(${left} <@ ${right})`;
|
|
117607
118453
|
}
|
|
117608
|
-
if (dialect.name === "mysql" &&
|
|
118454
|
+
if (dialect.name === "mysql" && isJsonExpression3(leftExpression) && isJsonExpression3(rightExpression)) {
|
|
117609
118455
|
return `json_contains(${renderExpression2(rightExpression, state, dialect)}, ${renderExpression2(leftExpression, state, dialect)})`;
|
|
117610
118456
|
}
|
|
117611
118457
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -117614,11 +118460,11 @@ var renderExpression2 = (expression, state, dialect) => {
|
|
|
117614
118460
|
const [leftExpression, rightExpression] = expectBinaryExpressions2("overlaps", ast.left, ast.right);
|
|
117615
118461
|
if (dialect.name === "postgres") {
|
|
117616
118462
|
assertCompatiblePostgresRangeOperands(leftExpression, rightExpression);
|
|
117617
|
-
const left =
|
|
117618
|
-
const right =
|
|
118463
|
+
const left = isJsonExpression3(leftExpression) ? renderPostgresJsonValue2(leftExpression, state, dialect) : renderExpression2(leftExpression, state, dialect);
|
|
118464
|
+
const right = isJsonExpression3(rightExpression) ? renderPostgresJsonValue2(rightExpression, state, dialect) : renderExpression2(rightExpression, state, dialect);
|
|
117619
118465
|
return `(${left} && ${right})`;
|
|
117620
118466
|
}
|
|
117621
|
-
if (dialect.name === "mysql" &&
|
|
118467
|
+
if (dialect.name === "mysql" && isJsonExpression3(leftExpression) && isJsonExpression3(rightExpression)) {
|
|
117622
118468
|
return `json_overlaps(${renderExpression2(leftExpression, state, dialect)}, ${renderExpression2(rightExpression, state, dialect)})`;
|
|
117623
118469
|
}
|
|
117624
118470
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -117799,7 +118645,6 @@ var renderMysqlPlan = (plan, options2 = {}) => {
|
|
|
117799
118645
|
|
|
117800
118646
|
// src/mysql/executor.ts
|
|
117801
118647
|
var withTransaction2 = withTransaction;
|
|
117802
|
-
var withSavepoint2 = withSavepoint;
|
|
117803
118648
|
function driver2(executeOrHandlers) {
|
|
117804
118649
|
return driver("mysql", executeOrHandlers);
|
|
117805
118650
|
}
|
|
@@ -117820,8 +118665,8 @@ var fromDriver2 = (renderer, sqlDriver, driverMode = "raw", valueMappings) => ({
|
|
|
117820
118665
|
},
|
|
117821
118666
|
stream(plan) {
|
|
117822
118667
|
const rendered = renderer.render(plan);
|
|
117823
|
-
return Stream2.mapError(Stream2.
|
|
117824
|
-
try: () =>
|
|
118668
|
+
return Stream2.mapError(Stream2.mapArrayEffect(sqlDriver.stream(rendered), (rows) => Effect2.try({
|
|
118669
|
+
try: () => decodeRows(rendered, plan, rows, { driverMode, valueMappings }),
|
|
117825
118670
|
catch: (error) => error
|
|
117826
118671
|
})), (error) => {
|
|
117827
118672
|
if (typeof error === "object" && error !== null && "_tag" in error && error._tag === "RowDecodeError") {
|
|
@@ -117857,6 +118702,32 @@ __export(exports_query_extension, {
|
|
|
117857
118702
|
var ignore = lock("ignore");
|
|
117858
118703
|
var quick = lock("quick");
|
|
117859
118704
|
var lowPriority = lock("lowPriority");
|
|
118705
|
+
// src/mysql/type.ts
|
|
118706
|
+
var enum_2 = (kind) => ({
|
|
118707
|
+
dialect: "mysql",
|
|
118708
|
+
kind,
|
|
118709
|
+
variant: "enum"
|
|
118710
|
+
});
|
|
118711
|
+
var set2 = (kind) => ({
|
|
118712
|
+
dialect: "mysql",
|
|
118713
|
+
kind,
|
|
118714
|
+
variant: "set"
|
|
118715
|
+
});
|
|
118716
|
+
var custom4 = (kind) => ({
|
|
118717
|
+
dialect: "mysql",
|
|
118718
|
+
kind
|
|
118719
|
+
});
|
|
118720
|
+
var driverValueMapping3 = (dbType, mapping) => ({
|
|
118721
|
+
...dbType,
|
|
118722
|
+
driverValueMapping: mapping
|
|
118723
|
+
});
|
|
118724
|
+
var type2 = {
|
|
118725
|
+
...pickDatatypeConstructors(mysqlDatatypes, mysqlSpecificDatatypeKeys),
|
|
118726
|
+
enum: enum_2,
|
|
118727
|
+
set: set2,
|
|
118728
|
+
custom: custom4,
|
|
118729
|
+
driverValueMapping: driverValueMapping3
|
|
118730
|
+
};
|
|
117860
118731
|
// src/mysql/renderer.ts
|
|
117861
118732
|
var exports_renderer2 = {};
|
|
117862
118733
|
__export(exports_renderer2, {
|
|
@@ -117864,26 +118735,28 @@ __export(exports_renderer2, {
|
|
|
117864
118735
|
make: () => make5,
|
|
117865
118736
|
TypeId: () => TypeId10
|
|
117866
118737
|
});
|
|
117867
|
-
import { pipeArguments as
|
|
118738
|
+
import { pipeArguments as pipeArguments8 } from "effect/Pipeable";
|
|
117868
118739
|
var RendererProto = {
|
|
117869
118740
|
pipe() {
|
|
117870
|
-
return
|
|
118741
|
+
return pipeArguments8(this, arguments);
|
|
117871
118742
|
}
|
|
117872
118743
|
};
|
|
117873
|
-
var
|
|
117874
|
-
const renderer = makeTrusted("mysql", (plan) => renderMysqlPlan(plan,
|
|
118744
|
+
var makeWithState = (state = {}) => {
|
|
118745
|
+
const renderer = makeTrusted("mysql", (plan) => renderMysqlPlan(plan, state));
|
|
117875
118746
|
return Object.assign(Object.create(RendererProto), renderer, {
|
|
117876
|
-
[
|
|
117877
|
-
casing:
|
|
118747
|
+
[TypeId6]: {
|
|
118748
|
+
casing: state.casing
|
|
117878
118749
|
},
|
|
117879
|
-
withCasing: (override) =>
|
|
117880
|
-
...
|
|
117881
|
-
casing: merge(
|
|
118750
|
+
withCasing: (override) => makeWithState({
|
|
118751
|
+
...state,
|
|
118752
|
+
casing: merge(state.casing, override)
|
|
117882
118753
|
})
|
|
117883
118754
|
});
|
|
117884
118755
|
};
|
|
118756
|
+
var make5 = (options2 = {}) => makeWithState({ valueMappings: options2.valueMappings });
|
|
117885
118757
|
var mysql = make5();
|
|
117886
118758
|
export {
|
|
118759
|
+
type2 as Type,
|
|
117887
118760
|
exports_renderer2 as Renderer,
|
|
117888
118761
|
exports_query_extension as Query,
|
|
117889
118762
|
exports_json as Json,
|