@dbsp/adapter-pgsql 1.4.0 → 1.6.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/index.d.ts +23 -13
- package/dist/index.js +565 -162
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExpressionRef, IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, ModelIR as ModelIR$1 } from '@dbsp/core';
|
|
2
2
|
export { normalizeSQL } from '@dbsp/core';
|
|
3
3
|
import * as _dbsp_types from '@dbsp/types';
|
|
4
|
-
import { ParamIntent, DialectCapabilities, ModelIR, DbCasing, ColumnIR, HierarchyIR, WhereIntent, Adapter, AdapterLogger, AdapterCapabilities, PlanReport, CompiledNqlQuery, CompileOptions, CompiledQuery, CompileResultWithIncludes, SubqueryIncludeInfo, ExpressionIntent, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, RecursivePlanReport, CteQueryIntent, SetOperationIntent, DumpMeta, Dump, AdapterStreamOptions, CompileOnlyAdapter, QueryIntent } from '@dbsp/types';
|
|
4
|
+
import { ColumnListInput, ParamIntent, JsonAggOrderByEntry, DialectCapabilities, ModelIR, DbCasing, ColumnIR, HierarchyIR, WhereIntent, Adapter, AdapterLogger, AdapterCapabilities, PlanReport, CompiledNqlQuery, CompileOptions, CompiledQuery, CompileResultWithIncludes, SubqueryIncludeInfo, ExpressionIntent, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, RecursivePlanReport, CteQueryIntent, SetOperationIntent, DumpMeta, Dump, AdapterStreamOptions, CompileOnlyAdapter, QueryIntent } from '@dbsp/types';
|
|
5
5
|
import * as _pgsql_types from '@pgsql/types';
|
|
6
6
|
import { Node, OnConflictClause, ParamRef } from '@pgsql/types';
|
|
7
7
|
import { Pool, PoolClient } from 'pg';
|
|
@@ -99,6 +99,10 @@ declare function getNamingPluginForDbCasing(casing: 'snake_case' | 'camelCase' |
|
|
|
99
99
|
|
|
100
100
|
type BindingNameRegistry = ReadonlySet<string>;
|
|
101
101
|
|
|
102
|
+
type PlanExpressionOrderBy = readonly {
|
|
103
|
+
field: string;
|
|
104
|
+
direction?: 'asc' | 'desc';
|
|
105
|
+
}[];
|
|
102
106
|
/**
|
|
103
107
|
* Simplified PlanDecision for the spike
|
|
104
108
|
* (In production, import from @dbsp/core)
|
|
@@ -115,8 +119,8 @@ interface PlanDecision {
|
|
|
115
119
|
readonly direction?: 'ASC' | 'DESC';
|
|
116
120
|
readonly nulls?: 'FIRST' | 'LAST';
|
|
117
121
|
readonly joinType?: 'inner' | 'left';
|
|
118
|
-
readonly sourceColumn?:
|
|
119
|
-
readonly targetColumn?:
|
|
122
|
+
readonly sourceColumn?: ColumnListInput;
|
|
123
|
+
readonly targetColumn?: ColumnListInput;
|
|
120
124
|
readonly targetTable?: string;
|
|
121
125
|
readonly function?: string;
|
|
122
126
|
readonly args?: readonly unknown[];
|
|
@@ -134,18 +138,17 @@ interface PlanDecision {
|
|
|
134
138
|
paramIndex: number;
|
|
135
139
|
};
|
|
136
140
|
readonly partitionBy?: readonly string[];
|
|
137
|
-
readonly orderBy?: readonly
|
|
138
|
-
field: string;
|
|
139
|
-
direction?: 'asc' | 'desc';
|
|
140
|
-
}[];
|
|
141
|
+
readonly orderBy?: PlanExpressionOrderBy | readonly JsonAggOrderByEntry[];
|
|
141
142
|
readonly dataType?: string;
|
|
142
143
|
readonly sourceTable?: string;
|
|
143
144
|
readonly relationName?: string;
|
|
144
145
|
readonly relationPath?: string;
|
|
145
146
|
readonly hydrationPrefix?: string;
|
|
146
147
|
readonly relationType?: 'belongsTo' | 'hasMany' | 'hasOne';
|
|
147
|
-
readonly foreignKey?:
|
|
148
|
-
readonly parentKey?:
|
|
148
|
+
readonly foreignKey?: ColumnListInput;
|
|
149
|
+
readonly parentKey?: ColumnListInput;
|
|
150
|
+
readonly targetPrimaryKey?: readonly JsonAggOrderByEntry[];
|
|
151
|
+
readonly orderByFallback?: boolean;
|
|
149
152
|
readonly children?: readonly PlanDecision[];
|
|
150
153
|
readonly intentPath?: string;
|
|
151
154
|
readonly choice?: string;
|
|
@@ -289,6 +292,8 @@ declare class PlanCompiler {
|
|
|
289
292
|
private rawJoins;
|
|
290
293
|
/** CTE nodes from include handlers (e.g., CTE strategy) */
|
|
291
294
|
private pendingCtes;
|
|
295
|
+
/** Local aliases for binding relation-column scalar subqueries. */
|
|
296
|
+
private bindingRelationColumnSubqueryIndex;
|
|
292
297
|
/**
|
|
293
298
|
* Maps relation-dotted include path → JOIN alias for multi-hop FK resolution.
|
|
294
299
|
* Populated as join decisions are compiled so later hops can find the
|
|
@@ -347,6 +352,9 @@ declare class PlanCompiler {
|
|
|
347
352
|
/** Build a fresh HandlerCompilerState sharing the current parameter array. */
|
|
348
353
|
private createHandlerState;
|
|
349
354
|
private schemaForRangeVar;
|
|
355
|
+
private isNqlBindingRoot;
|
|
356
|
+
private buildCorrelatedRelationRefs;
|
|
357
|
+
private compileBindingRelationColumnSubquery;
|
|
350
358
|
private compileExpressionSubquery;
|
|
351
359
|
private compileGenericNqlFunction;
|
|
352
360
|
private compileNqlFunctionArg;
|
|
@@ -1147,8 +1155,8 @@ interface Decision {
|
|
|
1147
1155
|
readonly direction?: 'ASC' | 'DESC';
|
|
1148
1156
|
readonly nulls?: 'FIRST' | 'LAST';
|
|
1149
1157
|
readonly joinType?: 'inner' | 'left';
|
|
1150
|
-
readonly sourceColumn?:
|
|
1151
|
-
readonly targetColumn?:
|
|
1158
|
+
readonly sourceColumn?: ColumnListInput;
|
|
1159
|
+
readonly targetColumn?: ColumnListInput;
|
|
1152
1160
|
readonly targetTable?: string;
|
|
1153
1161
|
readonly function?: string;
|
|
1154
1162
|
readonly args?: readonly unknown[];
|
|
@@ -1172,8 +1180,10 @@ interface Decision {
|
|
|
1172
1180
|
readonly hydrationPrefix?: string;
|
|
1173
1181
|
readonly include?: readonly Decision[];
|
|
1174
1182
|
readonly relationType?: 'belongsTo' | 'hasMany' | 'hasOne';
|
|
1175
|
-
readonly foreignKey?:
|
|
1176
|
-
readonly parentKey?:
|
|
1183
|
+
readonly foreignKey?: ColumnListInput;
|
|
1184
|
+
readonly parentKey?: ColumnListInput;
|
|
1185
|
+
readonly targetPrimaryKey?: readonly JsonAggOrderByEntry[];
|
|
1186
|
+
readonly orderByFallback?: boolean;
|
|
1177
1187
|
readonly children?: readonly Decision[];
|
|
1178
1188
|
readonly partition?: readonly string[];
|
|
1179
1189
|
readonly orderBy?: readonly {
|