@dbsp/adapter-pgsql 7.0.0 → 7.1.1
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.
|
@@ -12931,6 +12931,15 @@ function assertSafeOperator(op2, opts) {
|
|
|
12931
12931
|
);
|
|
12932
12932
|
}
|
|
12933
12933
|
}
|
|
12934
|
+
function expressionNamedColumnRef(name, ctx) {
|
|
12935
|
+
const dotIdx = name.indexOf(".");
|
|
12936
|
+
if (dotIdx === -1) return expressionUnqualifiedColumnRef(name, ctx);
|
|
12937
|
+
return expressionQualifiedColumnRef(
|
|
12938
|
+
name.slice(dotIdx + 1),
|
|
12939
|
+
name.slice(0, dotIdx),
|
|
12940
|
+
ctx
|
|
12941
|
+
);
|
|
12942
|
+
}
|
|
12934
12943
|
function compileExpressionIntent(intent, ctx, state) {
|
|
12935
12944
|
const kind = intent.kind;
|
|
12936
12945
|
switch (kind) {
|
|
@@ -12961,7 +12970,7 @@ function compileExpressionIntent(intent, ctx, state) {
|
|
|
12961
12970
|
(arg) => compileExpressionIntent(arg, ctx, state)
|
|
12962
12971
|
);
|
|
12963
12972
|
const orderByNodes = i.aggOrderBy && i.aggOrderBy.length > 0 ? i.aggOrderBy.map((ob) => {
|
|
12964
|
-
const colNode =
|
|
12973
|
+
const colNode = expressionNamedColumnRef(ob.field, ctx);
|
|
12965
12974
|
return sortBy(colNode, ob.direction === "desc" ? "DESC" : "ASC");
|
|
12966
12975
|
}) : void 0;
|
|
12967
12976
|
const filterNode = i.filter ? ctx.compileCustomFnFilter?.(i.filter, ctx, state) : void 0;
|
|
@@ -12978,13 +12987,7 @@ function compileExpressionIntent(intent, ctx, state) {
|
|
|
12978
12987
|
}
|
|
12979
12988
|
case "ref": {
|
|
12980
12989
|
const i = intent;
|
|
12981
|
-
|
|
12982
|
-
if (dotIdx !== -1) {
|
|
12983
|
-
const table2 = i.column.slice(0, dotIdx);
|
|
12984
|
-
const col = i.column.slice(dotIdx + 1);
|
|
12985
|
-
return expressionQualifiedColumnRef(col, table2, ctx);
|
|
12986
|
-
}
|
|
12987
|
-
return expressionUnqualifiedColumnRef(i.column, ctx);
|
|
12990
|
+
return expressionNamedColumnRef(i.column, ctx);
|
|
12988
12991
|
}
|
|
12989
12992
|
case "param": {
|
|
12990
12993
|
const i = intent;
|
|
@@ -19271,13 +19274,22 @@ var prefixedRelationColumnHandler = {
|
|
|
19271
19274
|
|
|
19272
19275
|
// src/handlers/expression/window.ts
|
|
19273
19276
|
var WINDOW_FRAME_DEFAULT = 1034;
|
|
19277
|
+
function windowColumnRef(name, ctx) {
|
|
19278
|
+
const dotIdx = name.indexOf(".");
|
|
19279
|
+
if (dotIdx === -1) return expressionColumnRef(name, ctx);
|
|
19280
|
+
return expressionQualifiedColumnRef(
|
|
19281
|
+
name.slice(dotIdx + 1),
|
|
19282
|
+
name.slice(0, dotIdx),
|
|
19283
|
+
ctx
|
|
19284
|
+
);
|
|
19285
|
+
}
|
|
19274
19286
|
function isWindowOrderBy(orderBy) {
|
|
19275
19287
|
return Array.isArray(orderBy) && orderBy.every(
|
|
19276
19288
|
(item) => typeof item === "object" && item !== null && "column" in item && typeof item.column === "string"
|
|
19277
19289
|
);
|
|
19278
19290
|
}
|
|
19279
19291
|
function buildSortBy(column2, direction, ctx) {
|
|
19280
|
-
const colRef =
|
|
19292
|
+
const colRef = windowColumnRef(column2, ctx);
|
|
19281
19293
|
const sortBy2 = {
|
|
19282
19294
|
node: colRef,
|
|
19283
19295
|
sortby_dir: direction === "DESC" ? "SORTBY_DESC" : "SORTBY_ASC",
|
|
@@ -19292,7 +19304,7 @@ function buildWindowDef(decision, ctx) {
|
|
|
19292
19304
|
const windowDef = { frameOptions: WINDOW_FRAME_DEFAULT };
|
|
19293
19305
|
if (partition && partition.length > 0) {
|
|
19294
19306
|
windowDef.partitionClause = partition.map(
|
|
19295
|
-
(col) =>
|
|
19307
|
+
(col) => windowColumnRef(col, ctx)
|
|
19296
19308
|
);
|
|
19297
19309
|
}
|
|
19298
19310
|
if (orderBy && orderBy.length > 0) {
|
|
@@ -19351,7 +19363,7 @@ function createLagLeadHandler(funcName, types) {
|
|
|
19351
19363
|
if (!column2) {
|
|
19352
19364
|
throw new Error(`${upperName} requires a column`);
|
|
19353
19365
|
}
|
|
19354
|
-
const colRef =
|
|
19366
|
+
const colRef = windowColumnRef(column2, ctx);
|
|
19355
19367
|
const args = [colRef];
|
|
19356
19368
|
const offset = decision.args?.[0] ?? 1;
|
|
19357
19369
|
args.push(bindParameter(unwrapParamIntent(offset), state));
|
|
@@ -19373,7 +19385,7 @@ function createColumnWindowHandler(funcName, types) {
|
|
|
19373
19385
|
if (!column2) {
|
|
19374
19386
|
throw new Error(`${upperName} requires a column`);
|
|
19375
19387
|
}
|
|
19376
|
-
const colRef =
|
|
19388
|
+
const colRef = windowColumnRef(column2, ctx);
|
|
19377
19389
|
return buildWindowFunction(funcName, [colRef], decision, ctx);
|
|
19378
19390
|
}
|
|
19379
19391
|
};
|
|
@@ -19408,7 +19420,7 @@ var genericWindowHandler = {
|
|
|
19408
19420
|
}
|
|
19409
19421
|
const args = [];
|
|
19410
19422
|
if (decision.column) {
|
|
19411
|
-
args.push(
|
|
19423
|
+
args.push(windowColumnRef(decision.column, ctx));
|
|
19412
19424
|
}
|
|
19413
19425
|
if (decision.args && Array.isArray(decision.args)) {
|
|
19414
19426
|
for (const arg of decision.args) {
|
|
@@ -26090,7 +26102,7 @@ var PlanCompiler = class _PlanCompiler {
|
|
|
26090
26102
|
const targetName = decision.targetTable ?? "";
|
|
26091
26103
|
const target = resolveRelationTarget(
|
|
26092
26104
|
queryLocal(targetName),
|
|
26093
|
-
this.
|
|
26105
|
+
this.relationTargetContext()
|
|
26094
26106
|
);
|
|
26095
26107
|
requireRelationTargetColumns(
|
|
26096
26108
|
target,
|
|
@@ -26102,7 +26114,7 @@ var PlanCompiler = class _PlanCompiler {
|
|
|
26102
26114
|
queryLocal(decision.alias ?? targetName),
|
|
26103
26115
|
target
|
|
26104
26116
|
);
|
|
26105
|
-
const sourceAlias = plan.rootTable;
|
|
26117
|
+
const sourceAlias = decision.sourceAlias ?? plan.rootTable;
|
|
26106
26118
|
const onCondition = buildKeyCorrelation(
|
|
26107
26119
|
sourceAlias,
|
|
26108
26120
|
sourceColumn,
|
|
@@ -28061,6 +28073,15 @@ function buildBatchValuesRangeFn(bv, startParamIndex, aliasOverride) {
|
|
|
28061
28073
|
};
|
|
28062
28074
|
return { rangeFunction, params };
|
|
28063
28075
|
}
|
|
28076
|
+
function resolvedJoinsCoverIntents(joins, resolved) {
|
|
28077
|
+
let position = 0;
|
|
28078
|
+
for (const [intentIndex, join] of joins.entries()) {
|
|
28079
|
+
const hops = join.relation !== void 0 ? join.relation.split(".").length : 1;
|
|
28080
|
+
for (let hop = 0; hop < hops; hop++, position++)
|
|
28081
|
+
if (resolved[position]?.intentIndex !== intentIndex) return false;
|
|
28082
|
+
}
|
|
28083
|
+
return position === resolved.length;
|
|
28084
|
+
}
|
|
28064
28085
|
function compileJoinIntents(joins, execution, schemaName, deps) {
|
|
28065
28086
|
if (execution.joins.length === 0) return [];
|
|
28066
28087
|
const rootTable = execution.rootRange.table;
|
|
@@ -28123,7 +28144,7 @@ function compileJoinIntents(joins, execution, schemaName, deps) {
|
|
|
28123
28144
|
if (alias === rootBinding.qualifier)
|
|
28124
28145
|
throw new Error(`Query scope already binds qualifier '${alias}'.`);
|
|
28125
28146
|
if (resolved.kind === "relation" && !resolved.defaultFilter) {
|
|
28126
|
-
const pairs = resolved.path.hops
|
|
28147
|
+
const pairs = resolved.path.hops.at(-1).pairs;
|
|
28127
28148
|
results.push({
|
|
28128
28149
|
type: "join",
|
|
28129
28150
|
targetTable: resolved.range.table,
|
|
@@ -28131,7 +28152,10 @@ function compileJoinIntents(joins, execution, schemaName, deps) {
|
|
|
28131
28152
|
relationName: resolved.path.logicalSegments.join("."),
|
|
28132
28153
|
sourceColumn: pairs.map((p) => p.fromColumn),
|
|
28133
28154
|
targetColumn: pairs.map((p) => p.toColumn),
|
|
28134
|
-
joinType: resolved.type
|
|
28155
|
+
joinType: resolved.type,
|
|
28156
|
+
...resolved.sourceRange.id !== execution.rootRange.id && {
|
|
28157
|
+
sourceAlias: resolved.sourceRange.alias
|
|
28158
|
+
}
|
|
28135
28159
|
});
|
|
28136
28160
|
} else if (resolved.kind === "values") {
|
|
28137
28161
|
const bv = joins[resolved.intentIndex]?.batchValues;
|
|
@@ -28169,7 +28193,7 @@ function compileJoinIntents(joins, execution, schemaName, deps) {
|
|
|
28169
28193
|
const tableAlias = resolved.range.alias;
|
|
28170
28194
|
const conditions = [];
|
|
28171
28195
|
if (resolved.path) {
|
|
28172
|
-
for (const pair of resolved.path.hops
|
|
28196
|
+
for (const pair of resolved.path.hops.at(-1).pairs) {
|
|
28173
28197
|
conditions.push(
|
|
28174
28198
|
compileResolvedCondition(
|
|
28175
28199
|
{
|
|
@@ -28222,6 +28246,10 @@ function compileJoinIntents(joins, execution, schemaName, deps) {
|
|
|
28222
28246
|
type: "join",
|
|
28223
28247
|
targetTable: resolved.range.table,
|
|
28224
28248
|
alias: tableAlias,
|
|
28249
|
+
// A filtered relation hop still answers to its relation path.
|
|
28250
|
+
...resolved.path && {
|
|
28251
|
+
relationName: resolved.path.logicalSegments.join(".")
|
|
28252
|
+
},
|
|
28225
28253
|
joinType: resolved.type,
|
|
28226
28254
|
joinRarg: joinedRangeVar,
|
|
28227
28255
|
joinOnNode: onNode,
|
|
@@ -28540,10 +28568,12 @@ function assertPlannedReportAuthority(plan) {
|
|
|
28540
28568
|
function compileSelectEnvelope(plan, options, deps) {
|
|
28541
28569
|
const schemaName = deps.schemaName;
|
|
28542
28570
|
const resolvedModelForCompiler = options?.model ?? deps.model;
|
|
28543
|
-
if ([plan.intent, plan.executableIntent].some(
|
|
28544
|
-
|
|
28545
|
-
|
|
28546
|
-
|
|
28571
|
+
if ([plan.intent, plan.executableIntent].some(
|
|
28572
|
+
(intent) => intent !== void 0 && !resolvedJoinsCoverIntents(
|
|
28573
|
+
intent.joins ?? [],
|
|
28574
|
+
plan.execution?.joins ?? []
|
|
28575
|
+
)
|
|
28576
|
+
)) {
|
|
28547
28577
|
const error = new Error(
|
|
28548
28578
|
"Planned joins require matching resolved execution joins"
|
|
28549
28579
|
);
|
|
@@ -59250,4 +59280,4 @@ export {
|
|
|
59250
59280
|
planPgTransitionRun,
|
|
59251
59281
|
applyPgTransitionRun
|
|
59252
59282
|
};
|
|
59253
|
-
//# sourceMappingURL=chunk-
|
|
59283
|
+
//# sourceMappingURL=chunk-XFAIB2BL.js.map
|