@dbsp/core 6.3.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{assertion-functions-dyf-Q__5.d.ts → assertion-functions-mGgbz4_k.d.ts} +53 -30
- package/dist/{chunk-5UI5IH5U.js → chunk-MVPSYATN.js} +177 -105
- package/dist/chunk-MVPSYATN.js.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-5UI5IH5U.js.map +0 -1
|
@@ -874,7 +874,7 @@ function findDefaultFilterScan(intent, model, filters, path, skipRoot = false, d
|
|
|
874
874
|
if (!filters || !Object.keys(filters).length) return;
|
|
875
875
|
const root = intent;
|
|
876
876
|
let found;
|
|
877
|
-
const
|
|
877
|
+
const refuse2 = (table, location) => {
|
|
878
878
|
if (getDefaultFilter(filters, table) && !found)
|
|
879
879
|
found = { table, path: location };
|
|
880
880
|
};
|
|
@@ -892,38 +892,38 @@ function findDefaultFilterScan(intent, model, filters, path, skipRoot = false, d
|
|
|
892
892
|
if (typeof node.from === "string") {
|
|
893
893
|
source = node.from;
|
|
894
894
|
if (!(skipRoot && value === intent) && !node.batchValuesSource && !derivedRanges.has(source))
|
|
895
|
-
|
|
895
|
+
refuse2(source, `${location}.from`);
|
|
896
896
|
}
|
|
897
897
|
const trusted = getTrustedNqlRelationFilterFields(value);
|
|
898
898
|
if (trusted) {
|
|
899
|
-
|
|
899
|
+
refuse2(trusted.targetTable, `${location}.relation`);
|
|
900
900
|
for (const hop of trusted.hops)
|
|
901
|
-
|
|
902
|
-
if (trusted.through)
|
|
901
|
+
refuse2(hop.target, `${location}.relation`);
|
|
902
|
+
if (trusted.through) refuse2(trusted.through, `${location}.junction`);
|
|
903
903
|
}
|
|
904
904
|
if (typeof node.targetTable === "string")
|
|
905
|
-
|
|
905
|
+
refuse2(node.targetTable, `${location}.targetTable`);
|
|
906
906
|
if (typeof node.table === "string" && !node.batchValues && !derivedRanges.has(node.table))
|
|
907
|
-
|
|
907
|
+
refuse2(node.table, `${location}.table`);
|
|
908
908
|
if (typeof node.relation === "string" || Array.isArray(node.relation)) {
|
|
909
909
|
const segments = Array.isArray(node.relation) ? node.relation : (typeof node.via === "string" ? node.via : node.relation).split(".");
|
|
910
910
|
for (const segment of segments) {
|
|
911
911
|
const relation = model.getRelation(`${source}.${segment}`);
|
|
912
912
|
if (!relation) break;
|
|
913
913
|
source = relation.target;
|
|
914
|
-
|
|
915
|
-
if (relation.through)
|
|
914
|
+
refuse2(source, `${location}.relation`);
|
|
915
|
+
if (relation.through) refuse2(relation.through, `${location}.junction`);
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
918
|
if (node.kind === "pseudoColumn")
|
|
919
|
-
|
|
919
|
+
refuse2(source, `${location}.pseudoColumn`);
|
|
920
920
|
if (typeof node.field === "string" && node.field.includes(".")) {
|
|
921
921
|
let table = source;
|
|
922
922
|
for (const segment of node.field.split(".").slice(0, -1)) {
|
|
923
923
|
const relation = model.getRelation(`${table}.${segment}`);
|
|
924
924
|
if (!relation) break;
|
|
925
925
|
table = relation.target;
|
|
926
|
-
|
|
926
|
+
refuse2(table, `${location}.field`);
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
929
|
for (const [key, child] of Object.entries(node)) {
|
|
@@ -955,7 +955,7 @@ function assertUnsupportedNqlDefaultFilters(intent, model, filters, path) {
|
|
|
955
955
|
...bundle.bindings?.keys() ?? [],
|
|
956
956
|
...bundle.cteQuery?.ctes.map((cte) => cte.name) ?? []
|
|
957
957
|
]);
|
|
958
|
-
const
|
|
958
|
+
const refuse2 = (table, location) => {
|
|
959
959
|
if (getDefaultFilter(filters, table))
|
|
960
960
|
throw new Error(
|
|
961
961
|
`Default filter for table '${table}' is not supported at ${location}.`
|
|
@@ -987,22 +987,22 @@ function assertUnsupportedNqlDefaultFilters(intent, model, filters, path) {
|
|
|
987
987
|
return;
|
|
988
988
|
if (typeof node.from === "string") source = node.from;
|
|
989
989
|
const trusted = getTrustedNqlRelationFilterFields(value);
|
|
990
|
-
if (trusted?.through)
|
|
990
|
+
if (trusted?.through) refuse2(trusted.through, `${location}.junction`);
|
|
991
991
|
if (node.kind === "relationColumn" && trusted) {
|
|
992
|
-
|
|
992
|
+
refuse2(trusted.targetTable, `${location}.relation`);
|
|
993
993
|
for (const hop of trusted.hops)
|
|
994
|
-
|
|
994
|
+
refuse2(hop.target, `${location}.relation`);
|
|
995
995
|
}
|
|
996
996
|
if (node.kind === "pseudoColumn")
|
|
997
|
-
|
|
997
|
+
refuse2(trusted?.targetTable ?? source, `${location}.pseudoColumn`);
|
|
998
998
|
if (typeof node.relation === "string" || Array.isArray(node.relation)) {
|
|
999
999
|
const segments = Array.isArray(node.relation) ? node.relation : (typeof node.via === "string" ? node.via : node.relation).split(".");
|
|
1000
1000
|
for (const segment of segments) {
|
|
1001
1001
|
const relation = model.getRelation(`${source}.${segment}`);
|
|
1002
1002
|
if (!relation) break;
|
|
1003
1003
|
if (locals.has(relation.target))
|
|
1004
|
-
|
|
1005
|
-
if (relation.through)
|
|
1004
|
+
refuse2(relation.target, `${location}.relation`);
|
|
1005
|
+
if (relation.through) refuse2(relation.through, `${location}.junction`);
|
|
1006
1006
|
source = relation.target;
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
@@ -2397,12 +2397,12 @@ function validateRecursiveIncludeStrategy(include, relation, intentPath, fullPat
|
|
|
2397
2397
|
);
|
|
2398
2398
|
if (inSetOperation)
|
|
2399
2399
|
throw new Error("Recursive include option set operations is not supported");
|
|
2400
|
-
const
|
|
2400
|
+
const refuse2 = (name) => {
|
|
2401
2401
|
throw new Error(`Recursive include option ${name} is not supported`);
|
|
2402
2402
|
};
|
|
2403
2403
|
if (intentPath.includes(".include["))
|
|
2404
|
-
|
|
2405
|
-
if (include.include !== void 0)
|
|
2404
|
+
refuse2("include does not support nested recursive includes");
|
|
2405
|
+
if (include.include !== void 0) refuse2("include");
|
|
2406
2406
|
for (const [name, value] of Object.entries({
|
|
2407
2407
|
where: include.where,
|
|
2408
2408
|
limit: include.limit,
|
|
@@ -2410,9 +2410,9 @@ function validateRecursiveIncludeStrategy(include, relation, intentPath, fullPat
|
|
|
2410
2410
|
foreignKey: include.recursive?.foreignKey,
|
|
2411
2411
|
"track.path": include.recursive?.track?.path
|
|
2412
2412
|
}))
|
|
2413
|
-
if (value !== void 0)
|
|
2413
|
+
if (value !== void 0) refuse2(name);
|
|
2414
2414
|
if (include.recursive?.track?.depth && typeof include.recursive.track.depth !== "boolean")
|
|
2415
|
-
|
|
2415
|
+
refuse2("track.depth.as");
|
|
2416
2416
|
if (include.recursive?.direction !== void 0 && !["ancestors", "descendants"].includes(include.recursive.direction))
|
|
2417
2417
|
throw new Error(
|
|
2418
2418
|
"Recursive include option direction must be ancestors or descendants"
|
|
@@ -2423,7 +2423,7 @@ function validateRecursiveIncludeStrategy(include, relation, intentPath, fullPat
|
|
|
2423
2423
|
"Recursive include option maxDepth must be a positive integer at most 2147483647"
|
|
2424
2424
|
);
|
|
2425
2425
|
if (include.select && include.select.type !== "fields" && include.select.type !== "all")
|
|
2426
|
-
|
|
2426
|
+
refuse2("select supports only fields or all");
|
|
2427
2427
|
if (include.select?.type === "fields" && include.select.fields.length === 0)
|
|
2428
2428
|
throw new Error(
|
|
2429
2429
|
"Recursive include option select requires at least one field"
|
|
@@ -2440,10 +2440,10 @@ function validateRecursiveIncludeStrategy(include, relation, intentPath, fullPat
|
|
|
2440
2440
|
);
|
|
2441
2441
|
if (rootIntent) {
|
|
2442
2442
|
if (rootIntent.having || dropsJoinIncludeData({ ...rootIntent, distinct: false }))
|
|
2443
|
-
|
|
2443
|
+
refuse2("grouped or aggregated roots");
|
|
2444
2444
|
if (rootIntent.distinct && !rootIntent.distinctOn?.length)
|
|
2445
|
-
|
|
2446
|
-
if (rootIntent.lock)
|
|
2445
|
+
refuse2("DISTINCT");
|
|
2446
|
+
if (rootIntent.lock) refuse2("row locks");
|
|
2447
2447
|
}
|
|
2448
2448
|
if (relation.includeStrategy !== "auto" && relation.includeStrategy !== "cte")
|
|
2449
2449
|
throw new UnsupportedStrategyError(
|
|
@@ -3154,10 +3154,6 @@ function resolveConditionContext(where, root, visible, enclosing, allocator, mod
|
|
|
3154
3154
|
const caseValue = (value) => {
|
|
3155
3155
|
if (value == null) return { kind: "literal", value: null };
|
|
3156
3156
|
if (typeof value === "string") return ref3(value);
|
|
3157
|
-
if (value && typeof value === "object" && "kind" in value && value.kind === "literal" && "value" in value) {
|
|
3158
|
-
const literal2 = value;
|
|
3159
|
-
return typeof literal2.value === "string" ? { kind: "parameter", value: literal2.value } : { kind: "literal", value: literal2.value };
|
|
3160
|
-
}
|
|
3161
3157
|
return arg(value);
|
|
3162
3158
|
};
|
|
3163
3159
|
switch (input.kind) {
|
|
@@ -3531,15 +3527,15 @@ function resolveConditionContext(where, root, visible, enclosing, allocator, mod
|
|
|
3531
3527
|
}
|
|
3532
3528
|
function assertScanDefaultFilter(condition, range, model) {
|
|
3533
3529
|
const table = range.table;
|
|
3534
|
-
const
|
|
3530
|
+
const refuse2 = (part) => {
|
|
3535
3531
|
throw new Error(part);
|
|
3536
3532
|
};
|
|
3537
3533
|
const column = (operand) => {
|
|
3538
|
-
if (operand.kind === "aggregate")
|
|
3534
|
+
if (operand.kind === "aggregate") refuse2("forbidden operand 'aggregate'");
|
|
3539
3535
|
if (operand.kind !== "column" || operand.range !== range)
|
|
3540
|
-
|
|
3536
|
+
refuse2("forbidden column range or outer reference");
|
|
3541
3537
|
if (model && !model.getTable(table)?.columns.some((column2) => column2.name === operand.column))
|
|
3542
|
-
|
|
3538
|
+
refuse2(`invalid column '${operand.column}'`);
|
|
3543
3539
|
};
|
|
3544
3540
|
const expression = (node, functionArgument = false) => {
|
|
3545
3541
|
switch (node.kind) {
|
|
@@ -3547,7 +3543,7 @@ function assertScanDefaultFilter(condition, range, model) {
|
|
|
3547
3543
|
column(node.operand);
|
|
3548
3544
|
return;
|
|
3549
3545
|
case "wholeRow":
|
|
3550
|
-
if (node.range !== range)
|
|
3546
|
+
if (node.range !== range) refuse2("forbidden whole-row range");
|
|
3551
3547
|
return;
|
|
3552
3548
|
case "call":
|
|
3553
3549
|
node.args.forEach((argument) => {
|
|
@@ -3558,7 +3554,7 @@ function assertScanDefaultFilter(condition, range, model) {
|
|
|
3558
3554
|
expression(order.expression);
|
|
3559
3555
|
});
|
|
3560
3556
|
if (node.aggregate || node.filter || node.orderBy || node.distinct !== void 0)
|
|
3561
|
-
|
|
3557
|
+
refuse2("forbidden aggregate call");
|
|
3562
3558
|
return;
|
|
3563
3559
|
case "operator":
|
|
3564
3560
|
node.operands.forEach((operand) => {
|
|
@@ -3582,7 +3578,7 @@ function assertScanDefaultFilter(condition, range, model) {
|
|
|
3582
3578
|
return;
|
|
3583
3579
|
case "namedArg":
|
|
3584
3580
|
if (!functionArgument)
|
|
3585
|
-
|
|
3581
|
+
refuse2("forbidden operand 'namedArg' outside a function argument");
|
|
3586
3582
|
expression(node.value);
|
|
3587
3583
|
return;
|
|
3588
3584
|
case "literal":
|
|
@@ -3590,14 +3586,14 @@ function assertScanDefaultFilter(condition, range, model) {
|
|
|
3590
3586
|
return;
|
|
3591
3587
|
case "star":
|
|
3592
3588
|
if (!functionArgument)
|
|
3593
|
-
|
|
3589
|
+
refuse2("forbidden operand 'star' outside a function argument");
|
|
3594
3590
|
return;
|
|
3595
3591
|
case "subquery":
|
|
3596
|
-
|
|
3592
|
+
refuse2("forbidden operand 'subquery'");
|
|
3597
3593
|
return;
|
|
3598
3594
|
default: {
|
|
3599
3595
|
const exhaustive = node;
|
|
3600
|
-
|
|
3596
|
+
refuse2(`unsupported expression '${String(exhaustive)}'`);
|
|
3601
3597
|
}
|
|
3602
3598
|
}
|
|
3603
3599
|
};
|
|
@@ -3631,7 +3627,7 @@ function assertScanDefaultFilter(condition, range, model) {
|
|
|
3631
3627
|
case "in":
|
|
3632
3628
|
column(node.left);
|
|
3633
3629
|
if (node.operand.kind !== "values")
|
|
3634
|
-
|
|
3630
|
+
refuse2("forbidden subquery in 'in'");
|
|
3635
3631
|
return;
|
|
3636
3632
|
case "like":
|
|
3637
3633
|
case "any":
|
|
@@ -3642,7 +3638,7 @@ function assertScanDefaultFilter(condition, range, model) {
|
|
|
3642
3638
|
column(node.left);
|
|
3643
3639
|
return;
|
|
3644
3640
|
default:
|
|
3645
|
-
|
|
3641
|
+
refuse2(`forbidden condition kind '${node.kind}'`);
|
|
3646
3642
|
}
|
|
3647
3643
|
};
|
|
3648
3644
|
visit(condition);
|
|
@@ -4812,6 +4808,11 @@ var RELATION_FROM_TABLE = /* @__PURE__ */ Symbol.for(
|
|
|
4812
4808
|
);
|
|
4813
4809
|
var CALLBACK_SCOPE = /* @__PURE__ */ Symbol.for("dbsp:callbackScope");
|
|
4814
4810
|
|
|
4811
|
+
// src/dx/table-ref.ts
|
|
4812
|
+
function isColumnRef(value) {
|
|
4813
|
+
return typeof value === "object" && value !== null && BRAND in value && value[BRAND] === "ColumnRef";
|
|
4814
|
+
}
|
|
4815
|
+
|
|
4815
4816
|
// src/dx/table-ref-factory.ts
|
|
4816
4817
|
var JS_RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
4817
4818
|
// Object built-ins
|
|
@@ -18800,24 +18801,105 @@ function isSqlRaw(value) {
|
|
|
18800
18801
|
}
|
|
18801
18802
|
|
|
18802
18803
|
// src/dx/expressions.ts
|
|
18803
|
-
import { brandValue as brandValue5, EXPRESSION_BRAND as
|
|
18804
|
-
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
|
|
18809
|
-
|
|
18810
|
-
|
|
18804
|
+
import { brandValue as brandValue5, EXPRESSION_BRAND as EXPRESSION_BRAND9, PREDICATE_BRAND } from "@dbsp/types";
|
|
18805
|
+
|
|
18806
|
+
// src/dx/coerce.ts
|
|
18807
|
+
import { EXPRESSION_BRAND as EXPRESSION_BRAND8, NotYetSupportedError as NotYetSupportedError3, REF_BRAND as REF_BRAND3 } from "@dbsp/types";
|
|
18808
|
+
var EXPRESSION_ARGUMENT = "expression argument";
|
|
18809
|
+
function isBrandedExpression(leaf) {
|
|
18810
|
+
return EXPRESSION_BRAND8 in leaf && leaf[EXPRESSION_BRAND8] === true && "intent" in leaf;
|
|
18811
|
+
}
|
|
18812
|
+
function isOuterRef2(leaf) {
|
|
18813
|
+
const candidate = leaf;
|
|
18814
|
+
return candidate.kind === "ref" && candidate.outer === true;
|
|
18815
|
+
}
|
|
18816
|
+
function isQueryBuilder(leaf) {
|
|
18817
|
+
if (leaf instanceof SubqueryBuilder) return true;
|
|
18818
|
+
const candidate = leaf;
|
|
18819
|
+
return typeof candidate.buildIntent === "function" || typeof candidate.buildSubqueryIntent === "function";
|
|
18820
|
+
}
|
|
18821
|
+
function refuse(helper, kind) {
|
|
18822
|
+
throw new InvalidOperationError(
|
|
18823
|
+
helper,
|
|
18824
|
+
`${kind} is not an expression argument; use literal(null), param(value) or an expression`
|
|
18825
|
+
);
|
|
18826
|
+
}
|
|
18827
|
+
function coerceReference(leaf, helper) {
|
|
18828
|
+
switch (typeof leaf) {
|
|
18829
|
+
case "string":
|
|
18830
|
+
return { kind: "ref", column: leaf };
|
|
18831
|
+
case "number":
|
|
18832
|
+
return Number.isFinite(leaf) ? { kind: "literal", value: leaf } : { kind: "param", value: leaf };
|
|
18833
|
+
case "boolean":
|
|
18834
|
+
return { kind: "literal", value: leaf };
|
|
18835
|
+
case "bigint":
|
|
18836
|
+
return leaf >= BigInt(Number.MIN_SAFE_INTEGER) && leaf <= BigInt(Number.MAX_SAFE_INTEGER) ? {
|
|
18837
|
+
kind: "literal",
|
|
18838
|
+
value: Number(leaf)
|
|
18839
|
+
} : { kind: "param", value: leaf };
|
|
18840
|
+
case "undefined":
|
|
18841
|
+
return refuse(helper, "undefined");
|
|
18842
|
+
case "object":
|
|
18843
|
+
break;
|
|
18844
|
+
default:
|
|
18845
|
+
return refuse(helper, `a ${typeof leaf}`);
|
|
18811
18846
|
}
|
|
18812
|
-
if (
|
|
18813
|
-
|
|
18847
|
+
if (leaf === null) return refuse(helper, "null");
|
|
18848
|
+
if (Array.isArray(leaf) || leaf instanceof Date)
|
|
18849
|
+
return { kind: "param", value: leaf };
|
|
18850
|
+
if (isBrandedExpression(leaf)) return leaf.intent;
|
|
18851
|
+
if (isSubqueryExpression(leaf))
|
|
18852
|
+
return {
|
|
18853
|
+
kind: "subquery",
|
|
18854
|
+
query: leaf.intent
|
|
18855
|
+
};
|
|
18856
|
+
if (isColumnRef(leaf)) {
|
|
18857
|
+
if (leaf[CALLBACK_SCOPE] !== void 0)
|
|
18858
|
+
throw new NotYetSupportedError3(
|
|
18859
|
+
"a callback-scoped ColumnRef",
|
|
18860
|
+
EXPRESSION_ARGUMENT,
|
|
18861
|
+
1052
|
|
18862
|
+
);
|
|
18863
|
+
if (isRelationPathColumn(leaf))
|
|
18864
|
+
throw new NotYetSupportedError3(
|
|
18865
|
+
"a relation-reached ColumnRef",
|
|
18866
|
+
EXPRESSION_ARGUMENT,
|
|
18867
|
+
1052
|
|
18868
|
+
);
|
|
18869
|
+
return {
|
|
18870
|
+
kind: "ref",
|
|
18871
|
+
column: getColumnName(leaf)
|
|
18872
|
+
};
|
|
18814
18873
|
}
|
|
18815
|
-
|
|
18874
|
+
if (REF_BRAND3 in leaf)
|
|
18875
|
+
return {
|
|
18876
|
+
kind: "ref",
|
|
18877
|
+
column: leaf.target
|
|
18878
|
+
};
|
|
18879
|
+
if (isOuterRef2(leaf))
|
|
18880
|
+
throw new NotYetSupportedError3("outerRef()", EXPRESSION_ARGUMENT, 1029);
|
|
18881
|
+
if (isQueryBuilder(leaf))
|
|
18882
|
+
throw new NotYetSupportedError3(
|
|
18883
|
+
"a query builder",
|
|
18884
|
+
EXPRESSION_ARGUMENT,
|
|
18885
|
+
1053
|
|
18886
|
+
);
|
|
18887
|
+
if (isSqlRaw(leaf))
|
|
18888
|
+
throw new InvalidOperationError(
|
|
18889
|
+
helper,
|
|
18890
|
+
"sql() is only accepted as an update or upsert value; use literal(), param() or an expression here"
|
|
18891
|
+
);
|
|
18892
|
+
return refuse(helper, "a plain object");
|
|
18816
18893
|
}
|
|
18894
|
+
|
|
18895
|
+
// src/dx/expressions.ts
|
|
18896
|
+
var OPERATOR_PATTERN = /^[a-zA-Z_<>=!@#%^&|~*+\-/.]+$/;
|
|
18897
|
+
var FUNCTION_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*$/;
|
|
18898
|
+
var TYPE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_ ]*(\[\])?$/;
|
|
18817
18899
|
var ExpressionRef = class _ExpressionRef {
|
|
18818
18900
|
intent;
|
|
18819
18901
|
constructor(intent) {
|
|
18820
|
-
brandValue5(this,
|
|
18902
|
+
brandValue5(this, EXPRESSION_BRAND9, true);
|
|
18821
18903
|
this.intent = Object.freeze(intent);
|
|
18822
18904
|
}
|
|
18823
18905
|
/**
|
|
@@ -18918,7 +19000,7 @@ function hasPredicateRefDiscriminator(value) {
|
|
|
18918
19000
|
return typeof value === "object" && value !== null && value[PREDICATE_BRAND] === PREDICATE_REF_DISCRIMINATOR;
|
|
18919
19001
|
}
|
|
18920
19002
|
function isExpressionPredicateRef(predicate) {
|
|
18921
|
-
return
|
|
19003
|
+
return EXPRESSION_BRAND9 in predicate && predicate[EXPRESSION_BRAND9] === true;
|
|
18922
19004
|
}
|
|
18923
19005
|
function predicateWhereIntent(predicate) {
|
|
18924
19006
|
return isExpressionPredicateRef(predicate) ? { kind: "expression", expr: predicate.intent } : predicate.intent;
|
|
@@ -18941,7 +19023,7 @@ function cast(expr, typeName) {
|
|
|
18941
19023
|
}
|
|
18942
19024
|
return new ExpressionRef({
|
|
18943
19025
|
kind: "cast",
|
|
18944
|
-
expr: expr
|
|
19026
|
+
expr: coerceReference(expr, "cast"),
|
|
18945
19027
|
typeName
|
|
18946
19028
|
});
|
|
18947
19029
|
}
|
|
@@ -18980,8 +19062,8 @@ function op(operator, ...operands) {
|
|
|
18980
19062
|
const intent = {
|
|
18981
19063
|
kind: "customOp",
|
|
18982
19064
|
operator,
|
|
18983
|
-
left:
|
|
18984
|
-
right:
|
|
19065
|
+
left: coerceReference(left, "op"),
|
|
19066
|
+
right: coerceReference(right, "op")
|
|
18985
19067
|
};
|
|
18986
19068
|
if (isPredicateOperator(operator)) {
|
|
18987
19069
|
return new ExpressionPredicateRef(intent);
|
|
@@ -19022,6 +19104,9 @@ function isPredicateOperator(operator) {
|
|
|
19022
19104
|
return operator === "=" || operator === "!=" || operator === "<>" || operator === "<" || operator === "<=" || operator === ">" || operator === ">=" || operator === "@@" || operator === "@@@" || operator === "&&" || operator === "<@" || operator === "@>";
|
|
19023
19105
|
}
|
|
19024
19106
|
function fn(name, ...args) {
|
|
19107
|
+
return new ExpressionRef(customFnIntent("fn", name, args));
|
|
19108
|
+
}
|
|
19109
|
+
function customFnIntent(helper, name, args) {
|
|
19025
19110
|
if (!name || !FUNCTION_NAME_PATTERN.test(name)) {
|
|
19026
19111
|
throw new Error(`Invalid function name: ${name}`);
|
|
19027
19112
|
}
|
|
@@ -19043,11 +19128,11 @@ function fn(name, ...args) {
|
|
|
19043
19128
|
);
|
|
19044
19129
|
}
|
|
19045
19130
|
distinct2 = true;
|
|
19046
|
-
regularArgs.push(
|
|
19131
|
+
regularArgs.push(coerceReference(field, helper));
|
|
19047
19132
|
} else if (isAggOrderByArg(arg)) {
|
|
19048
19133
|
orderByArgs.push(arg);
|
|
19049
19134
|
} else {
|
|
19050
|
-
regularArgs.push(
|
|
19135
|
+
regularArgs.push(coerceReference(arg, helper));
|
|
19051
19136
|
}
|
|
19052
19137
|
}
|
|
19053
19138
|
const intent = {
|
|
@@ -19057,12 +19142,10 @@ function fn(name, ...args) {
|
|
|
19057
19142
|
...distinct2 ? { distinct: true } : {},
|
|
19058
19143
|
...orderByArgs.length > 0 ? { aggOrderBy: orderByArgs } : {}
|
|
19059
19144
|
};
|
|
19060
|
-
return
|
|
19145
|
+
return intent;
|
|
19061
19146
|
}
|
|
19062
19147
|
function boolFn(name, ...args) {
|
|
19063
|
-
return new ExpressionPredicateRef(
|
|
19064
|
-
fn(name, ...args).intent
|
|
19065
|
-
);
|
|
19148
|
+
return new ExpressionPredicateRef(customFnIntent("boolFn", name, args));
|
|
19066
19149
|
}
|
|
19067
19150
|
function literal(value) {
|
|
19068
19151
|
return new ExpressionRef({
|
|
@@ -19077,7 +19160,7 @@ function unary(operator, expr) {
|
|
|
19077
19160
|
return new ExpressionRef({
|
|
19078
19161
|
kind: "unary",
|
|
19079
19162
|
operator,
|
|
19080
|
-
operand:
|
|
19163
|
+
operand: coerceReference(expr, "unary")
|
|
19081
19164
|
});
|
|
19082
19165
|
}
|
|
19083
19166
|
function namedArg(name, value) {
|
|
@@ -19087,7 +19170,7 @@ function namedArg(name, value) {
|
|
|
19087
19170
|
return new ExpressionRef({
|
|
19088
19171
|
kind: "namedArg",
|
|
19089
19172
|
name,
|
|
19090
|
-
value:
|
|
19173
|
+
value: coerceReference(value, "namedArg")
|
|
19091
19174
|
});
|
|
19092
19175
|
}
|
|
19093
19176
|
function star() {
|
|
@@ -19096,7 +19179,7 @@ function star() {
|
|
|
19096
19179
|
function array(...items2) {
|
|
19097
19180
|
return new ExpressionRef({
|
|
19098
19181
|
kind: "array",
|
|
19099
|
-
elements: items2.map(
|
|
19182
|
+
elements: items2.map((item) => coerceReference(item, "array"))
|
|
19100
19183
|
});
|
|
19101
19184
|
}
|
|
19102
19185
|
function isDistinctField2(input) {
|
|
@@ -19109,8 +19192,9 @@ function aggOrderBy(field, direction = "asc") {
|
|
|
19109
19192
|
return { __aggOrderBy: true, field, direction };
|
|
19110
19193
|
}
|
|
19111
19194
|
function arrayAgg(col2, ...rest) {
|
|
19112
|
-
|
|
19113
|
-
|
|
19195
|
+
return new ExpressionRef(
|
|
19196
|
+
customFnIntent("arrayAgg", "array_agg", [col2, ...rest])
|
|
19197
|
+
);
|
|
19114
19198
|
}
|
|
19115
19199
|
function stringAgg(col2, separator, ...rest) {
|
|
19116
19200
|
const colExpr = typeof col2 === "string" ? ref2(col2) : col2;
|
|
@@ -19118,17 +19202,11 @@ function stringAgg(col2, separator, ...rest) {
|
|
|
19118
19202
|
}
|
|
19119
19203
|
|
|
19120
19204
|
// src/dx/case-when-builder.ts
|
|
19121
|
-
function toResultIntent(value) {
|
|
19122
|
-
if (value
|
|
19123
|
-
return value.intent;
|
|
19124
|
-
}
|
|
19125
|
-
if (value === null || value === void 0) {
|
|
19205
|
+
function toResultIntent(value, helper) {
|
|
19206
|
+
if (value === null) {
|
|
19126
19207
|
return { kind: "literal", value: null };
|
|
19127
19208
|
}
|
|
19128
|
-
|
|
19129
|
-
return { kind: "ref", column: value };
|
|
19130
|
-
}
|
|
19131
|
-
return { kind: "literal", value };
|
|
19209
|
+
return coerceReference(value, helper);
|
|
19132
19210
|
}
|
|
19133
19211
|
var CaseBuilder = class _CaseBuilder {
|
|
19134
19212
|
branches;
|
|
@@ -19138,14 +19216,14 @@ var CaseBuilder = class _CaseBuilder {
|
|
|
19138
19216
|
when(condition, thenValue) {
|
|
19139
19217
|
return new _CaseBuilder([
|
|
19140
19218
|
...this.branches,
|
|
19141
|
-
{ condition, result: toResultIntent(thenValue) }
|
|
19219
|
+
{ condition, result: toResultIntent(thenValue, "caseWhen().when") }
|
|
19142
19220
|
]);
|
|
19143
19221
|
}
|
|
19144
19222
|
else(elseValue) {
|
|
19145
19223
|
const intent = {
|
|
19146
19224
|
kind: "case",
|
|
19147
19225
|
when: this.branches,
|
|
19148
|
-
else: toResultIntent(elseValue)
|
|
19226
|
+
else: toResultIntent(elseValue, "caseWhen().else")
|
|
19149
19227
|
};
|
|
19150
19228
|
return new ExpressionRef(intent);
|
|
19151
19229
|
}
|
|
@@ -19161,7 +19239,9 @@ var CaseBuilder = class _CaseBuilder {
|
|
|
19161
19239
|
}
|
|
19162
19240
|
};
|
|
19163
19241
|
function caseWhen(condition, thenValue) {
|
|
19164
|
-
return new CaseBuilder([
|
|
19242
|
+
return new CaseBuilder([
|
|
19243
|
+
{ condition, result: toResultIntent(thenValue, "caseWhen") }
|
|
19244
|
+
]);
|
|
19165
19245
|
}
|
|
19166
19246
|
|
|
19167
19247
|
// src/adapter.ts
|
|
@@ -22072,22 +22152,12 @@ function createNqlProgramSteps(compiledIntent) {
|
|
|
22072
22152
|
assertNqlProgramSteps(compiledIntent, steps);
|
|
22073
22153
|
return steps;
|
|
22074
22154
|
}
|
|
22075
|
-
function
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
22079
|
-
}
|
|
22080
|
-
|
|
22081
|
-
function joinDumpSequenceSql(sequence) {
|
|
22082
|
-
let parameterOffset = 0;
|
|
22083
|
-
return sequence.map((step) => {
|
|
22084
|
-
const sql2 = renumberDumpSqlParams(step.sql, parameterOffset);
|
|
22085
|
-
parameterOffset += step.params.length;
|
|
22086
|
-
return sql2;
|
|
22087
|
-
}).join(";\n");
|
|
22088
|
-
}
|
|
22089
|
-
function flattenDumpSequenceParams(sequence) {
|
|
22090
|
-
return sequence.flatMap((step) => [...step.params]);
|
|
22155
|
+
function lastDumpSequenceStep(sequence) {
|
|
22156
|
+
const last = sequence.at(-1);
|
|
22157
|
+
if (last === void 0) {
|
|
22158
|
+
throw new Error("NQL program sequence did not contain a final statement.");
|
|
22159
|
+
}
|
|
22160
|
+
return last;
|
|
22091
22161
|
}
|
|
22092
22162
|
function filterMapByBindingDependencies(source, bindingDependencies) {
|
|
22093
22163
|
if (source === void 0) return /* @__PURE__ */ new Map();
|
|
@@ -22737,10 +22807,11 @@ var NqlBuilderImpl = class {
|
|
|
22737
22807
|
correlationId: meta.correlationId
|
|
22738
22808
|
}
|
|
22739
22809
|
};
|
|
22810
|
+
const lastStatement2 = lastDumpSequenceStep(sequence);
|
|
22740
22811
|
return {
|
|
22741
22812
|
plan: planReport,
|
|
22742
|
-
sql:
|
|
22743
|
-
params:
|
|
22813
|
+
sql: lastStatement2.sql,
|
|
22814
|
+
params: lastStatement2.params,
|
|
22744
22815
|
meta: dumpMeta2,
|
|
22745
22816
|
sequence
|
|
22746
22817
|
};
|
|
@@ -22758,9 +22829,10 @@ var NqlBuilderImpl = class {
|
|
|
22758
22829
|
correlationId: meta.correlationId
|
|
22759
22830
|
}
|
|
22760
22831
|
};
|
|
22832
|
+
const lastStatement = lastDumpSequenceStep(sequence);
|
|
22761
22833
|
return {
|
|
22762
|
-
sql:
|
|
22763
|
-
parameters:
|
|
22834
|
+
sql: lastStatement.sql,
|
|
22835
|
+
parameters: lastStatement.params,
|
|
22764
22836
|
intent: finalStep.intent,
|
|
22765
22837
|
meta: dumpMeta,
|
|
22766
22838
|
sequence
|
|
@@ -22893,9 +22965,9 @@ function extractPseudoColumnKeywords(model) {
|
|
|
22893
22965
|
}
|
|
22894
22966
|
|
|
22895
22967
|
// src/dx/types.ts
|
|
22896
|
-
import { EXPRESSION_BRAND as
|
|
22968
|
+
import { EXPRESSION_BRAND as EXPRESSION_BRAND10 } from "@dbsp/types";
|
|
22897
22969
|
function isExpressionSpec(spec) {
|
|
22898
|
-
return typeof spec === "object" && spec !== null &&
|
|
22970
|
+
return typeof spec === "object" && spec !== null && EXPRESSION_BRAND10 in spec && spec[EXPRESSION_BRAND10] === true;
|
|
22899
22971
|
}
|
|
22900
22972
|
|
|
22901
22973
|
// src/dx/raw-cte-builder.ts
|
|
@@ -27701,4 +27773,4 @@ export {
|
|
|
27701
27773
|
runAssertions,
|
|
27702
27774
|
isOverallSuccess
|
|
27703
27775
|
};
|
|
27704
|
-
//# sourceMappingURL=chunk-
|
|
27776
|
+
//# sourceMappingURL=chunk-MVPSYATN.js.map
|