effect-qb 0.19.0 → 4.0.0-beta.92
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 +1987 -679
- package/dist/mysql.js +1486 -616
- package/dist/postgres/metadata.js +1334 -263
- package/dist/postgres.js +3374 -2308
- package/dist/sqlite.js +1569 -627
- package/dist/standard.js +1982 -674
- package/package.json +2 -4
- 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 +118 -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/executor.ts +4 -6
- package/src/mysql/function/temporal.ts +1 -1
- package/src/mysql/internal/dsl.ts +113 -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/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 +119 -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/executor.ts +4 -6
- package/src/sqlite/function/temporal.ts +1 -1
- package/src/sqlite/internal/dsl.ts +97 -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 = () => ({
|
|
@@ -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,7 +113918,7 @@ 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) => {
|
|
@@ -113055,7 +113927,7 @@ var literalSchemaOf = (value) => {
|
|
|
113055
113927
|
}
|
|
113056
113928
|
return Schema6.Literal(value);
|
|
113057
113929
|
};
|
|
113058
|
-
var literal = (value) =>
|
|
113930
|
+
var literal = (value) => makeExpression2({
|
|
113059
113931
|
runtime: undefined,
|
|
113060
113932
|
dbType: value === null ? profile.nullDb : value instanceof Date ? profile.timestampDb : typeof value === "string" ? profile.textDb : typeof value === "number" ? profile.numericDb : profile.boolDb,
|
|
113061
113933
|
runtimeSchema: literalSchemaOf(value),
|
|
@@ -113079,7 +113951,7 @@ var retargetLiteralExpression = (value, target) => {
|
|
|
113079
113951
|
return value;
|
|
113080
113952
|
}
|
|
113081
113953
|
const targetState = target[TypeId];
|
|
113082
|
-
return
|
|
113954
|
+
return makeExpression2({
|
|
113083
113955
|
runtime: value[TypeId].runtime,
|
|
113084
113956
|
dbType: targetState.dbType,
|
|
113085
113957
|
runtimeSchema: targetState.runtimeSchema,
|
|
@@ -113113,7 +113985,7 @@ var extractRequiredFromDialectNumericInputRuntime = (value) => {
|
|
|
113113
113985
|
};
|
|
113114
113986
|
var buildBinaryPredicate = (left, right, kind, nullability = "maybe") => {
|
|
113115
113987
|
const [leftExpression, rightExpression] = alignBinaryPredicateExpressions(toDialectExpression(left), toDialectExpression(right));
|
|
113116
|
-
return
|
|
113988
|
+
return makeExpression2({
|
|
113117
113989
|
runtime: true,
|
|
113118
113990
|
dbType: profile.boolDb,
|
|
113119
113991
|
nullability,
|
|
@@ -113193,11 +114065,11 @@ var isJsonExpressionValue = (value) => isExpressionValue(value) && (() => {
|
|
|
113193
114065
|
const dbType = value[TypeId].dbType;
|
|
113194
114066
|
return dbType.variant === "json" || dbType.kind === "json" || dbType.kind === "jsonb";
|
|
113195
114067
|
})();
|
|
113196
|
-
var isJsonPathValue = (value) => value !== null && typeof value === "object" && (
|
|
114068
|
+
var isJsonPathValue = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
113197
114069
|
var normalizeJsonPathInput = (value) => isJsonPathValue(value) ? value.segments : [value];
|
|
113198
114070
|
var isExactJsonSegmentValue = (segment) => segment.kind === "key" || segment.kind === "index";
|
|
113199
114071
|
var isExactJsonPathValue = (segments) => segments.every(isExactJsonSegmentValue);
|
|
113200
|
-
var buildJsonNodeExpression = (expressions, state, ast) =>
|
|
114072
|
+
var buildJsonNodeExpression = (expressions, state, ast) => makeExpression2({
|
|
113201
114073
|
runtime: state.runtime,
|
|
113202
114074
|
dbType: state.dbType,
|
|
113203
114075
|
nullability: state.nullability,
|
|
@@ -113207,7 +114079,7 @@ var buildJsonNodeExpression = (expressions, state, ast) => makeExpression({
|
|
|
113207
114079
|
}, ast);
|
|
113208
114080
|
var jsonDbTypeOf = (base) => base[TypeId].dbType;
|
|
113209
114081
|
var resolveJsonMergeDbType = (...values) => values.some((value) => value[TypeId].dbType.kind === "jsonb") ? jsonbDb : jsonDb;
|
|
113210
|
-
var makeJsonLiteralExpression = (value, dbType = jsonDb) =>
|
|
114082
|
+
var makeJsonLiteralExpression = (value, dbType = jsonDb) => makeExpression2({
|
|
113211
114083
|
runtime: value,
|
|
113212
114084
|
dbType,
|
|
113213
114085
|
nullability: value === null ? "always" : "never",
|
|
@@ -113542,7 +114414,7 @@ var jsonPathMatch = (base, query) => {
|
|
|
113542
114414
|
};
|
|
113543
114415
|
var json = {
|
|
113544
114416
|
key,
|
|
113545
|
-
index
|
|
114417
|
+
index,
|
|
113546
114418
|
wildcard,
|
|
113547
114419
|
slice,
|
|
113548
114420
|
descend,
|
|
@@ -113578,7 +114450,7 @@ var json = {
|
|
|
113578
114450
|
};
|
|
113579
114451
|
var jsonb = {
|
|
113580
114452
|
key,
|
|
113581
|
-
index
|
|
114453
|
+
index,
|
|
113582
114454
|
wildcard,
|
|
113583
114455
|
slice,
|
|
113584
114456
|
descend,
|
|
@@ -113629,7 +114501,7 @@ var toMutationValueExpression = (value, column) => {
|
|
|
113629
114501
|
const ast = expression[TypeId2];
|
|
113630
114502
|
if (ast.kind === "literal") {
|
|
113631
114503
|
const normalizedValue2 = normalizeMutationValue(ast.value);
|
|
113632
|
-
return
|
|
114504
|
+
return makeExpression2({
|
|
113633
114505
|
runtime: normalizedValue2,
|
|
113634
114506
|
dbType: columnState.dbType,
|
|
113635
114507
|
runtimeSchema: columnState.runtimeSchema,
|
|
@@ -113646,7 +114518,7 @@ var toMutationValueExpression = (value, column) => {
|
|
|
113646
114518
|
return retargetLiteralExpression(value, column);
|
|
113647
114519
|
}
|
|
113648
114520
|
const normalizedValue = normalizeMutationValue(value);
|
|
113649
|
-
return
|
|
114521
|
+
return makeExpression2({
|
|
113650
114522
|
runtime: normalizedValue,
|
|
113651
114523
|
dbType: columnState.dbType,
|
|
113652
114524
|
runtimeSchema: columnState.runtimeSchema,
|
|
@@ -113661,15 +114533,15 @@ var toMutationValueExpression = (value, column) => {
|
|
|
113661
114533
|
});
|
|
113662
114534
|
};
|
|
113663
114535
|
var targetSourceDetails = (table) => {
|
|
113664
|
-
const sourceName = table[
|
|
113665
|
-
const sourceBaseName = table[
|
|
114536
|
+
const sourceName = table[TypeId7].name;
|
|
114537
|
+
const sourceBaseName = table[TypeId7].baseName;
|
|
113666
114538
|
return {
|
|
113667
114539
|
sourceName,
|
|
113668
114540
|
sourceBaseName
|
|
113669
114541
|
};
|
|
113670
114542
|
};
|
|
113671
114543
|
var sourceDetails = (source) => {
|
|
113672
|
-
if (
|
|
114544
|
+
if (TypeId7 in source) {
|
|
113673
114545
|
return targetSourceDetails(source);
|
|
113674
114546
|
}
|
|
113675
114547
|
const record2 = source;
|
|
@@ -113682,7 +114554,7 @@ var makeColumnReferenceSelection = (alias2, selection) => {
|
|
|
113682
114554
|
const columns = {};
|
|
113683
114555
|
for (const [columnName, expression] of Object.entries(selection)) {
|
|
113684
114556
|
const state = expression[TypeId];
|
|
113685
|
-
columns[columnName] =
|
|
114557
|
+
columns[columnName] = makeExpression2({
|
|
113686
114558
|
runtime: undefined,
|
|
113687
114559
|
dbType: state.dbType,
|
|
113688
114560
|
runtimeSchema: state.runtimeSchema,
|
|
@@ -113736,7 +114608,7 @@ var buildMutationAssignments = (target, values) => {
|
|
|
113736
114608
|
}
|
|
113737
114609
|
const valueMap = values;
|
|
113738
114610
|
return targets.flatMap((table) => {
|
|
113739
|
-
const targetName = table[
|
|
114611
|
+
const targetName = table[TypeId7].name;
|
|
113740
114612
|
const scopedValues = valueMap[targetName] ?? {};
|
|
113741
114613
|
const columns = table;
|
|
113742
114614
|
return Object.entries(scopedValues).map(([columnName, value]) => ({
|
|
@@ -113902,59 +114774,28 @@ var {
|
|
|
113902
114774
|
normalizeColumnList,
|
|
113903
114775
|
defaultIndexName
|
|
113904
114776
|
});
|
|
114777
|
+
|
|
113905
114778
|
// 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
114779
|
var typeOf = json.typeOf;
|
|
113935
114780
|
var length = json.length;
|
|
113936
|
-
var keys = json.keys;
|
|
113937
114781
|
var stripNulls = json.stripNulls;
|
|
113938
|
-
var pathExists = json.pathExists;
|
|
113939
114782
|
var pathMatch = json.pathMatch;
|
|
113940
114783
|
// src/mysql/executor.ts
|
|
113941
114784
|
var exports_executor2 = {};
|
|
113942
114785
|
__export(exports_executor2, {
|
|
113943
114786
|
withTransaction: () => withTransaction2,
|
|
113944
|
-
withSavepoint: () => withSavepoint2,
|
|
113945
114787
|
make: () => make4,
|
|
113946
114788
|
driver: () => driver2,
|
|
113947
114789
|
custom: () => custom3
|
|
113948
114790
|
});
|
|
113949
114791
|
import * as Effect2 from "effect/Effect";
|
|
113950
|
-
import * as SqlClient3 from "
|
|
114792
|
+
import * as SqlClient3 from "effect/unstable/sql/SqlClient";
|
|
113951
114793
|
import * as Stream2 from "effect/Stream";
|
|
113952
114794
|
|
|
113953
114795
|
// src/internal/executor.ts
|
|
113954
114796
|
var exports_executor = {};
|
|
113955
114797
|
__export(exports_executor, {
|
|
113956
114798
|
withTransaction: () => withTransaction,
|
|
113957
|
-
withSavepoint: () => withSavepoint,
|
|
113958
114799
|
streamFromSqlClient: () => streamFromSqlClient,
|
|
113959
114800
|
remapRows: () => remapRows,
|
|
113960
114801
|
makeRowDecoder: () => makeRowDecoder,
|
|
@@ -113968,9 +114809,10 @@ __export(exports_executor, {
|
|
|
113968
114809
|
});
|
|
113969
114810
|
import * as Chunk from "effect/Chunk";
|
|
113970
114811
|
import * as Effect from "effect/Effect";
|
|
114812
|
+
import * as Exit from "effect/Exit";
|
|
113971
114813
|
import * as Option from "effect/Option";
|
|
113972
114814
|
import * as Schema9 from "effect/Schema";
|
|
113973
|
-
import * as SqlClient from "
|
|
114815
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
113974
114816
|
import * as Stream from "effect/Stream";
|
|
113975
114817
|
|
|
113976
114818
|
// src/internal/runtime/driver-value-mapping.ts
|
|
@@ -114017,9 +114859,9 @@ var mappingCandidates = (context) => {
|
|
|
114017
114859
|
runtimeTag === undefined ? undefined : context.valueMappings?.[runtimeTag]
|
|
114018
114860
|
];
|
|
114019
114861
|
};
|
|
114020
|
-
var findMapping = (context,
|
|
114862
|
+
var findMapping = (context, key2) => {
|
|
114021
114863
|
for (const candidate of mappingCandidates(context)) {
|
|
114022
|
-
const value = candidate?.[
|
|
114864
|
+
const value = candidate?.[key2];
|
|
114023
114865
|
if (value !== undefined) {
|
|
114024
114866
|
return value;
|
|
114025
114867
|
}
|
|
@@ -114147,7 +114989,7 @@ var renderJsonSelectSql = (sql, context) => {
|
|
|
114147
114989
|
import * as Schema8 from "effect/Schema";
|
|
114148
114990
|
import * as SchemaAST from "effect/SchemaAST";
|
|
114149
114991
|
var schemaCache = new WeakMap;
|
|
114150
|
-
var FiniteNumberSchema = Schema8.Number.
|
|
114992
|
+
var FiniteNumberSchema = Schema8.Number.check(Schema8.isFinite());
|
|
114151
114993
|
var runtimeSchemaForTag = (tag) => {
|
|
114152
114994
|
switch (tag) {
|
|
114153
114995
|
case "string":
|
|
@@ -114175,14 +115017,11 @@ var runtimeSchemaForTag = (tag) => {
|
|
|
114175
115017
|
case "decimalString":
|
|
114176
115018
|
return DecimalStringSchema;
|
|
114177
115019
|
case "bytes":
|
|
114178
|
-
return Schema8.
|
|
115020
|
+
return Schema8.Uint8Array;
|
|
114179
115021
|
case "array":
|
|
114180
115022
|
return Schema8.Array(Schema8.Unknown);
|
|
114181
115023
|
case "record":
|
|
114182
|
-
return Schema8.Record(
|
|
114183
|
-
key: Schema8.String,
|
|
114184
|
-
value: Schema8.Unknown
|
|
114185
|
-
});
|
|
115024
|
+
return Schema8.Record(Schema8.String, Schema8.Unknown);
|
|
114186
115025
|
case "null":
|
|
114187
115026
|
return Schema8.Null;
|
|
114188
115027
|
case "unknown":
|
|
@@ -114200,7 +115039,7 @@ var runtimeSchemaForDbType = (dbType) => {
|
|
|
114200
115039
|
return Schema8.Array(runtimeSchemaForDbType(dbType.element) ?? Schema8.Unknown);
|
|
114201
115040
|
}
|
|
114202
115041
|
if ("fields" in dbType) {
|
|
114203
|
-
const fields2 = Object.fromEntries(Object.entries(dbType.fields).map(([
|
|
115042
|
+
const fields2 = Object.fromEntries(Object.entries(dbType.fields).map(([key2, field]) => [key2, runtimeSchemaForDbType(field) ?? Schema8.Unknown]));
|
|
114204
115043
|
return Schema8.Struct(fields2);
|
|
114205
115044
|
}
|
|
114206
115045
|
if ("variant" in dbType && dbType.variant === "json") {
|
|
@@ -114220,27 +115059,23 @@ var unionAst = (asts) => {
|
|
|
114220
115059
|
if (asts.length === 1) {
|
|
114221
115060
|
return asts[0];
|
|
114222
115061
|
}
|
|
114223
|
-
return SchemaAST.Union
|
|
115062
|
+
return new SchemaAST.Union(asts, "anyOf");
|
|
114224
115063
|
};
|
|
114225
|
-
var propertyAstOf = (ast,
|
|
115064
|
+
var propertyAstOf = (ast, key2) => {
|
|
114226
115065
|
switch (ast._tag) {
|
|
114227
|
-
case "Transformation":
|
|
114228
|
-
return propertyAstOf(SchemaAST.typeAST(ast), key3);
|
|
114229
|
-
case "Refinement":
|
|
114230
|
-
return propertyAstOf(ast.from, key3);
|
|
114231
115066
|
case "Suspend":
|
|
114232
|
-
return propertyAstOf(ast.
|
|
114233
|
-
case "
|
|
114234
|
-
const property = ast.propertySignatures.find((entry) => entry.name ===
|
|
115067
|
+
return propertyAstOf(ast.thunk(), key2);
|
|
115068
|
+
case "Objects": {
|
|
115069
|
+
const property = ast.propertySignatures.find((entry) => entry.name === key2);
|
|
114235
115070
|
if (property !== undefined) {
|
|
114236
115071
|
return property.type;
|
|
114237
115072
|
}
|
|
114238
|
-
const
|
|
114239
|
-
return
|
|
115073
|
+
const index4 = ast.indexSignatures.find((entry) => entry.parameter._tag === "String");
|
|
115074
|
+
return index4?.type;
|
|
114240
115075
|
}
|
|
114241
115076
|
case "Union": {
|
|
114242
115077
|
const values2 = ast.types.flatMap((member) => {
|
|
114243
|
-
const next = propertyAstOf(member,
|
|
115078
|
+
const next = propertyAstOf(member, key2);
|
|
114244
115079
|
return next === undefined ? [] : [next];
|
|
114245
115080
|
});
|
|
114246
115081
|
return unionAst(values2);
|
|
@@ -114249,27 +115084,23 @@ var propertyAstOf = (ast, key3) => {
|
|
|
114249
115084
|
return;
|
|
114250
115085
|
}
|
|
114251
115086
|
};
|
|
114252
|
-
var numberAstOf = (ast,
|
|
115087
|
+
var numberAstOf = (ast, index4) => {
|
|
114253
115088
|
switch (ast._tag) {
|
|
114254
|
-
case "Transformation":
|
|
114255
|
-
return numberAstOf(SchemaAST.typeAST(ast), index5);
|
|
114256
|
-
case "Refinement":
|
|
114257
|
-
return numberAstOf(ast.from, index5);
|
|
114258
115089
|
case "Suspend":
|
|
114259
|
-
return numberAstOf(ast.
|
|
114260
|
-
case "
|
|
114261
|
-
const element = ast.elements[
|
|
115090
|
+
return numberAstOf(ast.thunk(), index4);
|
|
115091
|
+
case "Arrays": {
|
|
115092
|
+
const element = ast.elements[index4];
|
|
114262
115093
|
if (element !== undefined) {
|
|
114263
|
-
return element
|
|
115094
|
+
return element;
|
|
114264
115095
|
}
|
|
114265
115096
|
if (ast.rest.length === 0) {
|
|
114266
115097
|
return;
|
|
114267
115098
|
}
|
|
114268
|
-
return unionAst(ast.rest
|
|
115099
|
+
return unionAst(ast.rest);
|
|
114269
115100
|
}
|
|
114270
115101
|
case "Union": {
|
|
114271
115102
|
const values2 = ast.types.flatMap((member) => {
|
|
114272
|
-
const next = numberAstOf(member,
|
|
115103
|
+
const next = numberAstOf(member, index4);
|
|
114273
115104
|
return next === undefined ? [] : [next];
|
|
114274
115105
|
});
|
|
114275
115106
|
return unionAst(values2);
|
|
@@ -114280,7 +115111,7 @@ var numberAstOf = (ast, index5) => {
|
|
|
114280
115111
|
};
|
|
114281
115112
|
var exactJsonSegments = (segments) => segments.every((segment) => segment.kind === "key" || segment.kind === "index");
|
|
114282
115113
|
var schemaAstAtExactJsonPath = (schema2, segments) => {
|
|
114283
|
-
let current =
|
|
115114
|
+
let current = schema2.ast;
|
|
114284
115115
|
for (const segment of segments) {
|
|
114285
115116
|
if (segment.kind === "key") {
|
|
114286
115117
|
const property = propertyAstOf(current, segment.key);
|
|
@@ -114310,28 +115141,28 @@ var unionSchemas = (schemas) => {
|
|
|
114310
115141
|
if (resolved.length === 1) {
|
|
114311
115142
|
return resolved[0];
|
|
114312
115143
|
}
|
|
114313
|
-
return Schema8.Union(
|
|
115144
|
+
return Schema8.Union(resolved);
|
|
114314
115145
|
};
|
|
114315
115146
|
var firstSelectedExpression = (plan) => {
|
|
114316
115147
|
const selection = getAst(plan).select;
|
|
114317
115148
|
return flattenSelection(selection)[0]?.expression;
|
|
114318
115149
|
};
|
|
114319
115150
|
var isJsonCompatibleAst = (ast) => {
|
|
115151
|
+
ast = SchemaAST.toType(ast);
|
|
114320
115152
|
switch (ast._tag) {
|
|
114321
|
-
case "
|
|
114322
|
-
case "
|
|
114323
|
-
case "
|
|
114324
|
-
case "
|
|
114325
|
-
case "
|
|
115153
|
+
case "String":
|
|
115154
|
+
case "Number":
|
|
115155
|
+
case "Boolean":
|
|
115156
|
+
case "Null":
|
|
115157
|
+
case "Arrays":
|
|
115158
|
+
case "Objects":
|
|
114326
115159
|
return true;
|
|
114327
115160
|
case "Literal":
|
|
114328
|
-
return
|
|
115161
|
+
return typeof ast.literal === "string" || typeof ast.literal === "number" || typeof ast.literal === "boolean";
|
|
114329
115162
|
case "Union":
|
|
114330
115163
|
return ast.types.every(isJsonCompatibleAst);
|
|
114331
|
-
case "Transformation":
|
|
114332
|
-
return isJsonCompatibleAst(SchemaAST.typeAST(ast));
|
|
114333
115164
|
case "Suspend":
|
|
114334
|
-
return isJsonCompatibleAst(ast.
|
|
115165
|
+
return isJsonCompatibleAst(ast.thunk());
|
|
114335
115166
|
default:
|
|
114336
115167
|
return false;
|
|
114337
115168
|
}
|
|
@@ -114340,14 +115171,14 @@ var jsonCompatibleSchema = (schema2) => {
|
|
|
114340
115171
|
if (schema2 === undefined) {
|
|
114341
115172
|
return;
|
|
114342
115173
|
}
|
|
114343
|
-
const ast = SchemaAST.
|
|
115174
|
+
const ast = SchemaAST.toType(schema2.ast);
|
|
114344
115175
|
return isJsonCompatibleAst(ast) ? schema2 : JsonValueSchema;
|
|
114345
115176
|
};
|
|
114346
115177
|
var buildStructSchema = (entries, context) => {
|
|
114347
115178
|
const fields2 = Object.fromEntries(entries.map((entry) => [entry.key, expressionRuntimeSchema(entry.value, context) ?? JsonValueSchema]));
|
|
114348
115179
|
return Schema8.Struct(fields2);
|
|
114349
115180
|
};
|
|
114350
|
-
var buildTupleSchema = (values2, context) => Schema8.Tuple(
|
|
115181
|
+
var buildTupleSchema = (values2, context) => Schema8.Tuple(values2.map((value) => expressionRuntimeSchema(value, context) ?? JsonValueSchema));
|
|
114351
115182
|
var deriveCaseSchema = (ast, context) => {
|
|
114352
115183
|
if (context === undefined) {
|
|
114353
115184
|
return unionSchemas([
|
|
@@ -114500,20 +115331,20 @@ var expressionRuntimeSchema = (expression, context) => {
|
|
|
114500
115331
|
};
|
|
114501
115332
|
|
|
114502
115333
|
// src/internal/executor.ts
|
|
114503
|
-
var setPath2 = (target,
|
|
115334
|
+
var setPath2 = (target, path2, value) => {
|
|
114504
115335
|
let current = target;
|
|
114505
|
-
for (let
|
|
114506
|
-
const
|
|
114507
|
-
const existing = current[
|
|
115336
|
+
for (let index4 = 0;index4 < path2.length - 1; index4++) {
|
|
115337
|
+
const key2 = path2[index4];
|
|
115338
|
+
const existing = current[key2];
|
|
114508
115339
|
if (typeof existing === "object" && existing !== null && !Array.isArray(existing)) {
|
|
114509
115340
|
current = existing;
|
|
114510
115341
|
continue;
|
|
114511
115342
|
}
|
|
114512
115343
|
const next = {};
|
|
114513
|
-
current[
|
|
115344
|
+
current[key2] = next;
|
|
114514
115345
|
current = next;
|
|
114515
115346
|
}
|
|
114516
|
-
current[
|
|
115347
|
+
current[path2[path2.length - 1]] = value;
|
|
114517
115348
|
};
|
|
114518
115349
|
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
115350
|
var hasWriteCapabilityInSource = (source) => typeof source === "object" && source !== null && ("plan" in source) ? hasWriteCapability(source.plan) : false;
|
|
@@ -114553,24 +115384,31 @@ var remapRows = (query, rows) => rows.map((row) => {
|
|
|
114553
115384
|
}
|
|
114554
115385
|
return decoded;
|
|
114555
115386
|
});
|
|
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
|
-
|
|
115387
|
+
var makeRowDecodeError = (rendered, projection, expression, raw, stage, cause, normalized) => {
|
|
115388
|
+
const schemaError = Schema9.isSchemaError(cause) ? {
|
|
115389
|
+
message: cause.message,
|
|
115390
|
+
issue: cause.issue
|
|
115391
|
+
} : undefined;
|
|
115392
|
+
return {
|
|
115393
|
+
_tag: "RowDecodeError",
|
|
115394
|
+
message: stage === "normalize" ? `Failed to normalize projection '${projection.alias}'` : `Failed to decode projection '${projection.alias}' against its runtime schema`,
|
|
115395
|
+
dialect: rendered.dialect,
|
|
115396
|
+
query: {
|
|
115397
|
+
sql: rendered.sql,
|
|
115398
|
+
params: rendered.params
|
|
115399
|
+
},
|
|
115400
|
+
projection: {
|
|
115401
|
+
alias: projection.alias,
|
|
115402
|
+
path: projection.path
|
|
115403
|
+
},
|
|
115404
|
+
dbType: expression[TypeId].dbType,
|
|
115405
|
+
raw,
|
|
115406
|
+
normalized,
|
|
115407
|
+
stage,
|
|
115408
|
+
cause,
|
|
115409
|
+
...schemaError === undefined ? {} : { schemaError }
|
|
115410
|
+
};
|
|
115411
|
+
};
|
|
114574
115412
|
var hasOptionalSourceDependency = (expression, scope) => {
|
|
114575
115413
|
const state = expression[TypeId];
|
|
114576
115414
|
return Object.keys(state.dependencies).some((sourceName) => !scope.absentSourceNames.has(sourceName) && scope.sourceModes.get(sourceName) === "optional");
|
|
@@ -114582,11 +115420,11 @@ var effectiveRuntimeNullability = (expression, scope) => {
|
|
|
114582
115420
|
return "always";
|
|
114583
115421
|
}
|
|
114584
115422
|
if (ast.kind === "column") {
|
|
114585
|
-
const
|
|
114586
|
-
if (scope.absentSourceNames.has(ast.tableName) || scope.nullKeys.has(
|
|
115423
|
+
const key2 = columnPredicateKey(ast.tableName, ast.columnName);
|
|
115424
|
+
if (scope.absentSourceNames.has(ast.tableName) || scope.nullKeys.has(key2)) {
|
|
114587
115425
|
return "always";
|
|
114588
115426
|
}
|
|
114589
|
-
if (scope.nonNullKeys.has(
|
|
115427
|
+
if (scope.nonNullKeys.has(key2)) {
|
|
114590
115428
|
return "never";
|
|
114591
115429
|
}
|
|
114592
115430
|
}
|
|
@@ -114613,8 +115451,8 @@ var decodeProjectionValue = (rendered, projection, expression, raw, scope, drive
|
|
|
114613
115451
|
driverValueMapping: expression[TypeId].driverValueMapping,
|
|
114614
115452
|
valueMappings
|
|
114615
115453
|
});
|
|
114616
|
-
} catch (
|
|
114617
|
-
throw makeRowDecodeError(rendered, projection, expression, raw, "normalize",
|
|
115454
|
+
} catch (cause2) {
|
|
115455
|
+
throw makeRowDecodeError(rendered, projection, expression, raw, "normalize", cause2);
|
|
114618
115456
|
}
|
|
114619
115457
|
}
|
|
114620
115458
|
const nullability = effectiveRuntimeNullability(expression, scope);
|
|
@@ -114640,18 +115478,22 @@ var decodeProjectionValue = (rendered, projection, expression, raw, scope, drive
|
|
|
114640
115478
|
if (Schema9.is(schema2)(normalized)) {
|
|
114641
115479
|
return normalized;
|
|
114642
115480
|
}
|
|
114643
|
-
|
|
114644
|
-
|
|
114645
|
-
|
|
114646
|
-
throw makeRowDecodeError(rendered, projection, expression, raw, "schema", cause, normalized);
|
|
115481
|
+
const decoded = Schema9.decodeUnknownExit(schema2)(normalized);
|
|
115482
|
+
if (Exit.isSuccess(decoded)) {
|
|
115483
|
+
return decoded.value;
|
|
114647
115484
|
}
|
|
115485
|
+
const cause = Option.match(Exit.findErrorOption(decoded), {
|
|
115486
|
+
onNone: () => decoded.cause,
|
|
115487
|
+
onSome: (schemaError) => schemaError
|
|
115488
|
+
});
|
|
115489
|
+
throw makeRowDecodeError(rendered, projection, expression, raw, "schema", cause, normalized);
|
|
114648
115490
|
};
|
|
114649
115491
|
var makeRowDecoder = (rendered, plan, options2 = {}) => {
|
|
114650
115492
|
const projections = flattenSelection(getAst(plan).select);
|
|
114651
115493
|
const byPath = new Map(projections.map((projection) => [JSON.stringify(projection.path), projection.expression]));
|
|
114652
115494
|
const driverMode = options2.driverMode ?? "raw";
|
|
114653
115495
|
const valueMappings = options2.valueMappings ?? rendered.valueMappings;
|
|
114654
|
-
const scope = resolveImplicationScope(plan[
|
|
115496
|
+
const scope = resolveImplicationScope(plan[TypeId4].available, getQueryState(plan).assumptions);
|
|
114655
115497
|
return (row) => {
|
|
114656
115498
|
const decoded = {};
|
|
114657
115499
|
for (const projection of rendered.projections) {
|
|
@@ -114669,7 +115511,7 @@ var makeRowDecoder = (rendered, plan, options2 = {}) => {
|
|
|
114669
115511
|
};
|
|
114670
115512
|
var decodeChunk = (rendered, plan, rows, options2 = {}) => {
|
|
114671
115513
|
const decodeRow = makeRowDecoder(rendered, plan, options2);
|
|
114672
|
-
return Chunk.
|
|
115514
|
+
return Chunk.fromIterable(Chunk.toReadonlyArray(rows).map((row) => decodeRow(row)));
|
|
114673
115515
|
};
|
|
114674
115516
|
var decodeRows = (rendered, plan, rows, options2 = {}) => {
|
|
114675
115517
|
const decodeRow = makeRowDecoder(rendered, plan, options2);
|
|
@@ -114707,12 +115549,12 @@ var fromDriver = (renderer, sqlDriver) => {
|
|
|
114707
115549
|
},
|
|
114708
115550
|
stream(plan) {
|
|
114709
115551
|
const rendered = renderer.render(plan);
|
|
114710
|
-
return Stream.
|
|
115552
|
+
return Stream.mapArray(sqlDriver.stream(rendered), (rows) => remapRows(rendered, rows));
|
|
114711
115553
|
}
|
|
114712
115554
|
};
|
|
114713
115555
|
return executor;
|
|
114714
115556
|
};
|
|
114715
|
-
var streamFromSqlClient = (query) => Stream.
|
|
115557
|
+
var streamFromSqlClient = (query) => Stream.unwrap(Effect.flatMap(SqlClient.SqlClient, (sql) => Effect.flatMap(Effect.serviceOption(sql.transactionService), Option.match({
|
|
114716
115558
|
onNone: () => sql.reserve,
|
|
114717
115559
|
onSome: ([connection]) => Effect.succeed(connection)
|
|
114718
115560
|
})).pipe(Effect.map((connection) => connection.executeStream(query.sql, [...query.params], undefined)))));
|
|
@@ -114721,12 +115563,11 @@ var fromSqlClient = (renderer) => fromDriver(renderer, driver(renderer.dialect,
|
|
|
114721
115563
|
stream: (query) => streamFromSqlClient(query)
|
|
114722
115564
|
}));
|
|
114723
115565
|
var withTransaction = (effect) => Effect.flatMap(SqlClient.SqlClient, (sql) => sql.withTransaction(effect));
|
|
114724
|
-
var withSavepoint = (effect) => Effect.flatMap(SqlClient.SqlClient, (sql) => sql.withTransaction(effect));
|
|
114725
115566
|
|
|
114726
115567
|
// src/internal/renderer.ts
|
|
114727
115568
|
var TypeId10 = Symbol.for("effect-qb/Renderer");
|
|
114728
|
-
var projectionPathKey = (
|
|
114729
|
-
var formatProjectionPath2 = (
|
|
115569
|
+
var projectionPathKey = (path2) => JSON.stringify(path2);
|
|
115570
|
+
var formatProjectionPath2 = (path2) => path2.join(".");
|
|
114730
115571
|
var validateProjectionPathsMatchSelection = (plan, projections) => {
|
|
114731
115572
|
const expected = flattenSelection(getAst(plan).select);
|
|
114732
115573
|
const expectedPaths = new Set(expected.map((projection) => projectionPathKey(projection.path)));
|
|
@@ -114785,14 +115626,15 @@ var renderDbTypeName = (value) => value;
|
|
|
114785
115626
|
// src/internal/dialect-renderers/mysql.ts
|
|
114786
115627
|
import * as Schema10 from "effect/Schema";
|
|
114787
115628
|
var renderDbType = (dialect, dbType) => {
|
|
114788
|
-
|
|
114789
|
-
return "char(36)";
|
|
114790
|
-
}
|
|
114791
|
-
return renderDbTypeName(dbType.kind);
|
|
115629
|
+
return renderDbTypeName(renderPortableDatatypeDdlType(dialect.name, dbType.kind) ?? dbType.kind);
|
|
114792
115630
|
};
|
|
114793
115631
|
var isArrayDbType = (dbType) => ("element" in dbType);
|
|
114794
115632
|
var renderCastType = (dialect, dbType) => {
|
|
114795
115633
|
const kind = dbType?.kind;
|
|
115634
|
+
const portableType = renderPortableDatatypeCastType(dialect.name, kind);
|
|
115635
|
+
if (portableType !== undefined) {
|
|
115636
|
+
return renderDbTypeName(portableType);
|
|
115637
|
+
}
|
|
114796
115638
|
if (dialect.name !== "mysql") {
|
|
114797
115639
|
return renderDbTypeName(kind);
|
|
114798
115640
|
}
|
|
@@ -114861,7 +115703,7 @@ var renderMysqlMutationLimit = (expression, state, dialect) => {
|
|
|
114861
115703
|
}
|
|
114862
115704
|
return renderExpression(expression, state, dialect);
|
|
114863
115705
|
};
|
|
114864
|
-
var casingForTable = (table, state) => merge(state.casing, table[
|
|
115706
|
+
var casingForTable = (table, state) => merge(state.casing, table[TypeId7].casing);
|
|
114865
115707
|
var casedColumnName = (columnName, state, tableName) => {
|
|
114866
115708
|
if (tableName !== undefined) {
|
|
114867
115709
|
const mapped = state.sourceNames?.get(tableName)?.columns.get(columnName);
|
|
@@ -114873,7 +115715,7 @@ var casedColumnName = (columnName, state, tableName) => {
|
|
|
114873
115715
|
};
|
|
114874
115716
|
var casedTableReferenceName = (tableName, state) => state.sourceNames?.get(tableName)?.tableName ?? applyCategory(state.casing, "tables", tableName);
|
|
114875
115717
|
var quoteColumn = (columnName, state, dialect, tableName) => dialect.quoteIdentifier(casedColumnName(columnName, state, tableName));
|
|
114876
|
-
var stateWithTableCasing = (state, source) => typeof source === "object" && source !== null && (
|
|
115718
|
+
var stateWithTableCasing = (state, source) => typeof source === "object" && source !== null && (TypeId7 in source) ? { ...state, casing: casingForTable(source, state) } : state;
|
|
114877
115719
|
var referenceCasing = (reference, state) => merge(state.casing, reference.casing);
|
|
114878
115720
|
var renderReferenceTable = (reference, state, dialect) => {
|
|
114879
115721
|
const casing = referenceCasing(reference, state);
|
|
@@ -114886,9 +115728,9 @@ var registerSourceReference = (source, tableName, state) => {
|
|
|
114886
115728
|
if (typeof source !== "object" || source === null) {
|
|
114887
115729
|
return;
|
|
114888
115730
|
}
|
|
114889
|
-
if (
|
|
115731
|
+
if (TypeId7 in source) {
|
|
114890
115732
|
const table = source;
|
|
114891
|
-
const tableState = table[
|
|
115733
|
+
const tableState = table[TypeId7];
|
|
114892
115734
|
const casing = casingForTable(table, state);
|
|
114893
115735
|
const renderedTableName = tableState.kind === "alias" ? tableName : applyCategory(casing, "tables", tableState.baseName);
|
|
114894
115736
|
const columns = new Map(Object.keys(tableState.fields).map((columnName) => [
|
|
@@ -114956,11 +115798,11 @@ var renderCreateTableSql = (targetSource, state, dialect, ifNotExists) => {
|
|
|
114956
115798
|
const normalizedIfNotExists = normalizeStatementFlag(ifNotExists);
|
|
114957
115799
|
const table = targetSource.source;
|
|
114958
115800
|
const tableCasing = casingForTable(table, state);
|
|
114959
|
-
const fields2 = table[
|
|
115801
|
+
const fields2 = table[TypeId7].fields;
|
|
114960
115802
|
const definitions = Object.entries(fields2).map(([columnName, column]) => renderColumnDefinition(dialect, state, columnName, column, targetSource.tableName, tableCasing));
|
|
114961
115803
|
const options2 = table[OptionsSymbol];
|
|
114962
115804
|
const tableOptions = Array.isArray(options2) ? options2 : [options2];
|
|
114963
|
-
validateOptions(table[
|
|
115805
|
+
validateOptions(table[TypeId7].name, fields2, tableOptions);
|
|
114964
115806
|
for (const option2 of tableOptions) {
|
|
114965
115807
|
if (typeof option2 !== "object" || option2 === null || !("kind" in option2)) {
|
|
114966
115808
|
continue;
|
|
@@ -115022,7 +115864,7 @@ var renderDropIndexSql = (targetSource, ddl, state, dialect) => {
|
|
|
115022
115864
|
const tableCasing = casingForTable(table, state);
|
|
115023
115865
|
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
115866
|
};
|
|
115025
|
-
var
|
|
115867
|
+
var isExpression4 = (value) => value !== null && typeof value === "object" && (TypeId in value);
|
|
115026
115868
|
var isJsonDbType2 = (dbType) => {
|
|
115027
115869
|
if (dbType.kind === "jsonb" || dbType.kind === "json") {
|
|
115028
115870
|
return true;
|
|
@@ -115033,7 +115875,7 @@ var isJsonDbType2 = (dbType) => {
|
|
|
115033
115875
|
const variant = dbType.variant;
|
|
115034
115876
|
return variant === "json" || variant === "jsonb";
|
|
115035
115877
|
};
|
|
115036
|
-
var
|
|
115878
|
+
var isJsonExpression2 = (value) => isExpression4(value) && isJsonDbType2(value[TypeId].dbType);
|
|
115037
115879
|
var expectValueExpression = (_functionName, value) => value;
|
|
115038
115880
|
var expectBinaryExpressions = (_functionName, left, right) => [left, right];
|
|
115039
115881
|
var renderBinaryExpression = (functionName, operator, left, right, state, dialect) => {
|
|
@@ -115050,7 +115892,7 @@ var unsupportedJsonFeature = (dialect, feature) => {
|
|
|
115050
115892
|
throw error;
|
|
115051
115893
|
};
|
|
115052
115894
|
var extractJsonBase = (node) => node.value ?? node.base ?? node.input ?? node.left ?? node.target;
|
|
115053
|
-
var isJsonPathValue2 = (value) => value !== null && typeof value === "object" && (
|
|
115895
|
+
var isJsonPathValue2 = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
115054
115896
|
var isOptionalJsonPathNumber = (value) => value === undefined || typeof value === "number" && Number.isFinite(value);
|
|
115055
115897
|
var isJsonPathSegment = (segment) => {
|
|
115056
115898
|
if (typeof segment === "string") {
|
|
@@ -115066,8 +115908,8 @@ var isJsonPathSegment = (segment) => {
|
|
|
115066
115908
|
case "key":
|
|
115067
115909
|
return typeof segment.key === "string";
|
|
115068
115910
|
case "index": {
|
|
115069
|
-
const
|
|
115070
|
-
return typeof
|
|
115911
|
+
const index4 = segment.index;
|
|
115912
|
+
return typeof index4 === "number" && Number.isFinite(index4);
|
|
115071
115913
|
}
|
|
115072
115914
|
case "wildcard":
|
|
115073
115915
|
case "descend":
|
|
@@ -115088,12 +115930,12 @@ var validateJsonPathSegments = (segments) => {
|
|
|
115088
115930
|
return segments;
|
|
115089
115931
|
};
|
|
115090
115932
|
var extractJsonPathSegments = (node) => {
|
|
115091
|
-
const
|
|
115092
|
-
if (isJsonPathValue2(
|
|
115093
|
-
return validateJsonPathSegments(
|
|
115933
|
+
const path2 = node.path ?? node.segments ?? node.keys;
|
|
115934
|
+
if (isJsonPathValue2(path2)) {
|
|
115935
|
+
return validateJsonPathSegments(path2.segments);
|
|
115094
115936
|
}
|
|
115095
|
-
if (Array.isArray(
|
|
115096
|
-
return validateJsonPathSegments(
|
|
115937
|
+
if (Array.isArray(path2)) {
|
|
115938
|
+
return validateJsonPathSegments(path2);
|
|
115097
115939
|
}
|
|
115098
115940
|
if (node.segments !== undefined) {
|
|
115099
115941
|
return validateJsonPathSegments(node.segments);
|
|
@@ -115107,7 +115949,7 @@ var extractJsonPathSegments = (node) => {
|
|
|
115107
115949
|
return [key(segment)];
|
|
115108
115950
|
}
|
|
115109
115951
|
if (typeof segment === "number") {
|
|
115110
|
-
return [
|
|
115952
|
+
return [index(segment)];
|
|
115111
115953
|
}
|
|
115112
115954
|
if (segment !== null && typeof segment === "object" && SegmentTypeId in segment) {
|
|
115113
115955
|
return [segment];
|
|
@@ -115144,7 +115986,7 @@ var renderJsonPathSegment = (segment) => {
|
|
|
115144
115986
|
throw new Error("Unsupported JSON path segment");
|
|
115145
115987
|
}
|
|
115146
115988
|
};
|
|
115147
|
-
var renderMySqlJsonIndex = (
|
|
115989
|
+
var renderMySqlJsonIndex = (index4) => index4 >= 0 ? String(index4) : index4 === -1 ? "last" : `last-${Math.abs(index4) - 1}`;
|
|
115148
115990
|
var renderMySqlJsonPathSegment = (segment) => {
|
|
115149
115991
|
if (typeof segment === "number") {
|
|
115150
115992
|
return `[${renderMySqlJsonIndex(segment)}]`;
|
|
@@ -115161,11 +116003,11 @@ var renderMySqlJsonPathSegment = (segment) => {
|
|
|
115161
116003
|
return renderJsonPathSegment(segment);
|
|
115162
116004
|
};
|
|
115163
116005
|
var renderJsonPathStringLiteral = (segments, renderSegment = renderJsonPathSegment) => {
|
|
115164
|
-
let
|
|
116006
|
+
let path2 = "$";
|
|
115165
116007
|
for (const segment of segments) {
|
|
115166
|
-
|
|
116008
|
+
path2 += renderSegment(segment);
|
|
115167
116009
|
}
|
|
115168
|
-
return
|
|
116010
|
+
return path2;
|
|
115169
116011
|
};
|
|
115170
116012
|
var renderMySqlJsonPath = (segments, state, dialect) => dialect.renderLiteral(renderJsonPathStringLiteral(segments, renderMySqlJsonPathSegment), state);
|
|
115171
116013
|
var isJsonArrayIndexSegment = (segment) => typeof segment === "number" || typeof segment === "object" && segment !== null && segment.kind === "index";
|
|
@@ -115217,7 +116059,7 @@ var renderPostgresJsonAccessStep = (segment, textMode, state, dialect) => {
|
|
|
115217
116059
|
}
|
|
115218
116060
|
};
|
|
115219
116061
|
var renderPostgresJsonValue = (value, state, dialect) => {
|
|
115220
|
-
if (!
|
|
116062
|
+
if (!isExpression4(value)) {
|
|
115221
116063
|
throw new Error("Expected a JSON expression");
|
|
115222
116064
|
}
|
|
115223
116065
|
const rendered = renderExpression(value, state, dialect);
|
|
@@ -115274,7 +116116,7 @@ var renderJsonOpaquePath = (value, state, dialect) => {
|
|
|
115274
116116
|
}
|
|
115275
116117
|
return dialect.renderLiteral(value, state);
|
|
115276
116118
|
}
|
|
115277
|
-
if (
|
|
116119
|
+
if (isExpression4(value)) {
|
|
115278
116120
|
const ast = value[TypeId2];
|
|
115279
116121
|
if (ast.kind === "literal" && typeof ast.value === "string" && ast.value.trim().length === 0) {
|
|
115280
116122
|
throw new Error("SQL/JSON path input must be a non-empty string");
|
|
@@ -115324,8 +116166,8 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115324
116166
|
const base = extractJsonBase(ast);
|
|
115325
116167
|
const segments = extractJsonPathSegments(ast);
|
|
115326
116168
|
const exact = segments.every((segment) => segment.kind === "key" || segment.kind === "index");
|
|
115327
|
-
const postgresExpressionKind = dialect.name === "postgres" &&
|
|
115328
|
-
const postgresBaseKind = dialect.name === "postgres" &&
|
|
116169
|
+
const postgresExpressionKind = dialect.name === "postgres" && isJsonExpression2(expression) ? renderPostgresJsonKind(expression) : undefined;
|
|
116170
|
+
const postgresBaseKind = dialect.name === "postgres" && isJsonExpression2(base) ? renderPostgresJsonKind(base) : undefined;
|
|
115329
116171
|
switch (kind) {
|
|
115330
116172
|
case "jsonGet":
|
|
115331
116173
|
case "jsonPath":
|
|
@@ -115335,7 +116177,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115335
116177
|
case "jsonPathText":
|
|
115336
116178
|
case "jsonAccessText":
|
|
115337
116179
|
case "jsonTraverseText": {
|
|
115338
|
-
if (!
|
|
116180
|
+
if (!isExpression4(base) || segments.length === 0) {
|
|
115339
116181
|
return;
|
|
115340
116182
|
}
|
|
115341
116183
|
const baseSql = renderExpression(base, state, dialect);
|
|
@@ -115358,24 +116200,24 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115358
116200
|
case "jsonKeyExists":
|
|
115359
116201
|
case "jsonHasAnyKeys":
|
|
115360
116202
|
case "jsonHasAllKeys": {
|
|
115361
|
-
if (!
|
|
116203
|
+
if (!isExpression4(base)) {
|
|
115362
116204
|
return;
|
|
115363
116205
|
}
|
|
115364
116206
|
const baseSql = dialect.name === "postgres" ? renderPostgresJsonValue(base, state, dialect) : renderExpression(base, state, dialect);
|
|
115365
|
-
const
|
|
115366
|
-
if (
|
|
116207
|
+
const keys = extractJsonKeys(ast, segments);
|
|
116208
|
+
if (keys.length === 0) {
|
|
115367
116209
|
return;
|
|
115368
116210
|
}
|
|
115369
|
-
if (
|
|
116211
|
+
if (keys.some((key2) => typeof key2 !== "string" || key2.length === 0)) {
|
|
115370
116212
|
throw new Error("json key predicates require string keys");
|
|
115371
116213
|
}
|
|
115372
|
-
const keyNames =
|
|
116214
|
+
const keyNames = keys;
|
|
115373
116215
|
if (dialect.name === "postgres") {
|
|
115374
116216
|
if (kind === "jsonHasAnyKeys") {
|
|
115375
|
-
return `(${baseSql} ?| array[${keyNames.map((
|
|
116217
|
+
return `(${baseSql} ?| array[${keyNames.map((key2) => renderPostgresTextLiteral(key2, state, dialect)).join(", ")}])`;
|
|
115376
116218
|
}
|
|
115377
116219
|
if (kind === "jsonHasAllKeys") {
|
|
115378
|
-
return `(${baseSql} ?& array[${keyNames.map((
|
|
116220
|
+
return `(${baseSql} ?& array[${keyNames.map((key2) => renderPostgresTextLiteral(key2, state, dialect)).join(", ")}])`;
|
|
115379
116221
|
}
|
|
115380
116222
|
return `(${baseSql} ? ${renderPostgresTextLiteral(keyNames[0], state, dialect)})`;
|
|
115381
116223
|
}
|
|
@@ -115389,7 +116231,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115389
116231
|
}
|
|
115390
116232
|
case "jsonConcat":
|
|
115391
116233
|
case "jsonMerge": {
|
|
115392
|
-
if (!
|
|
116234
|
+
if (!isExpression4(ast.left) || !isExpression4(ast.right)) {
|
|
115393
116235
|
return;
|
|
115394
116236
|
}
|
|
115395
116237
|
if (dialect.name === "postgres") {
|
|
@@ -115426,7 +116268,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115426
116268
|
return;
|
|
115427
116269
|
}
|
|
115428
116270
|
case "jsonToJson":
|
|
115429
|
-
if (!
|
|
116271
|
+
if (!isExpression4(base)) {
|
|
115430
116272
|
return;
|
|
115431
116273
|
}
|
|
115432
116274
|
if (dialect.name === "postgres") {
|
|
@@ -115437,7 +116279,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115437
116279
|
}
|
|
115438
116280
|
return;
|
|
115439
116281
|
case "jsonToJsonb":
|
|
115440
|
-
if (!
|
|
116282
|
+
if (!isExpression4(base)) {
|
|
115441
116283
|
return;
|
|
115442
116284
|
}
|
|
115443
116285
|
if (dialect.name === "postgres") {
|
|
@@ -115448,7 +116290,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115448
116290
|
}
|
|
115449
116291
|
return;
|
|
115450
116292
|
case "jsonTypeOf":
|
|
115451
|
-
if (!
|
|
116293
|
+
if (!isExpression4(base)) {
|
|
115452
116294
|
return;
|
|
115453
116295
|
}
|
|
115454
116296
|
if (dialect.name === "postgres") {
|
|
@@ -115460,7 +116302,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115460
116302
|
}
|
|
115461
116303
|
return;
|
|
115462
116304
|
case "jsonLength":
|
|
115463
|
-
if (!
|
|
116305
|
+
if (!isExpression4(base)) {
|
|
115464
116306
|
return;
|
|
115465
116307
|
}
|
|
115466
116308
|
if (dialect.name === "postgres") {
|
|
@@ -115475,7 +116317,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115475
116317
|
}
|
|
115476
116318
|
return;
|
|
115477
116319
|
case "jsonKeys":
|
|
115478
|
-
if (!
|
|
116320
|
+
if (!isExpression4(base)) {
|
|
115479
116321
|
return;
|
|
115480
116322
|
}
|
|
115481
116323
|
if (dialect.name === "postgres") {
|
|
@@ -115489,7 +116331,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115489
116331
|
}
|
|
115490
116332
|
return;
|
|
115491
116333
|
case "jsonStripNulls":
|
|
115492
|
-
if (!
|
|
116334
|
+
if (!isExpression4(base)) {
|
|
115493
116335
|
return;
|
|
115494
116336
|
}
|
|
115495
116337
|
if (dialect.name === "postgres") {
|
|
@@ -115500,7 +116342,7 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115500
116342
|
case "jsonDelete":
|
|
115501
116343
|
case "jsonDeletePath":
|
|
115502
116344
|
case "jsonRemove": {
|
|
115503
|
-
if (!
|
|
116345
|
+
if (!isExpression4(base) || segments.length === 0) {
|
|
115504
116346
|
return;
|
|
115505
116347
|
}
|
|
115506
116348
|
if (dialect.name === "postgres") {
|
|
@@ -115519,11 +116361,11 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115519
116361
|
}
|
|
115520
116362
|
case "jsonSet":
|
|
115521
116363
|
case "jsonInsert": {
|
|
115522
|
-
if (!
|
|
116364
|
+
if (!isExpression4(base) || segments.length === 0) {
|
|
115523
116365
|
return;
|
|
115524
116366
|
}
|
|
115525
116367
|
const nextValue = extractJsonValue(ast);
|
|
115526
|
-
if (!
|
|
116368
|
+
if (!isExpression4(nextValue)) {
|
|
115527
116369
|
return;
|
|
115528
116370
|
}
|
|
115529
116371
|
const createMissing = ast.createMissing === true;
|
|
@@ -115549,39 +116391,39 @@ var renderJsonExpression = (expression, ast, state, dialect) => {
|
|
|
115549
116391
|
return;
|
|
115550
116392
|
}
|
|
115551
116393
|
case "jsonPathExists": {
|
|
115552
|
-
if (!
|
|
116394
|
+
if (!isExpression4(base)) {
|
|
115553
116395
|
return;
|
|
115554
116396
|
}
|
|
115555
|
-
const
|
|
115556
|
-
if (
|
|
116397
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
116398
|
+
if (path2 === undefined) {
|
|
115557
116399
|
return;
|
|
115558
116400
|
}
|
|
115559
116401
|
if (dialect.name === "postgres") {
|
|
115560
|
-
return `(${renderPostgresJsonValue(base, state, dialect)} @? ${renderJsonOpaquePath(
|
|
116402
|
+
return `(${renderPostgresJsonValue(base, state, dialect)} @? ${renderJsonOpaquePath(path2, state, dialect)})`;
|
|
115561
116403
|
}
|
|
115562
116404
|
if (dialect.name === "mysql") {
|
|
115563
|
-
return `json_contains_path(${renderExpression(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath(
|
|
116405
|
+
return `json_contains_path(${renderExpression(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath(path2, state, dialect)})`;
|
|
115564
116406
|
}
|
|
115565
116407
|
return;
|
|
115566
116408
|
}
|
|
115567
116409
|
case "jsonPathMatch": {
|
|
115568
|
-
if (!
|
|
116410
|
+
if (!isExpression4(base)) {
|
|
115569
116411
|
return;
|
|
115570
116412
|
}
|
|
115571
|
-
const
|
|
115572
|
-
if (
|
|
116413
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
116414
|
+
if (path2 === undefined) {
|
|
115573
116415
|
return;
|
|
115574
116416
|
}
|
|
115575
116417
|
if (dialect.name === "postgres") {
|
|
115576
|
-
return `(${renderPostgresJsonValue(base, state, dialect)} @@ ${renderJsonOpaquePath(
|
|
116418
|
+
return `(${renderPostgresJsonValue(base, state, dialect)} @@ ${renderJsonOpaquePath(path2, state, dialect)})`;
|
|
115577
116419
|
}
|
|
115578
116420
|
unsupportedJsonFeature(dialect, "jsonPathMatch");
|
|
115579
116421
|
}
|
|
115580
116422
|
}
|
|
115581
116423
|
return;
|
|
115582
116424
|
};
|
|
115583
|
-
var selectionProjections = (selection) => flattenSelection(selection).map(({ path:
|
|
115584
|
-
path:
|
|
116425
|
+
var selectionProjections = (selection) => flattenSelection(selection).map(({ path: path2, alias: alias2 }) => ({
|
|
116426
|
+
path: path2,
|
|
115585
116427
|
alias: alias2
|
|
115586
116428
|
}));
|
|
115587
116429
|
var renderMutationAssignment = (entry, state, dialect, targetTableName) => {
|
|
@@ -115721,18 +116563,18 @@ var renderQueryAst = (ast, state, dialect, options2 = {}) => {
|
|
|
115721
116563
|
const columns = insertSource.columns.map((column) => quoteColumn(column, state, dialect, targetSource.tableName)).join(", ");
|
|
115722
116564
|
if (dialect.name === "postgres") {
|
|
115723
116565
|
const table = targetSource.source;
|
|
115724
|
-
const fields2 = table[
|
|
116566
|
+
const fields2 = table[TypeId7].fields;
|
|
115725
116567
|
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
116568
|
sql += ` (${columns}) select * from unnest(${rendered})`;
|
|
115727
116569
|
} else {
|
|
115728
116570
|
const table = targetSource.source;
|
|
115729
|
-
const fields2 = table[
|
|
116571
|
+
const fields2 = table[TypeId7].fields;
|
|
115730
116572
|
const encodedValues = insertSource.values.map((entry) => ({
|
|
115731
116573
|
columnName: entry.columnName,
|
|
115732
116574
|
values: encodeArrayValues(entry.values, fields2[entry.columnName], state, dialect)
|
|
115733
116575
|
}));
|
|
115734
116576
|
const rowCount = encodedValues[0]?.values.length ?? 0;
|
|
115735
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
116577
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => `(${encodedValues.map((entry) => dialect.renderLiteral(entry.values[index4], state)).join(", ")})`).join(", ");
|
|
115736
116578
|
sql += ` (${columns}) values ${rows}`;
|
|
115737
116579
|
}
|
|
115738
116580
|
} else {
|
|
@@ -115890,25 +116732,25 @@ var renderQueryAst = (ast, state, dialect, options2 = {}) => {
|
|
|
115890
116732
|
const mergeAst = ast;
|
|
115891
116733
|
const targetSource = mergeAst.target;
|
|
115892
116734
|
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 (
|
|
116735
|
+
const merge2 = mergeAst.merge;
|
|
116736
|
+
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)}`;
|
|
116737
|
+
if (merge2.whenMatched) {
|
|
115896
116738
|
sql += " when matched";
|
|
115897
|
-
if (
|
|
115898
|
-
sql += ` and ${renderExpression(
|
|
116739
|
+
if (merge2.whenMatched.predicate) {
|
|
116740
|
+
sql += ` and ${renderExpression(merge2.whenMatched.predicate, state, dialect)}`;
|
|
115899
116741
|
}
|
|
115900
|
-
if (
|
|
116742
|
+
if (merge2.whenMatched.kind === "delete") {
|
|
115901
116743
|
sql += " then delete";
|
|
115902
116744
|
} else {
|
|
115903
|
-
sql += ` then update set ${
|
|
116745
|
+
sql += ` then update set ${merge2.whenMatched.values.map((entry) => `${dialect.quoteIdentifier(entry.columnName)} = ${renderExpression(entry.value, state, dialect)}`).join(", ")}`;
|
|
115904
116746
|
}
|
|
115905
116747
|
}
|
|
115906
|
-
if (
|
|
116748
|
+
if (merge2.whenNotMatched) {
|
|
115907
116749
|
sql += " when not matched";
|
|
115908
|
-
if (
|
|
115909
|
-
sql += ` and ${renderExpression(
|
|
116750
|
+
if (merge2.whenNotMatched.predicate) {
|
|
116751
|
+
sql += ` and ${renderExpression(merge2.whenNotMatched.predicate, state, dialect)}`;
|
|
115910
116752
|
}
|
|
115911
|
-
sql += ` then insert (${
|
|
116753
|
+
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
116754
|
}
|
|
115913
116755
|
break;
|
|
115914
116756
|
}
|
|
@@ -115969,7 +116811,7 @@ var renderSourceReference = (source, tableName, baseTableName, state, dialect) =
|
|
|
115969
116811
|
};
|
|
115970
116812
|
const renderUnnestRows = (arrays, columnNames) => {
|
|
115971
116813
|
const rowCount = arrays[columnNames[0]].length;
|
|
115972
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
116814
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => Object.fromEntries(columnNames.map((columnName) => [columnName, arrays[columnName][index4]])));
|
|
115973
116815
|
return renderSelectRows(rows, columnNames);
|
|
115974
116816
|
};
|
|
115975
116817
|
if (typeof source === "object" && source !== null && "kind" in source && source.kind === "cte") {
|
|
@@ -116024,10 +116866,10 @@ var renderSourceReference = (source, tableName, baseTableName, state, dialect) =
|
|
|
116024
116866
|
const columnNames = Object.keys(tableFunction.columns);
|
|
116025
116867
|
return `${functionName}(${tableFunction.args.map((arg) => renderExpression(arg, state, dialect)).join(", ")}) as ${dialect.quoteIdentifier(tableFunction.name)}(${columnNames.map((columnName) => dialect.quoteIdentifier(columnName)).join(", ")})`;
|
|
116026
116868
|
}
|
|
116027
|
-
const schemaName = typeof source === "object" && source !== null &&
|
|
116028
|
-
if (typeof source === "object" && source !== null &&
|
|
116869
|
+
const schemaName = typeof source === "object" && source !== null && TypeId7 in source ? source[TypeId7].schemaName : undefined;
|
|
116870
|
+
if (typeof source === "object" && source !== null && TypeId7 in source) {
|
|
116029
116871
|
const table = source;
|
|
116030
|
-
const tableState = table[
|
|
116872
|
+
const tableState = table[TypeId7];
|
|
116031
116873
|
const casing = casingForTable(table, state);
|
|
116032
116874
|
const renderedTableName = tableState.kind === "alias" ? tableName : applyCategory(casing, "tables", baseTableName);
|
|
116033
116875
|
const renderedBaseName = applyCategory(casing, "tables", baseTableName);
|
|
@@ -116120,11 +116962,11 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116120
116962
|
case "contains": {
|
|
116121
116963
|
const [leftExpression, rightExpression] = expectBinaryExpressions("contains", ast.left, ast.right);
|
|
116122
116964
|
if (dialect.name === "postgres") {
|
|
116123
|
-
const left =
|
|
116124
|
-
const right =
|
|
116965
|
+
const left = isJsonExpression2(leftExpression) ? renderPostgresJsonValue(leftExpression, state, dialect) : renderExpression(leftExpression, state, dialect);
|
|
116966
|
+
const right = isJsonExpression2(rightExpression) ? renderPostgresJsonValue(rightExpression, state, dialect) : renderExpression(rightExpression, state, dialect);
|
|
116125
116967
|
return `(${left} @> ${right})`;
|
|
116126
116968
|
}
|
|
116127
|
-
if (dialect.name === "mysql" &&
|
|
116969
|
+
if (dialect.name === "mysql" && isJsonExpression2(leftExpression) && isJsonExpression2(rightExpression)) {
|
|
116128
116970
|
return `json_contains(${renderJsonInputExpression(leftExpression, state, dialect)}, ${renderJsonInputExpression(rightExpression, state, dialect)})`;
|
|
116129
116971
|
}
|
|
116130
116972
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -116132,11 +116974,11 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116132
116974
|
case "containedBy": {
|
|
116133
116975
|
const [leftExpression, rightExpression] = expectBinaryExpressions("containedBy", ast.left, ast.right);
|
|
116134
116976
|
if (dialect.name === "postgres") {
|
|
116135
|
-
const left =
|
|
116136
|
-
const right =
|
|
116977
|
+
const left = isJsonExpression2(leftExpression) ? renderPostgresJsonValue(leftExpression, state, dialect) : renderExpression(leftExpression, state, dialect);
|
|
116978
|
+
const right = isJsonExpression2(rightExpression) ? renderPostgresJsonValue(rightExpression, state, dialect) : renderExpression(rightExpression, state, dialect);
|
|
116137
116979
|
return `(${left} <@ ${right})`;
|
|
116138
116980
|
}
|
|
116139
|
-
if (dialect.name === "mysql" &&
|
|
116981
|
+
if (dialect.name === "mysql" && isJsonExpression2(leftExpression) && isJsonExpression2(rightExpression)) {
|
|
116140
116982
|
return `json_contains(${renderJsonInputExpression(rightExpression, state, dialect)}, ${renderJsonInputExpression(leftExpression, state, dialect)})`;
|
|
116141
116983
|
}
|
|
116142
116984
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -116144,11 +116986,11 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116144
116986
|
case "overlaps": {
|
|
116145
116987
|
const [leftExpression, rightExpression] = expectBinaryExpressions("overlaps", ast.left, ast.right);
|
|
116146
116988
|
if (dialect.name === "postgres") {
|
|
116147
|
-
const left =
|
|
116148
|
-
const right =
|
|
116989
|
+
const left = isJsonExpression2(leftExpression) ? renderPostgresJsonValue(leftExpression, state, dialect) : renderExpression(leftExpression, state, dialect);
|
|
116990
|
+
const right = isJsonExpression2(rightExpression) ? renderPostgresJsonValue(rightExpression, state, dialect) : renderExpression(rightExpression, state, dialect);
|
|
116149
116991
|
return `(${left} && ${right})`;
|
|
116150
116992
|
}
|
|
116151
|
-
if (dialect.name === "mysql" &&
|
|
116993
|
+
if (dialect.name === "mysql" && isJsonExpression2(leftExpression) && isJsonExpression2(rightExpression)) {
|
|
116152
116994
|
return `json_overlaps(${renderJsonInputExpression(leftExpression, state, dialect)}, ${renderJsonInputExpression(rightExpression, state, dialect)})`;
|
|
116153
116995
|
}
|
|
116154
116996
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -116225,14 +117067,15 @@ var renderExpression = (expression, state, dialect) => {
|
|
|
116225
117067
|
// src/internal/dialect-renderers/postgres.ts
|
|
116226
117068
|
import * as Schema11 from "effect/Schema";
|
|
116227
117069
|
var renderDbType2 = (dialect, dbType) => {
|
|
116228
|
-
|
|
116229
|
-
return "bytea";
|
|
116230
|
-
}
|
|
116231
|
-
return renderDbTypeName(dbType.kind);
|
|
117070
|
+
return renderDbTypeName(renderPortableDatatypeDdlType(dialect.name, dbType.kind) ?? dbType.kind);
|
|
116232
117071
|
};
|
|
116233
117072
|
var isArrayDbType2 = (dbType) => ("element" in dbType);
|
|
116234
117073
|
var renderCastType2 = (dialect, dbType) => {
|
|
116235
117074
|
const kind = dbType?.kind;
|
|
117075
|
+
const portableType = renderPortableDatatypeCastType(dialect.name, kind);
|
|
117076
|
+
if (portableType !== undefined) {
|
|
117077
|
+
return renderDbTypeName(portableType);
|
|
117078
|
+
}
|
|
116236
117079
|
if (dialect.name !== "mysql") {
|
|
116237
117080
|
return renderDbTypeName(kind);
|
|
116238
117081
|
}
|
|
@@ -116254,13 +117097,13 @@ var renderCastType2 = (dialect, dbType) => {
|
|
|
116254
117097
|
return renderDbTypeName(kind);
|
|
116255
117098
|
}
|
|
116256
117099
|
};
|
|
116257
|
-
var casingForTable2 = (table, state) => merge(state.casing, table[
|
|
117100
|
+
var casingForTable2 = (table, state) => merge(state.casing, table[TypeId7].casing);
|
|
116258
117101
|
var casedTableName = (table, state) => {
|
|
116259
|
-
const tableState = table[
|
|
117102
|
+
const tableState = table[TypeId7];
|
|
116260
117103
|
return applyCategory(casingForTable2(table, state), "tables", tableState.baseName);
|
|
116261
117104
|
};
|
|
116262
117105
|
var casedSchemaName = (table, state) => {
|
|
116263
|
-
const schemaName = table[
|
|
117106
|
+
const schemaName = table[TypeId7].schemaName;
|
|
116264
117107
|
return schemaName === undefined ? undefined : applyCategory(casingForTable2(table, state), "schemas", schemaName);
|
|
116265
117108
|
};
|
|
116266
117109
|
var casedColumnName2 = (columnName, state, tableName) => {
|
|
@@ -116274,7 +117117,7 @@ var casedColumnName2 = (columnName, state, tableName) => {
|
|
|
116274
117117
|
};
|
|
116275
117118
|
var casedTableReferenceName2 = (tableName, state) => state.sourceNames?.get(tableName)?.tableName ?? applyCategory(state.casing, "tables", tableName);
|
|
116276
117119
|
var quoteColumn2 = (columnName, state, dialect, tableName) => dialect.quoteIdentifier(casedColumnName2(columnName, state, tableName));
|
|
116277
|
-
var stateWithTableCasing2 = (state, source) => typeof source === "object" && source !== null && (
|
|
117120
|
+
var stateWithTableCasing2 = (state, source) => typeof source === "object" && source !== null && (TypeId7 in source) ? { ...state, casing: casingForTable2(source, state) } : state;
|
|
116278
117121
|
var referenceCasing2 = (reference, state) => merge(state.casing, reference.casing);
|
|
116279
117122
|
var renderReferenceTable2 = (reference, state, dialect) => {
|
|
116280
117123
|
const casing = referenceCasing2(reference, state);
|
|
@@ -116287,9 +117130,9 @@ var registerSourceReference2 = (source, tableName, state) => {
|
|
|
116287
117130
|
if (typeof source !== "object" || source === null) {
|
|
116288
117131
|
return;
|
|
116289
117132
|
}
|
|
116290
|
-
if (
|
|
117133
|
+
if (TypeId7 in source) {
|
|
116291
117134
|
const table = source;
|
|
116292
|
-
const tableState = table[
|
|
117135
|
+
const tableState = table[TypeId7];
|
|
116293
117136
|
const casing = casingForTable2(table, state);
|
|
116294
117137
|
const renderedTableName = tableState.kind === "alias" ? tableName : applyCategory(casing, "tables", tableState.baseName);
|
|
116295
117138
|
const columns = new Map(Object.keys(tableState.fields).map((columnName) => [
|
|
@@ -116403,11 +117246,11 @@ var renderCreateTableSql2 = (targetSource, state, dialect, ifNotExists) => {
|
|
|
116403
117246
|
}
|
|
116404
117247
|
const table = targetSource.source;
|
|
116405
117248
|
const tableCasing = casingForTable2(table, state);
|
|
116406
|
-
const fields2 = table[
|
|
117249
|
+
const fields2 = table[TypeId7].fields;
|
|
116407
117250
|
const definitions = Object.entries(fields2).map(([columnName, column]) => renderColumnDefinition2(dialect, state, columnName, column, targetSource.tableName, tableCasing));
|
|
116408
117251
|
const options2 = table[OptionsSymbol];
|
|
116409
117252
|
const tableOptions = Array.isArray(options2) ? options2 : [options2];
|
|
116410
|
-
validateOptions(table[
|
|
117253
|
+
validateOptions(table[TypeId7].name, fields2, tableOptions);
|
|
116411
117254
|
for (const option2 of tableOptions) {
|
|
116412
117255
|
if (typeof option2 !== "object" || option2 === null || !("kind" in option2)) {
|
|
116413
117256
|
continue;
|
|
@@ -116466,8 +117309,8 @@ var renderDropIndexSql2 = (targetSource, ddl, state, dialect) => {
|
|
|
116466
117309
|
throw new Error(`Unsupported ${dialect.name} drop index options`);
|
|
116467
117310
|
}
|
|
116468
117311
|
if (dialect.name === "postgres") {
|
|
116469
|
-
const table2 = typeof targetSource.source === "object" && targetSource.source !== null &&
|
|
116470
|
-
const schemaName = table2?.[
|
|
117312
|
+
const table2 = typeof targetSource.source === "object" && targetSource.source !== null && TypeId7 in targetSource.source ? targetSource.source : undefined;
|
|
117313
|
+
const schemaName = table2?.[TypeId7].schemaName;
|
|
116471
117314
|
const tableCasing2 = table2 === undefined ? state.casing : casingForTable2(table2, state);
|
|
116472
117315
|
const renderedSchemaName = table2 === undefined ? schemaName : casedSchemaName(table2, state);
|
|
116473
117316
|
const renderedIndexName = applyCategory(tableCasing2, "indexes", name);
|
|
@@ -116478,7 +117321,7 @@ var renderDropIndexSql2 = (targetSource, ddl, state, dialect) => {
|
|
|
116478
117321
|
const tableCasing = casingForTable2(table, state);
|
|
116479
117322
|
return `drop index ${dialect.quoteIdentifier(applyCategory(tableCasing, "indexes", name))} on ${renderSourceReference2(targetSource.source, targetSource.tableName, targetSource.baseTableName, state, dialect)}`;
|
|
116480
117323
|
};
|
|
116481
|
-
var
|
|
117324
|
+
var isExpression5 = (value) => value !== null && typeof value === "object" && (TypeId in value);
|
|
116482
117325
|
var isJsonDbType3 = (dbType) => {
|
|
116483
117326
|
if (dbType.kind === "jsonb" || dbType.kind === "json") {
|
|
116484
117327
|
return true;
|
|
@@ -116489,7 +117332,7 @@ var isJsonDbType3 = (dbType) => {
|
|
|
116489
117332
|
const variant = dbType.variant;
|
|
116490
117333
|
return variant === "json" || variant === "jsonb";
|
|
116491
117334
|
};
|
|
116492
|
-
var
|
|
117335
|
+
var isJsonExpression3 = (value) => isExpression5(value) && isJsonDbType3(value[TypeId].dbType);
|
|
116493
117336
|
var expectValueExpression2 = (_functionName, value) => value;
|
|
116494
117337
|
var expectBinaryExpressions2 = (_functionName, left, right) => [left, right];
|
|
116495
117338
|
var renderBinaryExpression2 = (functionName, operator, left, right, state, dialect) => {
|
|
@@ -116536,7 +117379,7 @@ var unsupportedJsonFeature2 = (dialect, feature) => {
|
|
|
116536
117379
|
throw error;
|
|
116537
117380
|
};
|
|
116538
117381
|
var extractJsonBase2 = (node) => node.value ?? node.base ?? node.input ?? node.left ?? node.target;
|
|
116539
|
-
var isJsonPathValue3 = (value) => value !== null && typeof value === "object" && (
|
|
117382
|
+
var isJsonPathValue3 = (value) => value !== null && typeof value === "object" && (TypeId3 in value);
|
|
116540
117383
|
var isOptionalJsonPathNumber2 = (value) => value === undefined || typeof value === "number" && Number.isFinite(value);
|
|
116541
117384
|
var isJsonPathSegment2 = (segment) => {
|
|
116542
117385
|
if (typeof segment === "string") {
|
|
@@ -116552,8 +117395,8 @@ var isJsonPathSegment2 = (segment) => {
|
|
|
116552
117395
|
case "key":
|
|
116553
117396
|
return typeof segment.key === "string";
|
|
116554
117397
|
case "index": {
|
|
116555
|
-
const
|
|
116556
|
-
return typeof
|
|
117398
|
+
const index4 = segment.index;
|
|
117399
|
+
return typeof index4 === "number" && Number.isFinite(index4);
|
|
116557
117400
|
}
|
|
116558
117401
|
case "wildcard":
|
|
116559
117402
|
case "descend":
|
|
@@ -116574,12 +117417,12 @@ var validateJsonPathSegments2 = (segments) => {
|
|
|
116574
117417
|
return segments;
|
|
116575
117418
|
};
|
|
116576
117419
|
var extractJsonPathSegments2 = (node) => {
|
|
116577
|
-
const
|
|
116578
|
-
if (isJsonPathValue3(
|
|
116579
|
-
return validateJsonPathSegments2(
|
|
117420
|
+
const path2 = node.path ?? node.segments ?? node.keys;
|
|
117421
|
+
if (isJsonPathValue3(path2)) {
|
|
117422
|
+
return validateJsonPathSegments2(path2.segments);
|
|
116580
117423
|
}
|
|
116581
|
-
if (Array.isArray(
|
|
116582
|
-
return validateJsonPathSegments2(
|
|
117424
|
+
if (Array.isArray(path2)) {
|
|
117425
|
+
return validateJsonPathSegments2(path2);
|
|
116583
117426
|
}
|
|
116584
117427
|
if (node.segments !== undefined) {
|
|
116585
117428
|
return validateJsonPathSegments2(node.segments);
|
|
@@ -116593,7 +117436,7 @@ var extractJsonPathSegments2 = (node) => {
|
|
|
116593
117436
|
return [key(segment)];
|
|
116594
117437
|
}
|
|
116595
117438
|
if (typeof segment === "number") {
|
|
116596
|
-
return [
|
|
117439
|
+
return [index(segment)];
|
|
116597
117440
|
}
|
|
116598
117441
|
if (segment !== null && typeof segment === "object" && SegmentTypeId in segment) {
|
|
116599
117442
|
return [segment];
|
|
@@ -116631,11 +117474,11 @@ var renderJsonPathSegment2 = (segment) => {
|
|
|
116631
117474
|
}
|
|
116632
117475
|
};
|
|
116633
117476
|
var renderJsonPathStringLiteral2 = (segments) => {
|
|
116634
|
-
let
|
|
117477
|
+
let path2 = "$";
|
|
116635
117478
|
for (const segment of segments) {
|
|
116636
|
-
|
|
117479
|
+
path2 += renderJsonPathSegment2(segment);
|
|
116637
117480
|
}
|
|
116638
|
-
return
|
|
117481
|
+
return path2;
|
|
116639
117482
|
};
|
|
116640
117483
|
var renderMySqlJsonPath2 = (segments, state, dialect) => dialect.renderLiteral(renderJsonPathStringLiteral2(segments), state);
|
|
116641
117484
|
var renderPostgresJsonPathArray2 = (segments, state, dialect) => `array[${segments.map((segment) => {
|
|
@@ -116666,7 +117509,7 @@ var renderPostgresJsonAccessStep2 = (segment, textMode, state, dialect) => {
|
|
|
116666
117509
|
}
|
|
116667
117510
|
};
|
|
116668
117511
|
var renderPostgresJsonValue2 = (value, state, dialect) => {
|
|
116669
|
-
if (!
|
|
117512
|
+
if (!isExpression5(value)) {
|
|
116670
117513
|
throw new Error("Expected a JSON expression");
|
|
116671
117514
|
}
|
|
116672
117515
|
const rendered = renderExpression2(value, state, dialect);
|
|
@@ -116710,7 +117553,7 @@ var renderJsonOpaquePath2 = (value, state, dialect) => {
|
|
|
116710
117553
|
}
|
|
116711
117554
|
return dialect.renderLiteral(value, state);
|
|
116712
117555
|
}
|
|
116713
|
-
if (
|
|
117556
|
+
if (isExpression5(value)) {
|
|
116714
117557
|
const ast = value[TypeId2];
|
|
116715
117558
|
if (ast.kind === "literal" && typeof ast.value === "string" && ast.value.trim().length === 0) {
|
|
116716
117559
|
throw new Error("SQL/JSON path input must be a non-empty string");
|
|
@@ -116760,8 +117603,8 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116760
117603
|
const base = extractJsonBase2(ast);
|
|
116761
117604
|
const segments = extractJsonPathSegments2(ast);
|
|
116762
117605
|
const exact = segments.every((segment) => segment.kind === "key" || segment.kind === "index");
|
|
116763
|
-
const postgresExpressionKind = dialect.name === "postgres" &&
|
|
116764
|
-
const postgresBaseKind = dialect.name === "postgres" &&
|
|
117606
|
+
const postgresExpressionKind = dialect.name === "postgres" && isJsonExpression3(expression) ? renderPostgresJsonKind2(expression) : undefined;
|
|
117607
|
+
const postgresBaseKind = dialect.name === "postgres" && isJsonExpression3(base) ? renderPostgresJsonKind2(base) : undefined;
|
|
116765
117608
|
switch (kind) {
|
|
116766
117609
|
case "jsonGet":
|
|
116767
117610
|
case "jsonPath":
|
|
@@ -116771,7 +117614,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116771
117614
|
case "jsonPathText":
|
|
116772
117615
|
case "jsonAccessText":
|
|
116773
117616
|
case "jsonTraverseText": {
|
|
116774
|
-
if (!
|
|
117617
|
+
if (!isExpression5(base) || segments.length === 0) {
|
|
116775
117618
|
return;
|
|
116776
117619
|
}
|
|
116777
117620
|
const baseSql = renderExpression2(base, state, dialect);
|
|
@@ -116794,24 +117637,24 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116794
117637
|
case "jsonKeyExists":
|
|
116795
117638
|
case "jsonHasAnyKeys":
|
|
116796
117639
|
case "jsonHasAllKeys": {
|
|
116797
|
-
if (!
|
|
117640
|
+
if (!isExpression5(base)) {
|
|
116798
117641
|
return;
|
|
116799
117642
|
}
|
|
116800
117643
|
const baseSql = dialect.name === "postgres" ? renderPostgresJsonValue2(base, state, dialect) : renderExpression2(base, state, dialect);
|
|
116801
|
-
const
|
|
116802
|
-
if (
|
|
117644
|
+
const keys = extractJsonKeys2(ast, segments);
|
|
117645
|
+
if (keys.length === 0) {
|
|
116803
117646
|
return;
|
|
116804
117647
|
}
|
|
116805
|
-
if (
|
|
117648
|
+
if (keys.some((key2) => typeof key2 !== "string" || key2.length === 0)) {
|
|
116806
117649
|
throw new Error("json key predicates require string keys");
|
|
116807
117650
|
}
|
|
116808
|
-
const keyNames =
|
|
117651
|
+
const keyNames = keys;
|
|
116809
117652
|
if (dialect.name === "postgres") {
|
|
116810
117653
|
if (kind === "jsonHasAnyKeys") {
|
|
116811
|
-
return `(${baseSql} ?| array[${keyNames.map((
|
|
117654
|
+
return `(${baseSql} ?| array[${keyNames.map((key2) => renderPostgresTextLiteral2(key2, state, dialect)).join(", ")}])`;
|
|
116812
117655
|
}
|
|
116813
117656
|
if (kind === "jsonHasAllKeys") {
|
|
116814
|
-
return `(${baseSql} ?& array[${keyNames.map((
|
|
117657
|
+
return `(${baseSql} ?& array[${keyNames.map((key2) => renderPostgresTextLiteral2(key2, state, dialect)).join(", ")}])`;
|
|
116815
117658
|
}
|
|
116816
117659
|
return `(${baseSql} ? ${renderPostgresTextLiteral2(keyNames[0], state, dialect)})`;
|
|
116817
117660
|
}
|
|
@@ -116824,7 +117667,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116824
117667
|
}
|
|
116825
117668
|
case "jsonConcat":
|
|
116826
117669
|
case "jsonMerge": {
|
|
116827
|
-
if (!
|
|
117670
|
+
if (!isExpression5(ast.left) || !isExpression5(ast.right)) {
|
|
116828
117671
|
return;
|
|
116829
117672
|
}
|
|
116830
117673
|
if (dialect.name === "postgres") {
|
|
@@ -116861,7 +117704,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116861
117704
|
return;
|
|
116862
117705
|
}
|
|
116863
117706
|
case "jsonToJson":
|
|
116864
|
-
if (!
|
|
117707
|
+
if (!isExpression5(base)) {
|
|
116865
117708
|
return;
|
|
116866
117709
|
}
|
|
116867
117710
|
if (dialect.name === "postgres") {
|
|
@@ -116872,7 +117715,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116872
117715
|
}
|
|
116873
117716
|
return;
|
|
116874
117717
|
case "jsonToJsonb":
|
|
116875
|
-
if (!
|
|
117718
|
+
if (!isExpression5(base)) {
|
|
116876
117719
|
return;
|
|
116877
117720
|
}
|
|
116878
117721
|
if (dialect.name === "postgres") {
|
|
@@ -116883,7 +117726,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116883
117726
|
}
|
|
116884
117727
|
return;
|
|
116885
117728
|
case "jsonTypeOf":
|
|
116886
|
-
if (!
|
|
117729
|
+
if (!isExpression5(base)) {
|
|
116887
117730
|
return;
|
|
116888
117731
|
}
|
|
116889
117732
|
if (dialect.name === "postgres") {
|
|
@@ -116895,7 +117738,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116895
117738
|
}
|
|
116896
117739
|
return;
|
|
116897
117740
|
case "jsonLength":
|
|
116898
|
-
if (!
|
|
117741
|
+
if (!isExpression5(base)) {
|
|
116899
117742
|
return;
|
|
116900
117743
|
}
|
|
116901
117744
|
if (dialect.name === "postgres") {
|
|
@@ -116910,7 +117753,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116910
117753
|
}
|
|
116911
117754
|
return;
|
|
116912
117755
|
case "jsonKeys":
|
|
116913
|
-
if (!
|
|
117756
|
+
if (!isExpression5(base)) {
|
|
116914
117757
|
return;
|
|
116915
117758
|
}
|
|
116916
117759
|
if (dialect.name === "postgres") {
|
|
@@ -116924,7 +117767,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116924
117767
|
}
|
|
116925
117768
|
return;
|
|
116926
117769
|
case "jsonStripNulls":
|
|
116927
|
-
if (!
|
|
117770
|
+
if (!isExpression5(base)) {
|
|
116928
117771
|
return;
|
|
116929
117772
|
}
|
|
116930
117773
|
if (dialect.name === "postgres") {
|
|
@@ -116935,7 +117778,7 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116935
117778
|
case "jsonDelete":
|
|
116936
117779
|
case "jsonDeletePath":
|
|
116937
117780
|
case "jsonRemove": {
|
|
116938
|
-
if (!
|
|
117781
|
+
if (!isExpression5(base) || segments.length === 0) {
|
|
116939
117782
|
return;
|
|
116940
117783
|
}
|
|
116941
117784
|
if (dialect.name === "postgres") {
|
|
@@ -116953,11 +117796,11 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116953
117796
|
}
|
|
116954
117797
|
case "jsonSet":
|
|
116955
117798
|
case "jsonInsert": {
|
|
116956
|
-
if (!
|
|
117799
|
+
if (!isExpression5(base) || segments.length === 0) {
|
|
116957
117800
|
return;
|
|
116958
117801
|
}
|
|
116959
117802
|
const nextValue = extractJsonValue2(ast);
|
|
116960
|
-
if (!
|
|
117803
|
+
if (!isExpression5(nextValue)) {
|
|
116961
117804
|
return;
|
|
116962
117805
|
}
|
|
116963
117806
|
const createMissing = ast.createMissing === true;
|
|
@@ -116974,39 +117817,39 @@ var renderJsonExpression2 = (expression, ast, state, dialect) => {
|
|
|
116974
117817
|
return;
|
|
116975
117818
|
}
|
|
116976
117819
|
case "jsonPathExists": {
|
|
116977
|
-
if (!
|
|
117820
|
+
if (!isExpression5(base)) {
|
|
116978
117821
|
return;
|
|
116979
117822
|
}
|
|
116980
|
-
const
|
|
116981
|
-
if (
|
|
117823
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
117824
|
+
if (path2 === undefined) {
|
|
116982
117825
|
return;
|
|
116983
117826
|
}
|
|
116984
117827
|
if (dialect.name === "postgres") {
|
|
116985
|
-
return `(${renderPostgresJsonValue2(base, state, dialect)} @? ${renderJsonOpaquePath2(
|
|
117828
|
+
return `(${renderPostgresJsonValue2(base, state, dialect)} @? ${renderJsonOpaquePath2(path2, state, dialect)})`;
|
|
116986
117829
|
}
|
|
116987
117830
|
if (dialect.name === "mysql") {
|
|
116988
|
-
return `json_contains_path(${renderExpression2(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath2(
|
|
117831
|
+
return `json_contains_path(${renderExpression2(base, state, dialect)}, ${dialect.renderLiteral("one", state)}, ${renderJsonOpaquePath2(path2, state, dialect)})`;
|
|
116989
117832
|
}
|
|
116990
117833
|
return;
|
|
116991
117834
|
}
|
|
116992
117835
|
case "jsonPathMatch": {
|
|
116993
|
-
if (!
|
|
117836
|
+
if (!isExpression5(base)) {
|
|
116994
117837
|
return;
|
|
116995
117838
|
}
|
|
116996
|
-
const
|
|
116997
|
-
if (
|
|
117839
|
+
const path2 = ast.path ?? ast.query ?? ast.right;
|
|
117840
|
+
if (path2 === undefined) {
|
|
116998
117841
|
return;
|
|
116999
117842
|
}
|
|
117000
117843
|
if (dialect.name === "postgres") {
|
|
117001
|
-
return `(${renderPostgresJsonValue2(base, state, dialect)} @@ ${renderJsonOpaquePath2(
|
|
117844
|
+
return `(${renderPostgresJsonValue2(base, state, dialect)} @@ ${renderJsonOpaquePath2(path2, state, dialect)})`;
|
|
117002
117845
|
}
|
|
117003
117846
|
unsupportedJsonFeature2(dialect, "jsonPathMatch");
|
|
117004
117847
|
}
|
|
117005
117848
|
}
|
|
117006
117849
|
return;
|
|
117007
117850
|
};
|
|
117008
|
-
var selectionProjections2 = (selection) => flattenSelection(selection).map(({ path:
|
|
117009
|
-
path:
|
|
117851
|
+
var selectionProjections2 = (selection) => flattenSelection(selection).map(({ path: path2, alias: alias2 }) => ({
|
|
117852
|
+
path: path2,
|
|
117010
117853
|
alias: alias2
|
|
117011
117854
|
}));
|
|
117012
117855
|
var renderMutationAssignment2 = (entry, state, dialect, targetTableName) => {
|
|
@@ -117087,9 +117930,9 @@ var validateDistinctOnOrdering = (distinctOn2, orderBy2) => {
|
|
|
117087
117930
|
}
|
|
117088
117931
|
const remainingDistinctKeys = new Set(distinctOn2.map(groupingKeyOfExpression));
|
|
117089
117932
|
for (const order of orderBy2) {
|
|
117090
|
-
const
|
|
117091
|
-
if (remainingDistinctKeys.has(
|
|
117092
|
-
remainingDistinctKeys.delete(
|
|
117933
|
+
const key2 = groupingKeyOfExpression(order.value);
|
|
117934
|
+
if (remainingDistinctKeys.has(key2)) {
|
|
117935
|
+
remainingDistinctKeys.delete(key2);
|
|
117093
117936
|
continue;
|
|
117094
117937
|
}
|
|
117095
117938
|
if (remainingDistinctKeys.size > 0) {
|
|
@@ -117184,12 +118027,12 @@ var renderQueryAst2 = (ast, state, dialect, options2 = {}) => {
|
|
|
117184
118027
|
const columns = insertSource.columns.map((column) => quoteColumn2(column, state, dialect, targetSource.tableName)).join(", ");
|
|
117185
118028
|
if (dialect.name === "postgres") {
|
|
117186
118029
|
const table = targetSource.source;
|
|
117187
|
-
const fields2 = table[
|
|
118030
|
+
const fields2 = table[TypeId7].fields;
|
|
117188
118031
|
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
118032
|
sql += ` (${columns}) select * from unnest(${rendered})`;
|
|
117190
118033
|
} else {
|
|
117191
118034
|
const rowCount = insertSource.values[0]?.values.length ?? 0;
|
|
117192
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
118035
|
+
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
118036
|
sql += ` (${columns}) values ${rows}`;
|
|
117194
118037
|
}
|
|
117195
118038
|
} else {
|
|
@@ -117343,27 +118186,27 @@ var renderQueryAst2 = (ast, state, dialect, options2 = {}) => {
|
|
|
117343
118186
|
const mergeAst = ast;
|
|
117344
118187
|
const targetSource = mergeAst.target;
|
|
117345
118188
|
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 =
|
|
118189
|
+
const merge2 = mergeAst.merge;
|
|
118190
|
+
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)}`;
|
|
118191
|
+
if (merge2.whenMatched) {
|
|
118192
|
+
const matchedKind = merge2.whenMatched.kind === "delete" ? "delete" : "update";
|
|
117350
118193
|
sql += " when matched";
|
|
117351
|
-
if (
|
|
117352
|
-
sql += ` and ${renderExpression2(
|
|
118194
|
+
if (merge2.whenMatched.predicate) {
|
|
118195
|
+
sql += ` and ${renderExpression2(merge2.whenMatched.predicate, state, dialect)}`;
|
|
117353
118196
|
}
|
|
117354
118197
|
if (matchedKind === "delete") {
|
|
117355
118198
|
sql += " then delete";
|
|
117356
118199
|
} else {
|
|
117357
|
-
const matchedUpdate =
|
|
118200
|
+
const matchedUpdate = merge2.whenMatched;
|
|
117358
118201
|
sql += ` then update set ${matchedUpdate.values.map((entry) => `${quoteColumn2(entry.columnName, state, dialect, targetSource.tableName)} = ${renderExpression2(entry.value, state, dialect)}`).join(", ")}`;
|
|
117359
118202
|
}
|
|
117360
118203
|
}
|
|
117361
|
-
if (
|
|
118204
|
+
if (merge2.whenNotMatched) {
|
|
117362
118205
|
sql += " when not matched";
|
|
117363
|
-
if (
|
|
117364
|
-
sql += ` and ${renderExpression2(
|
|
118206
|
+
if (merge2.whenNotMatched.predicate) {
|
|
118207
|
+
sql += ` and ${renderExpression2(merge2.whenNotMatched.predicate, state, dialect)}`;
|
|
117365
118208
|
}
|
|
117366
|
-
sql += ` then insert (${
|
|
118209
|
+
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
118210
|
}
|
|
117368
118211
|
break;
|
|
117369
118212
|
}
|
|
@@ -117427,7 +118270,7 @@ var renderSourceReference2 = (source, tableName, baseTableName, state, dialect)
|
|
|
117427
118270
|
};
|
|
117428
118271
|
const renderUnnestRows = (arrays, columnNames) => {
|
|
117429
118272
|
const rowCount = arrays[columnNames[0]].length;
|
|
117430
|
-
const rows = Array.from({ length: rowCount }, (_,
|
|
118273
|
+
const rows = Array.from({ length: rowCount }, (_, index4) => Object.fromEntries(columnNames.map((columnName) => [columnName, arrays[columnName][index4]])));
|
|
117431
118274
|
return renderSelectRows(rows, columnNames);
|
|
117432
118275
|
};
|
|
117433
118276
|
if (typeof source === "object" && source !== null && "kind" in source && source.kind === "cte") {
|
|
@@ -117477,11 +118320,11 @@ var renderSourceReference2 = (source, tableName, baseTableName, state, dialect)
|
|
|
117477
118320
|
const columnNames = Object.keys(tableFunction.columns);
|
|
117478
118321
|
return `${functionName}(${tableFunction.args.map((arg) => renderExpression2(arg, state, dialect)).join(", ")}) as ${dialect.quoteIdentifier(tableFunction.name)}(${columnNames.map((columnName) => dialect.quoteIdentifier(columnName)).join(", ")})`;
|
|
117479
118322
|
}
|
|
117480
|
-
const schemaName = typeof source === "object" && source !== null &&
|
|
117481
|
-
if (typeof source === "object" && source !== null &&
|
|
118323
|
+
const schemaName = typeof source === "object" && source !== null && TypeId7 in source ? casedSchemaName(source, state) : undefined;
|
|
118324
|
+
if (typeof source === "object" && source !== null && TypeId7 in source) {
|
|
117482
118325
|
const table = source;
|
|
117483
118326
|
const renderedBaseName = casedTableName(table, state);
|
|
117484
|
-
const renderedTableName = table[
|
|
118327
|
+
const renderedTableName = table[TypeId7].kind === "alias" ? tableName : renderedBaseName;
|
|
117485
118328
|
return dialect.renderTableReference(renderedTableName, renderedBaseName, schemaName);
|
|
117486
118329
|
}
|
|
117487
118330
|
return dialect.renderTableReference(applyCategory(state.casing, "tables", tableName), applyCategory(state.casing, "tables", baseTableName), schemaName);
|
|
@@ -117588,11 +118431,11 @@ var renderExpression2 = (expression, state, dialect) => {
|
|
|
117588
118431
|
const [leftExpression, rightExpression] = expectBinaryExpressions2("contains", ast.left, ast.right);
|
|
117589
118432
|
if (dialect.name === "postgres") {
|
|
117590
118433
|
assertCompatiblePostgresRangeOperands(leftExpression, rightExpression);
|
|
117591
|
-
const left =
|
|
117592
|
-
const right =
|
|
118434
|
+
const left = isJsonExpression3(leftExpression) ? renderPostgresJsonValue2(leftExpression, state, dialect) : renderExpression2(leftExpression, state, dialect);
|
|
118435
|
+
const right = isJsonExpression3(rightExpression) ? renderPostgresJsonValue2(rightExpression, state, dialect) : renderExpression2(rightExpression, state, dialect);
|
|
117593
118436
|
return `(${left} @> ${right})`;
|
|
117594
118437
|
}
|
|
117595
|
-
if (dialect.name === "mysql" &&
|
|
118438
|
+
if (dialect.name === "mysql" && isJsonExpression3(leftExpression) && isJsonExpression3(rightExpression)) {
|
|
117596
118439
|
return `json_contains(${renderExpression2(leftExpression, state, dialect)}, ${renderExpression2(rightExpression, state, dialect)})`;
|
|
117597
118440
|
}
|
|
117598
118441
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -117601,11 +118444,11 @@ var renderExpression2 = (expression, state, dialect) => {
|
|
|
117601
118444
|
const [leftExpression, rightExpression] = expectBinaryExpressions2("containedBy", ast.left, ast.right);
|
|
117602
118445
|
if (dialect.name === "postgres") {
|
|
117603
118446
|
assertCompatiblePostgresRangeOperands(leftExpression, rightExpression);
|
|
117604
|
-
const left =
|
|
117605
|
-
const right =
|
|
118447
|
+
const left = isJsonExpression3(leftExpression) ? renderPostgresJsonValue2(leftExpression, state, dialect) : renderExpression2(leftExpression, state, dialect);
|
|
118448
|
+
const right = isJsonExpression3(rightExpression) ? renderPostgresJsonValue2(rightExpression, state, dialect) : renderExpression2(rightExpression, state, dialect);
|
|
117606
118449
|
return `(${left} <@ ${right})`;
|
|
117607
118450
|
}
|
|
117608
|
-
if (dialect.name === "mysql" &&
|
|
118451
|
+
if (dialect.name === "mysql" && isJsonExpression3(leftExpression) && isJsonExpression3(rightExpression)) {
|
|
117609
118452
|
return `json_contains(${renderExpression2(rightExpression, state, dialect)}, ${renderExpression2(leftExpression, state, dialect)})`;
|
|
117610
118453
|
}
|
|
117611
118454
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -117614,11 +118457,11 @@ var renderExpression2 = (expression, state, dialect) => {
|
|
|
117614
118457
|
const [leftExpression, rightExpression] = expectBinaryExpressions2("overlaps", ast.left, ast.right);
|
|
117615
118458
|
if (dialect.name === "postgres") {
|
|
117616
118459
|
assertCompatiblePostgresRangeOperands(leftExpression, rightExpression);
|
|
117617
|
-
const left =
|
|
117618
|
-
const right =
|
|
118460
|
+
const left = isJsonExpression3(leftExpression) ? renderPostgresJsonValue2(leftExpression, state, dialect) : renderExpression2(leftExpression, state, dialect);
|
|
118461
|
+
const right = isJsonExpression3(rightExpression) ? renderPostgresJsonValue2(rightExpression, state, dialect) : renderExpression2(rightExpression, state, dialect);
|
|
117619
118462
|
return `(${left} && ${right})`;
|
|
117620
118463
|
}
|
|
117621
|
-
if (dialect.name === "mysql" &&
|
|
118464
|
+
if (dialect.name === "mysql" && isJsonExpression3(leftExpression) && isJsonExpression3(rightExpression)) {
|
|
117622
118465
|
return `json_overlaps(${renderExpression2(leftExpression, state, dialect)}, ${renderExpression2(rightExpression, state, dialect)})`;
|
|
117623
118466
|
}
|
|
117624
118467
|
throw new Error("Unsupported container operator for SQL rendering");
|
|
@@ -117799,7 +118642,6 @@ var renderMysqlPlan = (plan, options2 = {}) => {
|
|
|
117799
118642
|
|
|
117800
118643
|
// src/mysql/executor.ts
|
|
117801
118644
|
var withTransaction2 = withTransaction;
|
|
117802
|
-
var withSavepoint2 = withSavepoint;
|
|
117803
118645
|
function driver2(executeOrHandlers) {
|
|
117804
118646
|
return driver("mysql", executeOrHandlers);
|
|
117805
118647
|
}
|
|
@@ -117820,8 +118662,8 @@ var fromDriver2 = (renderer, sqlDriver, driverMode = "raw", valueMappings) => ({
|
|
|
117820
118662
|
},
|
|
117821
118663
|
stream(plan) {
|
|
117822
118664
|
const rendered = renderer.render(plan);
|
|
117823
|
-
return Stream2.mapError(Stream2.
|
|
117824
|
-
try: () =>
|
|
118665
|
+
return Stream2.mapError(Stream2.mapArrayEffect(sqlDriver.stream(rendered), (rows) => Effect2.try({
|
|
118666
|
+
try: () => decodeRows(rendered, plan, rows, { driverMode, valueMappings }),
|
|
117825
118667
|
catch: (error) => error
|
|
117826
118668
|
})), (error) => {
|
|
117827
118669
|
if (typeof error === "object" && error !== null && "_tag" in error && error._tag === "RowDecodeError") {
|
|
@@ -117857,6 +118699,32 @@ __export(exports_query_extension, {
|
|
|
117857
118699
|
var ignore = lock("ignore");
|
|
117858
118700
|
var quick = lock("quick");
|
|
117859
118701
|
var lowPriority = lock("lowPriority");
|
|
118702
|
+
// src/mysql/type.ts
|
|
118703
|
+
var enum_2 = (kind) => ({
|
|
118704
|
+
dialect: "mysql",
|
|
118705
|
+
kind,
|
|
118706
|
+
variant: "enum"
|
|
118707
|
+
});
|
|
118708
|
+
var set2 = (kind) => ({
|
|
118709
|
+
dialect: "mysql",
|
|
118710
|
+
kind,
|
|
118711
|
+
variant: "set"
|
|
118712
|
+
});
|
|
118713
|
+
var custom4 = (kind) => ({
|
|
118714
|
+
dialect: "mysql",
|
|
118715
|
+
kind
|
|
118716
|
+
});
|
|
118717
|
+
var driverValueMapping3 = (dbType, mapping) => ({
|
|
118718
|
+
...dbType,
|
|
118719
|
+
driverValueMapping: mapping
|
|
118720
|
+
});
|
|
118721
|
+
var type2 = {
|
|
118722
|
+
...pickDatatypeConstructors(mysqlDatatypes, mysqlSpecificDatatypeKeys),
|
|
118723
|
+
enum: enum_2,
|
|
118724
|
+
set: set2,
|
|
118725
|
+
custom: custom4,
|
|
118726
|
+
driverValueMapping: driverValueMapping3
|
|
118727
|
+
};
|
|
117860
118728
|
// src/mysql/renderer.ts
|
|
117861
118729
|
var exports_renderer2 = {};
|
|
117862
118730
|
__export(exports_renderer2, {
|
|
@@ -117864,26 +118732,28 @@ __export(exports_renderer2, {
|
|
|
117864
118732
|
make: () => make5,
|
|
117865
118733
|
TypeId: () => TypeId10
|
|
117866
118734
|
});
|
|
117867
|
-
import { pipeArguments as
|
|
118735
|
+
import { pipeArguments as pipeArguments8 } from "effect/Pipeable";
|
|
117868
118736
|
var RendererProto = {
|
|
117869
118737
|
pipe() {
|
|
117870
|
-
return
|
|
118738
|
+
return pipeArguments8(this, arguments);
|
|
117871
118739
|
}
|
|
117872
118740
|
};
|
|
117873
|
-
var
|
|
117874
|
-
const renderer = makeTrusted("mysql", (plan) => renderMysqlPlan(plan,
|
|
118741
|
+
var makeWithState = (state = {}) => {
|
|
118742
|
+
const renderer = makeTrusted("mysql", (plan) => renderMysqlPlan(plan, state));
|
|
117875
118743
|
return Object.assign(Object.create(RendererProto), renderer, {
|
|
117876
|
-
[
|
|
117877
|
-
casing:
|
|
118744
|
+
[TypeId6]: {
|
|
118745
|
+
casing: state.casing
|
|
117878
118746
|
},
|
|
117879
|
-
withCasing: (override) =>
|
|
117880
|
-
...
|
|
117881
|
-
casing: merge(
|
|
118747
|
+
withCasing: (override) => makeWithState({
|
|
118748
|
+
...state,
|
|
118749
|
+
casing: merge(state.casing, override)
|
|
117882
118750
|
})
|
|
117883
118751
|
});
|
|
117884
118752
|
};
|
|
118753
|
+
var make5 = (options2 = {}) => makeWithState({ valueMappings: options2.valueMappings });
|
|
117885
118754
|
var mysql = make5();
|
|
117886
118755
|
export {
|
|
118756
|
+
type2 as Type,
|
|
117887
118757
|
exports_renderer2 as Renderer,
|
|
117888
118758
|
exports_query_extension as Query,
|
|
117889
118759
|
exports_json as Json,
|