@dbsp/adapter-pgsql 1.5.0 → 1.7.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 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?: string;
119
- readonly targetColumn?: string;
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,16 @@ 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?: string;
148
- readonly parentKey?: string;
148
+ readonly foreignKey?: ColumnListInput;
149
+ readonly parentKey?: ColumnListInput;
150
+ readonly orderByFallback?: boolean;
149
151
  readonly children?: readonly PlanDecision[];
150
152
  readonly intentPath?: string;
151
153
  readonly choice?: string;
@@ -350,6 +352,12 @@ declare class PlanCompiler {
350
352
  private createHandlerState;
351
353
  private schemaForRangeVar;
352
354
  private isNqlBindingRoot;
355
+ private allocateBindingRelationAlias;
356
+ private buildCorrelatedRelationRefs;
357
+ private bindingRelationHasCompleteManyToManyProof;
358
+ private bindingRelationName;
359
+ private bindingRelationNameLooksRecursive;
360
+ private compileBindingRecursiveRelationColumnSubquery;
353
361
  private compileBindingRelationColumnSubquery;
354
362
  private compileExpressionSubquery;
355
363
  private compileGenericNqlFunction;
@@ -625,6 +633,7 @@ declare function generateDownSQL(diff: SchemaDiff, options?: MigrationSQLOptions
625
633
  * Migration File Format v2 — UP + DOWN sections.
626
634
  *
627
635
  * File format:
636
+ * -- dbsp:destructive: true|false
628
637
  * <UP statements>;
629
638
  * -- DOWN
630
639
  * <DOWN statements>;
@@ -641,6 +650,7 @@ interface ParsedMigrationFile {
641
650
  readonly upStatements: readonly string[];
642
651
  readonly downStatements: readonly string[];
643
652
  readonly hasDown: boolean;
653
+ readonly destructive?: boolean | undefined;
644
654
  }
645
655
  /**
646
656
  * Generate a migration file content with UP and DOWN sections.
@@ -1151,8 +1161,8 @@ interface Decision {
1151
1161
  readonly direction?: 'ASC' | 'DESC';
1152
1162
  readonly nulls?: 'FIRST' | 'LAST';
1153
1163
  readonly joinType?: 'inner' | 'left';
1154
- readonly sourceColumn?: string;
1155
- readonly targetColumn?: string;
1164
+ readonly sourceColumn?: ColumnListInput;
1165
+ readonly targetColumn?: ColumnListInput;
1156
1166
  readonly targetTable?: string;
1157
1167
  readonly function?: string;
1158
1168
  readonly args?: readonly unknown[];
@@ -1176,14 +1186,15 @@ interface Decision {
1176
1186
  readonly hydrationPrefix?: string;
1177
1187
  readonly include?: readonly Decision[];
1178
1188
  readonly relationType?: 'belongsTo' | 'hasMany' | 'hasOne';
1179
- readonly foreignKey?: string;
1180
- readonly parentKey?: string;
1189
+ readonly foreignKey?: ColumnListInput;
1190
+ readonly parentKey?: ColumnListInput;
1191
+ readonly orderByFallback?: boolean;
1181
1192
  readonly children?: readonly Decision[];
1182
1193
  readonly partition?: readonly string[];
1183
1194
  readonly orderBy?: readonly {
1184
1195
  column: string;
1185
1196
  direction?: 'ASC' | 'DESC';
1186
- }[];
1197
+ }[] | readonly JsonAggOrderByEntry[];
1187
1198
  readonly frame?: string;
1188
1199
  readonly maxDepth?: number;
1189
1200
  readonly pathColumn?: string;