@dbsp/adapter-pgsql 1.3.0 → 1.5.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/README.md +4 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +627 -121
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -42,6 +42,10 @@ const { sql, params } = orm.select('users').where(eq('active', true)).dump();
|
|
|
42
42
|
// sql, params — no Pool needed
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
### Direct NQL bundles
|
|
46
|
+
|
|
47
|
+
`adapter.compile(compiledNqlBundle, options)` trusts that direct `CompiledNqlQuery` bundles are well-formed and semantically validated by the NQL compiler. The adapter still enforces SQL safety for emitted binding names, including identifier validation and binding/table or binding/binding collision checks before emitting `WITH` CTEs.
|
|
48
|
+
|
|
45
49
|
## Key features
|
|
46
50
|
|
|
47
51
|
- **Parameterized queries** — All user values use `$N` positional parameters; no SQL injection surface
|
package/dist/index.d.ts
CHANGED
|
@@ -261,6 +261,7 @@ interface CompiledResult {
|
|
|
261
261
|
interface CompilerOptions {
|
|
262
262
|
readonly naming?: NamingPlugin;
|
|
263
263
|
readonly schema?: string;
|
|
264
|
+
readonly dialectCapabilities?: DialectCapabilities;
|
|
264
265
|
/** Default primary key column name convention (default: 'id') */
|
|
265
266
|
readonly defaultPkColumnName?: string;
|
|
266
267
|
/** Convention for deriving FK column names: (tableName, pkName) => fkColumnName */
|
|
@@ -276,6 +277,7 @@ declare class PlanCompiler {
|
|
|
276
277
|
private readonly defaultPk;
|
|
277
278
|
private readonly deriveFk;
|
|
278
279
|
private readonly model;
|
|
280
|
+
private readonly dialectCapabilities;
|
|
279
281
|
private readonly bindingNames;
|
|
280
282
|
/** Mutable state shared with extracted condition/value compilation functions */
|
|
281
283
|
private state;
|
|
@@ -287,6 +289,8 @@ declare class PlanCompiler {
|
|
|
287
289
|
private rawJoins;
|
|
288
290
|
/** CTE nodes from include handlers (e.g., CTE strategy) */
|
|
289
291
|
private pendingCtes;
|
|
292
|
+
/** Local aliases for binding relation-column scalar subqueries. */
|
|
293
|
+
private bindingRelationColumnSubqueryIndex;
|
|
290
294
|
/**
|
|
291
295
|
* Maps relation-dotted include path → JOIN alias for multi-hop FK resolution.
|
|
292
296
|
* Populated as join decisions are compiled so later hops can find the
|
|
@@ -300,6 +304,7 @@ declare class PlanCompiler {
|
|
|
300
304
|
*/
|
|
301
305
|
private usedJoinAliases;
|
|
302
306
|
constructor(options?: CompilerOptions);
|
|
307
|
+
private childCompilerOptions;
|
|
303
308
|
/** Build immutable context for handler-based WHERE compilation */
|
|
304
309
|
private handlerCtx;
|
|
305
310
|
private findAliasForLegacySourceTable;
|
|
@@ -343,6 +348,9 @@ declare class PlanCompiler {
|
|
|
343
348
|
private createHandlerContext;
|
|
344
349
|
/** Build a fresh HandlerCompilerState sharing the current parameter array. */
|
|
345
350
|
private createHandlerState;
|
|
351
|
+
private schemaForRangeVar;
|
|
352
|
+
private isNqlBindingRoot;
|
|
353
|
+
private compileBindingRelationColumnSubquery;
|
|
346
354
|
private compileExpressionSubquery;
|
|
347
355
|
private compileGenericNqlFunction;
|
|
348
356
|
private compileNqlFunctionArg;
|
|
@@ -1067,6 +1075,8 @@ interface CompilerContext {
|
|
|
1067
1075
|
readonly naming: NamingPlugin;
|
|
1068
1076
|
/** Schema name for table qualification (optional) */
|
|
1069
1077
|
readonly schema?: string;
|
|
1078
|
+
/** Dialect capabilities for adapter-layer SQL surface gates */
|
|
1079
|
+
readonly dialectCapabilities?: DialectCapabilities;
|
|
1070
1080
|
/** Root table name for the query */
|
|
1071
1081
|
readonly rootTable: string;
|
|
1072
1082
|
/** Current table alias (for JOINs) */
|
|
@@ -1669,6 +1679,11 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1669
1679
|
getPoolInstance(): Pool;
|
|
1670
1680
|
/**
|
|
1671
1681
|
* Compile a plan to executable SQL.
|
|
1682
|
+
*
|
|
1683
|
+
* When passed a direct `CompiledNqlQuery`, the adapter trusts that the bundle
|
|
1684
|
+
* has already been semantically validated by the NQL compiler. This method
|
|
1685
|
+
* still performs adapter-owned SQL safety checks for emitted binding names
|
|
1686
|
+
* before CTE emission.
|
|
1672
1687
|
*/
|
|
1673
1688
|
compile<T = unknown>(plan: PlanReport | CompiledNqlQuery, options?: CompileOptions): CompiledQuery<T>;
|
|
1674
1689
|
/**
|