@dbsp/adapter-pgsql 7.1.3 → 7.2.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.
|
@@ -13643,9 +13643,14 @@ var comparisonHandler = {
|
|
|
13643
13643
|
}
|
|
13644
13644
|
};
|
|
13645
13645
|
function resolveHavingAggregatePgType(functionName, column2, ctx) {
|
|
13646
|
+
return aggregateResultPgType(
|
|
13647
|
+
functionName,
|
|
13648
|
+
functionName.toLowerCase() === "count" ? void 0 : resolveColumnPgType(column2, ctx)
|
|
13649
|
+
);
|
|
13650
|
+
}
|
|
13651
|
+
function aggregateResultPgType(functionName, argumentType) {
|
|
13646
13652
|
const aggregate = functionName.toLowerCase();
|
|
13647
13653
|
if (aggregate === "count") return "bigint";
|
|
13648
|
-
const argumentType = resolveColumnPgType(column2, ctx);
|
|
13649
13654
|
if (aggregate === "min" || aggregate === "max") return argumentType;
|
|
13650
13655
|
if (argumentType === void 0) return void 0;
|
|
13651
13656
|
const normalized = argumentType.toLowerCase().replace(/\s+/g, " ").trim();
|
|
@@ -14154,8 +14159,15 @@ function columnType(operand, ctx, state) {
|
|
|
14154
14159
|
validateDbType(type);
|
|
14155
14160
|
return dbTypeCastTarget(type);
|
|
14156
14161
|
}
|
|
14162
|
+
function leftType(operand, ctx, state) {
|
|
14163
|
+
if (operand.kind !== "aggregate") return columnType(operand, ctx, state);
|
|
14164
|
+
return aggregateResultPgType(
|
|
14165
|
+
operand.function,
|
|
14166
|
+
operand.column ? columnType(operand.column, ctx, state) : void 0
|
|
14167
|
+
);
|
|
14168
|
+
}
|
|
14157
14169
|
function parameter(p, ctx, state, left, force = false) {
|
|
14158
|
-
const type = left && (p.cast === "column-db-type" || p.cast === "column-array") ?
|
|
14170
|
+
const type = left && (p.cast === "column-db-type" || p.cast === "column-array") ? leftType(left, ctx, state) : void 0;
|
|
14159
14171
|
if (!p.bound && !force && (p.value === null || p.value === void 0))
|
|
14160
14172
|
return nullConstNode();
|
|
14161
14173
|
const index = ++state.paramIndex;
|
|
@@ -14376,6 +14388,11 @@ function compileResolvedExpressionUnchecked(expr, ctx, state) {
|
|
|
14376
14388
|
function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
14377
14389
|
const visit = (n) => compileResolvedConditionUnchecked(n, ctx, state);
|
|
14378
14390
|
const col = (c) => column(c, ctx);
|
|
14391
|
+
const left = (c) => c.kind !== "aggregate" ? col(c) : funcCall(c.function.toLowerCase(), c.column ? [col(c.column)] : [], {
|
|
14392
|
+
...!c.column && { star: true },
|
|
14393
|
+
...c.distinct && { distinct: true },
|
|
14394
|
+
...c.filter && { filter: visit(c.filter) }
|
|
14395
|
+
});
|
|
14379
14396
|
switch (tree.kind) {
|
|
14380
14397
|
case "and":
|
|
14381
14398
|
case "or": {
|
|
@@ -14385,10 +14402,10 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14385
14402
|
case "not":
|
|
14386
14403
|
return notExpr(visit(tree.condition));
|
|
14387
14404
|
case "null":
|
|
14388
|
-
return compileNull(
|
|
14405
|
+
return compileNull(left(tree.left), tree.operator === "isNull");
|
|
14389
14406
|
case "comparison": {
|
|
14390
14407
|
assertComparisonOperator(tree.operator);
|
|
14391
|
-
let
|
|
14408
|
+
let leftNode = left(tree.left);
|
|
14392
14409
|
if (tree.jsonPath?.length) {
|
|
14393
14410
|
assertDialectCapability(
|
|
14394
14411
|
ctx.dialectCapabilities,
|
|
@@ -14396,8 +14413,8 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14396
14413
|
"JSON operators are"
|
|
14397
14414
|
);
|
|
14398
14415
|
tree.jsonPath.forEach((p, i) => {
|
|
14399
|
-
|
|
14400
|
-
|
|
14416
|
+
leftNode = compileJsonOperator(
|
|
14417
|
+
leftNode,
|
|
14401
14418
|
parameter(p, ctx, state),
|
|
14402
14419
|
i === tree.jsonPath.length - 1 && tree.jsonMode !== "json" ? "->>" : "->"
|
|
14403
14420
|
);
|
|
@@ -14405,7 +14422,7 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14405
14422
|
}
|
|
14406
14423
|
return comparison(
|
|
14407
14424
|
tree.operator,
|
|
14408
|
-
|
|
14425
|
+
leftNode,
|
|
14409
14426
|
tree.right,
|
|
14410
14427
|
ctx,
|
|
14411
14428
|
state,
|
|
@@ -14413,17 +14430,17 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14413
14430
|
);
|
|
14414
14431
|
}
|
|
14415
14432
|
case "like": {
|
|
14416
|
-
const
|
|
14433
|
+
const left2 = col(tree.left);
|
|
14417
14434
|
if (!tree.pattern.bound) {
|
|
14418
14435
|
const n = compileLiteralNullComparison(
|
|
14419
14436
|
tree.caseInsensitive ? "ilike" : "like",
|
|
14420
|
-
|
|
14437
|
+
left2,
|
|
14421
14438
|
tree.pattern.value
|
|
14422
14439
|
);
|
|
14423
14440
|
if (n) return n;
|
|
14424
14441
|
}
|
|
14425
14442
|
return compileLike(
|
|
14426
|
-
|
|
14443
|
+
left2,
|
|
14427
14444
|
parameter(tree.pattern, ctx, state, void 0, true),
|
|
14428
14445
|
tree.caseInsensitive,
|
|
14429
14446
|
tree.escape && parameter(tree.escape, ctx, state, void 0, true)
|
|
@@ -14437,13 +14454,18 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14437
14454
|
"supportsArrayType",
|
|
14438
14455
|
"ANY array operator is"
|
|
14439
14456
|
);
|
|
14440
|
-
const type =
|
|
14457
|
+
const type = leftType(tree.left, ctx, state);
|
|
14458
|
+
const modelBase = (operand) => mapModelIRTypeToPgBase(metadata(operand, ctx, state)?.type ?? "");
|
|
14459
|
+
const base = type ? void 0 : tree.left.kind !== "aggregate" ? modelBase(tree.left) : aggregateResultPgType(
|
|
14460
|
+
tree.left.function,
|
|
14461
|
+
tree.left.column ? modelBase(tree.left.column) : void 0
|
|
14462
|
+
);
|
|
14441
14463
|
return compileAny(
|
|
14442
|
-
|
|
14464
|
+
left(tree.left),
|
|
14443
14465
|
Array.isArray(tree.values.value) ? tree.values.value : [],
|
|
14444
14466
|
state,
|
|
14445
14467
|
type,
|
|
14446
|
-
|
|
14468
|
+
base
|
|
14447
14469
|
);
|
|
14448
14470
|
}
|
|
14449
14471
|
case "in": {
|
|
@@ -14451,7 +14473,7 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14451
14473
|
const node = {
|
|
14452
14474
|
SubLink: {
|
|
14453
14475
|
subLinkType: "ANY_SUBLINK",
|
|
14454
|
-
testexpr:
|
|
14476
|
+
testexpr: left(tree.left),
|
|
14455
14477
|
operName: [{ String: { sval: "=" } }],
|
|
14456
14478
|
subselect: compileResolvedSubqueryBodyUnchecked(
|
|
14457
14479
|
tree.operand.body,
|
|
@@ -14463,16 +14485,18 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14463
14485
|
return tree.negated ? notExpr(node) : node;
|
|
14464
14486
|
}
|
|
14465
14487
|
const values = tree.operand.parameter.value;
|
|
14488
|
+
if (Array.isArray(values) && values.length === 0)
|
|
14489
|
+
return booleanConstNode(tree.negated);
|
|
14466
14490
|
if (!Array.isArray(values))
|
|
14467
14491
|
throw new Error(
|
|
14468
|
-
`[in handler] Received a non-array value for operator '${tree.negated ? "notIn" : "in"}' on column '${tree.left.column}'. This is a compiler bug: expected a scalar array but received ${values == null ? String(values) : typeof values}. File a bug report.`
|
|
14492
|
+
`[in handler] Received a non-array value for operator '${tree.negated ? "notIn" : "in"}' on column '${tree.left.kind === "aggregate" ? tree.left.function : tree.left.column}'. This is a compiler bug: expected a scalar array but received ${values == null ? String(values) : typeof values}. File a bug report.`
|
|
14469
14493
|
);
|
|
14470
14494
|
return compileInValues(
|
|
14471
|
-
|
|
14495
|
+
left(tree.left),
|
|
14472
14496
|
state,
|
|
14473
14497
|
values,
|
|
14474
14498
|
tree.negated,
|
|
14475
|
-
tree.operand.parameter.cast === "column-array" ?
|
|
14499
|
+
tree.operand.parameter.cast === "column-array" ? leftType(tree.left, ctx, state) : void 0,
|
|
14476
14500
|
supportsDialectCapability(ctx.dialectCapabilities, "supportsArrayType")
|
|
14477
14501
|
);
|
|
14478
14502
|
}
|
|
@@ -14532,18 +14556,18 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14532
14556
|
);
|
|
14533
14557
|
case "expression": {
|
|
14534
14558
|
if (tree.comparison) assertComparisonOperator(tree.comparison.operator);
|
|
14535
|
-
const
|
|
14559
|
+
const left2 = compileResolvedExpressionUnchecked(
|
|
14536
14560
|
tree.expression,
|
|
14537
14561
|
ctx,
|
|
14538
14562
|
state
|
|
14539
14563
|
);
|
|
14540
14564
|
return tree.comparison ? comparison(
|
|
14541
14565
|
tree.comparison.operator,
|
|
14542
|
-
|
|
14566
|
+
left2,
|
|
14543
14567
|
tree.comparison.right,
|
|
14544
14568
|
ctx,
|
|
14545
14569
|
state
|
|
14546
|
-
) :
|
|
14570
|
+
) : left2;
|
|
14547
14571
|
}
|
|
14548
14572
|
case "subquery": {
|
|
14549
14573
|
if (tree.use !== "exists") assertComparisonOperator(tree.operator);
|
|
@@ -14557,7 +14581,7 @@ function compileResolvedConditionUnchecked(tree, ctx, state) {
|
|
|
14557
14581
|
)
|
|
14558
14582
|
}
|
|
14559
14583
|
};
|
|
14560
|
-
return tree.use === "exists" ? tree.negated ? notExpr(node) : node : compileComparison(op(tree.operator),
|
|
14584
|
+
return tree.use === "exists" ? tree.negated ? notExpr(node) : node : compileComparison(op(tree.operator), left(tree.left), node);
|
|
14561
14585
|
}
|
|
14562
14586
|
case "relation": {
|
|
14563
14587
|
if (tree.vacuous) return booleanConstNode(true);
|
|
@@ -29746,16 +29770,20 @@ function getRegisteredProjection(registry, name) {
|
|
|
29746
29770
|
return registry.get(name);
|
|
29747
29771
|
}
|
|
29748
29772
|
function createPlanReportForQuery(query, model, defaultFilters) {
|
|
29773
|
+
const resolution = resolveReportIncludes(query, [], model, {
|
|
29774
|
+
...defaultFilters && { defaultFilters },
|
|
29775
|
+
skipRootDefaultFilter: true
|
|
29776
|
+
});
|
|
29749
29777
|
return markPlannedReport2({
|
|
29750
29778
|
rootTable: query.from,
|
|
29751
29779
|
decisions: [],
|
|
29752
29780
|
warnings: [],
|
|
29753
29781
|
ctes: [],
|
|
29754
29782
|
intent: query,
|
|
29755
|
-
|
|
29756
|
-
|
|
29757
|
-
|
|
29758
|
-
|
|
29783
|
+
...resolution.intent !== query && {
|
|
29784
|
+
executableIntent: resolution.intent
|
|
29785
|
+
},
|
|
29786
|
+
execution: resolution.execution,
|
|
29759
29787
|
metadata: {
|
|
29760
29788
|
planningTimeMs: 0,
|
|
29761
29789
|
relationsAnalyzed: 0,
|
|
@@ -33294,16 +33322,20 @@ function compileNqlRuntimeBindingCte(name, binding, deps, parameterOffset, sourc
|
|
|
33294
33322
|
};
|
|
33295
33323
|
}
|
|
33296
33324
|
function createNqlBindingSelectPlan(query, model, defaultFilters) {
|
|
33325
|
+
const resolution = resolveReportIncludes2(query, [], model, {
|
|
33326
|
+
...defaultFilters && { defaultFilters },
|
|
33327
|
+
skipRootDefaultFilter: true
|
|
33328
|
+
});
|
|
33297
33329
|
return markPlannedReport3({
|
|
33298
33330
|
rootTable: query.from,
|
|
33299
33331
|
decisions: [],
|
|
33300
33332
|
warnings: [],
|
|
33301
33333
|
ctes: [],
|
|
33302
33334
|
intent: query,
|
|
33303
|
-
|
|
33304
|
-
|
|
33305
|
-
|
|
33306
|
-
|
|
33335
|
+
...resolution.intent !== query && {
|
|
33336
|
+
executableIntent: resolution.intent
|
|
33337
|
+
},
|
|
33338
|
+
execution: resolution.execution,
|
|
33307
33339
|
metadata: {
|
|
33308
33340
|
planningTimeMs: 0,
|
|
33309
33341
|
relationsAnalyzed: 0,
|
|
@@ -59431,4 +59463,4 @@ export {
|
|
|
59431
59463
|
planPgTransitionRun,
|
|
59432
59464
|
applyPgTransitionRun
|
|
59433
59465
|
};
|
|
59434
|
-
//# sourceMappingURL=chunk-
|
|
59466
|
+
//# sourceMappingURL=chunk-WGJ4IBEN.js.map
|