turbine-orm 0.81.0 → 0.90.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 +26 -25
- package/dist/checkout.d.ts +27 -2
- package/dist/checkout.js +75 -4
- package/dist/cjs/checkout.d.ts +27 -2
- package/dist/cjs/checkout.js +76 -3
- package/dist/cjs/cli/code-first-tags.d.ts +62 -0
- package/dist/cjs/cli/code-first-tags.js +124 -0
- package/dist/cjs/cli/compile-query.js +9 -0
- package/dist/cjs/cli/config.d.ts +35 -6
- package/dist/cjs/cli/config.js +17 -1
- package/dist/cjs/cli/destructive.d.ts +7 -4
- package/dist/cjs/cli/destructive.js +224 -20
- package/dist/cjs/cli/error-catalog.js +36 -0
- package/dist/cjs/cli/error-text.d.ts +15 -0
- package/dist/cjs/cli/error-text.js +40 -0
- package/dist/cjs/cli/index.d.ts +62 -4
- package/dist/cjs/cli/index.js +568 -108
- package/dist/cjs/cli/local-server-guard.d.ts +53 -0
- package/dist/cjs/cli/local-server-guard.js +119 -0
- package/dist/cjs/cli/local-server-output.d.ts +41 -0
- package/dist/cjs/cli/local-server-output.js +103 -0
- package/dist/cjs/cli/mcp.d.ts +8 -0
- package/dist/cjs/cli/mcp.js +121 -32
- package/dist/cjs/cli/migrate.d.ts +113 -5
- package/dist/cjs/cli/migrate.js +270 -21
- package/dist/cjs/cli/observe.d.ts +6 -1
- package/dist/cjs/cli/observe.js +85 -55
- package/dist/cjs/cli/pii-predicate-guard.d.ts +43 -23
- package/dist/cjs/cli/pii-predicate-guard.js +98 -37
- package/dist/cjs/cli/prisma-resolve.js +17 -13
- package/dist/cjs/cli/prisma-schema.js +12 -4
- package/dist/cjs/cli/studio-ui.generated.js +1 -1
- package/dist/cjs/cli/studio.d.ts +14 -2
- package/dist/cjs/cli/studio.js +244 -69
- package/dist/cjs/cli/ui.d.ts +1 -1
- package/dist/cjs/client.d.ts +558 -85
- package/dist/cjs/client.js +1270 -395
- package/dist/cjs/connection-guard.d.ts +13 -0
- package/dist/cjs/connection-guard.js +28 -0
- package/dist/cjs/connection-url.d.ts +51 -16
- package/dist/cjs/connection-url.js +67 -34
- package/dist/cjs/diagnostics.d.ts +81 -0
- package/dist/cjs/diagnostics.js +147 -0
- package/dist/cjs/dialect.d.ts +449 -20
- package/dist/cjs/dialect.js +117 -76
- package/dist/cjs/engine-config.d.ts +7 -6
- package/dist/cjs/errors.d.ts +126 -6
- package/dist/cjs/errors.js +256 -13
- package/dist/cjs/generate.d.ts +57 -7
- package/dist/cjs/generate.js +635 -279
- package/dist/cjs/global-filters-config.d.ts +59 -0
- package/dist/cjs/global-filters-config.js +367 -0
- package/dist/cjs/index.d.ts +9 -4
- package/dist/cjs/index.js +10 -2
- package/dist/cjs/introspect.d.ts +31 -6
- package/dist/cjs/introspect.js +108 -50
- package/dist/cjs/log-codes.d.ts +12 -0
- package/dist/cjs/log-codes.js +77 -0
- package/dist/cjs/logger.d.ts +87 -0
- package/dist/cjs/logger.js +98 -0
- package/dist/cjs/mssql.d.ts +8 -5
- package/dist/cjs/mssql.js +352 -65
- package/dist/cjs/mysql.d.ts +3 -5
- package/dist/cjs/mysql.js +420 -70
- package/dist/cjs/nested-write.d.ts +3 -0
- package/dist/cjs/nested-write.js +179 -114
- package/dist/cjs/pipeline-submittable.d.ts +12 -0
- package/dist/cjs/pipeline-submittable.js +118 -44
- package/dist/cjs/pipeline.js +21 -26
- package/dist/cjs/powdb-introspect.d.ts +5 -2
- package/dist/cjs/powdb-introspect.js +20 -15
- package/dist/cjs/powdb-shared.d.ts +36 -5
- package/dist/cjs/powdb-shared.js +67 -8
- package/dist/cjs/powdb.d.ts +4 -0
- package/dist/cjs/powdb.js +183 -51
- package/dist/cjs/powql.d.ts +394 -51
- package/dist/cjs/powql.js +1829 -284
- package/dist/cjs/prisma-compat.d.ts +23 -15
- package/dist/cjs/prisma-compat.js +507 -372
- package/dist/cjs/query/aggregates.d.ts +17 -1
- package/dist/cjs/query/aggregates.js +261 -29
- package/dist/cjs/query/batched-loader.d.ts +25 -6
- package/dist/cjs/query/batched-loader.js +103 -20
- package/dist/cjs/query/builder.d.ts +325 -184
- package/dist/cjs/query/builder.js +1452 -490
- package/dist/cjs/query/column-ref.d.ts +61 -0
- package/dist/cjs/query/column-ref.js +73 -0
- package/dist/cjs/query/compound-unique.d.ts +21 -0
- package/dist/cjs/query/compound-unique.js +98 -18
- package/dist/cjs/query/deferred.d.ts +53 -16
- package/dist/cjs/query/expr.d.ts +217 -0
- package/dist/cjs/query/expr.js +859 -0
- package/dist/cjs/query/filters.d.ts +155 -53
- package/dist/cjs/query/filters.js +613 -76
- package/dist/cjs/query/index.d.ts +2 -0
- package/dist/cjs/query/index.js +7 -1
- package/dist/cjs/query/json-value.d.ts +43 -0
- package/dist/cjs/query/json-value.js +59 -0
- package/dist/cjs/query/normalize-args.d.ts +87 -0
- package/dist/cjs/query/normalize-args.js +527 -0
- package/dist/cjs/query/option-surface.d.ts +16 -4
- package/dist/cjs/query/option-surface.js +57 -14
- package/dist/cjs/query/relation-names.d.ts +14 -0
- package/dist/cjs/query/relation-names.js +77 -18
- package/dist/cjs/query/relations.d.ts +30 -3
- package/dist/cjs/query/relations.js +219 -63
- package/dist/cjs/query/row-lock.d.ts +49 -0
- package/dist/cjs/query/row-lock.js +138 -0
- package/dist/cjs/query/sql-comment.d.ts +161 -0
- package/dist/cjs/query/sql-comment.js +381 -0
- package/dist/cjs/query/stream-idle.d.ts +132 -0
- package/dist/cjs/query/stream-idle.js +212 -0
- package/dist/cjs/query/table-client.d.ts +101 -0
- package/dist/cjs/query/table-client.js +74 -0
- package/dist/cjs/query/types.d.ts +677 -298
- package/dist/cjs/query/utils.d.ts +105 -6
- package/dist/cjs/query/utils.js +426 -19
- package/dist/cjs/query/warn-registry.d.ts +18 -0
- package/dist/cjs/query/warn-registry.js +18 -0
- package/dist/cjs/query/where-compile.d.ts +138 -14
- package/dist/cjs/query/where-compile.js +513 -29
- package/dist/cjs/query/where.d.ts +159 -59
- package/dist/cjs/query/where.js +716 -246
- package/dist/cjs/query/writes.d.ts +112 -50
- package/dist/cjs/query/writes.js +1498 -200
- package/dist/cjs/query-events.d.ts +4 -2
- package/dist/cjs/query-events.js +3 -1
- package/dist/cjs/realtime.d.ts +7 -3
- package/dist/cjs/realtime.js +13 -2
- package/dist/cjs/schema-builder.d.ts +55 -4
- package/dist/cjs/schema-builder.js +382 -18
- package/dist/cjs/schema-metadata.d.ts +21 -1
- package/dist/cjs/schema-metadata.js +29 -7
- package/dist/cjs/schema-sql.d.ts +75 -5
- package/dist/cjs/schema-sql.js +497 -45
- package/dist/cjs/schema.d.ts +26 -5
- package/dist/cjs/schema.js +110 -13
- package/dist/cjs/sql-placeholders.d.ts +56 -0
- package/dist/cjs/sql-placeholders.js +204 -0
- package/dist/cjs/sqlite.d.ts +75 -20
- package/dist/cjs/sqlite.js +593 -95
- package/dist/cjs/supplied-pool-types.d.ts +48 -0
- package/dist/cjs/supplied-pool-types.js +256 -0
- package/dist/cjs/transaction-control.d.ts +51 -0
- package/dist/cjs/transaction-control.js +316 -0
- package/dist/cjs/transaction-state.d.ts +342 -0
- package/dist/cjs/transaction-state.js +707 -0
- package/dist/cjs/typed-sql.d.ts +37 -3
- package/dist/cjs/typed-sql.js +102 -8
- package/dist/cli/code-first-tags.d.ts +62 -0
- package/dist/cli/code-first-tags.js +120 -0
- package/dist/cli/compile-query.js +9 -0
- package/dist/cli/config.d.ts +35 -6
- package/dist/cli/config.js +16 -1
- package/dist/cli/destructive.d.ts +7 -4
- package/dist/cli/destructive.js +224 -20
- package/dist/cli/error-catalog.js +36 -0
- package/dist/cli/error-text.d.ts +15 -0
- package/dist/cli/error-text.js +37 -0
- package/dist/cli/index.d.ts +62 -4
- package/dist/cli/index.js +569 -112
- package/dist/cli/local-server-guard.d.ts +53 -0
- package/dist/cli/local-server-guard.js +113 -0
- package/dist/cli/local-server-output.d.ts +41 -0
- package/dist/cli/local-server-output.js +98 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +121 -34
- package/dist/cli/migrate.d.ts +113 -5
- package/dist/cli/migrate.js +261 -21
- package/dist/cli/observe.d.ts +6 -1
- package/dist/cli/observe.js +84 -54
- package/dist/cli/pii-predicate-guard.d.ts +43 -23
- package/dist/cli/pii-predicate-guard.js +100 -35
- package/dist/cli/prisma-resolve.js +15 -11
- package/dist/cli/prisma-schema.js +12 -4
- package/dist/cli/studio-ui.generated.js +1 -1
- package/dist/cli/studio.d.ts +14 -2
- package/dist/cli/studio.js +246 -71
- package/dist/cli/ui.d.ts +1 -1
- package/dist/client.d.ts +558 -85
- package/dist/client.js +1275 -400
- package/dist/connection-guard.d.ts +13 -0
- package/dist/connection-guard.js +27 -0
- package/dist/connection-url.d.ts +51 -16
- package/dist/connection-url.js +63 -34
- package/dist/diagnostics.d.ts +81 -0
- package/dist/diagnostics.js +144 -0
- package/dist/dialect.d.ts +449 -20
- package/dist/dialect.js +115 -43
- package/dist/engine-config.d.ts +7 -6
- package/dist/errors.d.ts +126 -6
- package/dist/errors.js +252 -12
- package/dist/generate.d.ts +57 -7
- package/dist/generate.js +635 -281
- package/dist/global-filters-config.d.ts +59 -0
- package/dist/global-filters-config.js +361 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +4 -2
- package/dist/introspect.d.ts +31 -6
- package/dist/introspect.js +106 -50
- package/dist/log-codes.d.ts +12 -0
- package/dist/log-codes.js +74 -0
- package/dist/logger.d.ts +87 -0
- package/dist/logger.js +93 -0
- package/dist/mssql.d.ts +8 -5
- package/dist/mssql.js +354 -67
- package/dist/mysql.d.ts +3 -5
- package/dist/mysql.js +423 -73
- package/dist/nested-write.d.ts +3 -0
- package/dist/nested-write.js +177 -112
- package/dist/pipeline-submittable.d.ts +12 -0
- package/dist/pipeline-submittable.js +117 -44
- package/dist/pipeline.js +21 -26
- package/dist/powdb-introspect.d.ts +5 -2
- package/dist/powdb-introspect.js +21 -16
- package/dist/powdb-shared.d.ts +36 -5
- package/dist/powdb-shared.js +65 -8
- package/dist/powdb.d.ts +4 -0
- package/dist/powdb.js +183 -51
- package/dist/powql.d.ts +394 -51
- package/dist/powql.js +1836 -291
- package/dist/prisma-compat.d.ts +23 -15
- package/dist/prisma-compat.js +508 -373
- package/dist/query/aggregates.d.ts +17 -1
- package/dist/query/aggregates.js +263 -32
- package/dist/query/batched-loader.d.ts +25 -6
- package/dist/query/batched-loader.js +101 -21
- package/dist/query/builder.d.ts +325 -184
- package/dist/query/builder.js +1458 -495
- package/dist/query/column-ref.d.ts +61 -0
- package/dist/query/column-ref.js +66 -0
- package/dist/query/compound-unique.d.ts +21 -0
- package/dist/query/compound-unique.js +97 -19
- package/dist/query/deferred.d.ts +53 -16
- package/dist/query/expr.d.ts +217 -0
- package/dist/query/expr.js +848 -0
- package/dist/query/filters.d.ts +155 -53
- package/dist/query/filters.js +597 -72
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.js +4 -0
- package/dist/query/json-value.d.ts +43 -0
- package/dist/query/json-value.js +54 -0
- package/dist/query/normalize-args.d.ts +87 -0
- package/dist/query/normalize-args.js +517 -0
- package/dist/query/option-surface.d.ts +16 -4
- package/dist/query/option-surface.js +56 -13
- package/dist/query/relation-names.d.ts +14 -0
- package/dist/query/relation-names.js +77 -19
- package/dist/query/relations.d.ts +30 -3
- package/dist/query/relations.js +220 -67
- package/dist/query/row-lock.d.ts +49 -0
- package/dist/query/row-lock.js +131 -0
- package/dist/query/sql-comment.d.ts +161 -0
- package/dist/query/sql-comment.js +374 -0
- package/dist/query/stream-idle.d.ts +132 -0
- package/dist/query/stream-idle.js +203 -0
- package/dist/query/table-client.d.ts +101 -0
- package/dist/query/table-client.js +70 -0
- package/dist/query/types.d.ts +677 -298
- package/dist/query/utils.d.ts +105 -6
- package/dist/query/utils.js +414 -18
- package/dist/query/warn-registry.d.ts +18 -0
- package/dist/query/warn-registry.js +18 -0
- package/dist/query/where-compile.d.ts +138 -14
- package/dist/query/where-compile.js +508 -31
- package/dist/query/where.d.ts +159 -59
- package/dist/query/where.js +711 -248
- package/dist/query/writes.d.ts +112 -50
- package/dist/query/writes.js +1496 -202
- package/dist/query-events.d.ts +4 -2
- package/dist/query-events.js +3 -1
- package/dist/realtime.d.ts +7 -3
- package/dist/realtime.js +13 -2
- package/dist/schema-builder.d.ts +55 -4
- package/dist/schema-builder.js +381 -18
- package/dist/schema-metadata.d.ts +21 -1
- package/dist/schema-metadata.js +28 -7
- package/dist/schema-sql.d.ts +75 -5
- package/dist/schema-sql.js +494 -44
- package/dist/schema.d.ts +26 -5
- package/dist/schema.js +109 -13
- package/dist/sql-placeholders.d.ts +56 -0
- package/dist/sql-placeholders.js +200 -0
- package/dist/sqlite.d.ts +75 -20
- package/dist/sqlite.js +597 -99
- package/dist/supplied-pool-types.d.ts +48 -0
- package/dist/supplied-pool-types.js +247 -0
- package/dist/transaction-control.d.ts +51 -0
- package/dist/transaction-control.js +311 -0
- package/dist/transaction-state.d.ts +342 -0
- package/dist/transaction-state.js +696 -0
- package/dist/typed-sql.d.ts +37 -3
- package/dist/typed-sql.js +100 -8
- package/package.json +7 -4
- package/skills/turbine-orm/SKILL.md +56 -6
package/dist/powql.d.ts
CHANGED
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import type { PowdbPool } from './powdb.js';
|
|
38
38
|
import type { MiddlewareFn, QueryInterfaceOptions } from './query/index.js';
|
|
39
|
-
import type {
|
|
39
|
+
import type { TableClient } from './query/table-client.js';
|
|
40
|
+
import type { AggregateArgs, AggregateResultOf, CountArgs, CreateArgs, CreateManyArgs, DeleteArgs, DeleteManyArgs, FieldResult, FindManyArgs, FindUniqueArgs, GroupByArgs, GroupByResult, OptionalInput, QueryResult, TypedWithClause, UpdateArgs, UpdateManyArgs, UpsertArgs } from './query/types.js';
|
|
40
41
|
import { type SchemaMetadata } from './schema.js';
|
|
41
42
|
/**
|
|
42
43
|
* Max values one `in` / `notIn` on a PowDB-native `datetime` column may carry.
|
|
@@ -50,12 +51,28 @@ import { type SchemaMetadata } from './schema.js';
|
|
|
50
51
|
* a loader can never build a chain the engine will reject.
|
|
51
52
|
*/
|
|
52
53
|
export declare const MAX_POWQL_DATETIME_TERMS = 32;
|
|
54
|
+
/**
|
|
55
|
+
* Max distinct keys one client-side relation filter may resolve to.
|
|
56
|
+
*
|
|
57
|
+
* A relation filter becomes a literal `in (…)` list on the local key, and the
|
|
58
|
+
* engine evaluates that list per row, so the cost grows with rows times keys
|
|
59
|
+
* (measured on the 0.20 addon over 100k rows: about 0.3 s per 1,000 keys).
|
|
60
|
+
* Past this bound the filter is refused with a typed error naming the bound,
|
|
61
|
+
* instead of building a statement whose cost has no ceiling.
|
|
62
|
+
*/
|
|
63
|
+
export declare const MAX_RELATION_FILTER_KEYS = 10000;
|
|
64
|
+
/** The relations type argument of an untyped accessor: none known. */
|
|
65
|
+
type NoRelations = {};
|
|
53
66
|
/**
|
|
54
67
|
* The PowQL query interface. Constructed by `turbinePowDB` via the
|
|
55
|
-
* `queryInterfaceFactory` seam
|
|
56
|
-
*
|
|
68
|
+
* `queryInterfaceFactory` seam. `implements TableClient` makes a method the SQL
|
|
69
|
+
* accessor has and this class lacks, or one whose signature differs, a build
|
|
70
|
+
* error. Where a method's result is narrowed by `select` / `omit` / `with`, a
|
|
71
|
+
* public overload signature carries the SQL accessor's typing and the
|
|
72
|
+
* implementation below it is typed on the plain row; both return the same
|
|
73
|
+
* projected, relation-loaded rows at run time.
|
|
57
74
|
*/
|
|
58
|
-
export declare class PowqlInterface<T extends object = Record<string, unknown>> {
|
|
75
|
+
export declare class PowqlInterface<T extends object = Record<string, unknown>> implements TableClient<T> {
|
|
59
76
|
private readonly pool;
|
|
60
77
|
private readonly table;
|
|
61
78
|
private readonly schema;
|
|
@@ -65,7 +82,10 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
65
82
|
private readonly defaultLimit?;
|
|
66
83
|
private readonly warnOnUnlimited;
|
|
67
84
|
private readonly onQuery?;
|
|
68
|
-
|
|
85
|
+
/** Where this interface's log lines go: the client's logger, else the console. */
|
|
86
|
+
private readonly logger;
|
|
87
|
+
/** The logger for advice lines, or `undefined` when `diagnostics` turns advice off. */
|
|
88
|
+
private readonly advice;
|
|
69
89
|
constructor(pool: PowdbPool, table: string, schema: SchemaMetadata, middlewares?: MiddlewareFn[], options?: QueryInterfaceOptions);
|
|
70
90
|
/**
|
|
71
91
|
* Resolve a camelCase field name (or raw snake) to its column metadata.
|
|
@@ -139,6 +159,12 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
139
159
|
* and coercion stays unambiguous. Non-finite floats are still rejected.
|
|
140
160
|
*/
|
|
141
161
|
private writeRef;
|
|
162
|
+
/**
|
|
163
|
+
* A PowQL `int` column declared as an integer type (not a Date, which is
|
|
164
|
+
* stored as int micros, and not a column whose declared type is something
|
|
165
|
+
* else).
|
|
166
|
+
*/
|
|
167
|
+
private isIntegerCol;
|
|
142
168
|
private isFloatCol;
|
|
143
169
|
/**
|
|
144
170
|
* The bound pool's {@link PowdbCapabilities}. Falls back to the trusted-caller
|
|
@@ -215,15 +241,6 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
215
241
|
* which is the divergence class the projection resolver already cost.
|
|
216
242
|
*/
|
|
217
243
|
private withDeclaredRelationNames;
|
|
218
|
-
/**
|
|
219
|
-
* Caller args in canonical form: declared relation spellings, and `take` /
|
|
220
|
-
* `skip` folded into `limit` / `offset`.
|
|
221
|
-
*
|
|
222
|
-
* Same composition as `QueryInterface.normalizeArgs` and here for the same
|
|
223
|
-
* reason the method above is here: nothing about a parallel implementation
|
|
224
|
-
* makes a core rule arrive on its own, and an engine that reads `take` but
|
|
225
|
-
* not `skip` pages differently from one that reads both.
|
|
226
|
-
*/
|
|
227
244
|
/**
|
|
228
245
|
* Fill in the deterministic per-relation ordering `stableRelationOrder` asks
|
|
229
246
|
* for, through the shared transform the SQL engines use.
|
|
@@ -233,8 +250,48 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
233
250
|
* option whose entire purpose is that they do not. Same resolution as
|
|
234
251
|
* QueryInterface: a per-query flag wins, else the client-level default.
|
|
235
252
|
*/
|
|
253
|
+
/** `take` / `skip` inside every `with` level folded into `limit` / `offset` (shared rule). */
|
|
254
|
+
private withRelationPagination;
|
|
236
255
|
private withStableRelationOrder;
|
|
256
|
+
/**
|
|
257
|
+
* Caller args in canonical form: `undefined` pruned (query/normalize-args.ts),
|
|
258
|
+
* declared relation spellings, stable relation order, and `take` / `skip`
|
|
259
|
+
* folded into `limit` / `offset` at the top level and inside `with`. Same composition as
|
|
260
|
+
* `QueryInterface.normalizeArgs`, run at the top of every public operation,
|
|
261
|
+
* so the two engines agree about what each argument means.
|
|
262
|
+
*
|
|
263
|
+
* `refuseEmptiedWhere` names the single-row read (`findFirst`,
|
|
264
|
+
* `findFirstOrThrow`) that refuses a `where` whose every key was `undefined`.
|
|
265
|
+
*/
|
|
237
266
|
private normalizeArgs;
|
|
267
|
+
/**
|
|
268
|
+
* The per-query `timeout` and `relationLoadStrategy`, checked with the SQL
|
|
269
|
+
* engines' rule and message: a timeout is a positive number of ms up to
|
|
270
|
+
* {@link MAX_TIMEOUT_MS} (or 0 for none), a strategy one of the SQL engines' values.
|
|
271
|
+
*/
|
|
272
|
+
private assertQueryOptions;
|
|
273
|
+
/**
|
|
274
|
+
* Whether `cursor` carries a value, after the SQL engines' cursor checks: a
|
|
275
|
+
* cursor that names no row (`null`, `{}`) is E003, and each value is a row's
|
|
276
|
+
* value under the shared rule (`cursorFieldValue`). Unknown fields are E003.
|
|
277
|
+
*/
|
|
278
|
+
private cursorCarriesValues;
|
|
279
|
+
/**
|
|
280
|
+
* The SQL engines' cursor placement rule (query/builder.ts `planCursor`),
|
|
281
|
+
* so a cursor they refuse is the same E003 here and only a cursor they would
|
|
282
|
+
* serve reaches PowDB's E017. The page order is `orderBy` plus the
|
|
283
|
+
* tiebreaker; the cursor must carry a value for every column of it, or name
|
|
284
|
+
* one row by a unique key (the shared findUnique rule).
|
|
285
|
+
*/
|
|
286
|
+
private assertCursorPlaceable;
|
|
287
|
+
/**
|
|
288
|
+
* A paginated `findMany` (`limit` / `offset`) whose `orderBy` can tie gets
|
|
289
|
+
* a tiebreaker appended in the last term's direction (the primary key, else
|
|
290
|
+
* the first unique key on NOT NULL columns), as on the SQL engines, so a page
|
|
291
|
+
* boundary cannot fall between tied rows in a different order on each page.
|
|
292
|
+
* Returns `args` itself when the order is already total or nothing pages.
|
|
293
|
+
*/
|
|
294
|
+
private completePageOrder;
|
|
238
295
|
/**
|
|
239
296
|
* `jsonEncoding` selects between PostgreSQL's `json_build_object` and
|
|
240
297
|
* `json_build_array` row encodings for relation subqueries. PowQL emits no
|
|
@@ -243,7 +300,13 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
243
300
|
* Refused for the same reason `forceCustomPlan` is.
|
|
244
301
|
*/
|
|
245
302
|
private assertNoJsonEncoding;
|
|
303
|
+
/** `optimisticLock` is an `update` option; the shared refusal and message from query/writes.ts. */
|
|
304
|
+
private assertNoOptimisticLock;
|
|
246
305
|
private assertNoForceCustomPlan;
|
|
306
|
+
/** `lock` (a row-locking read): PowDB has no row locks. */
|
|
307
|
+
private assertNoRowLock;
|
|
308
|
+
/** `_percentile`: PowQL has no percentile aggregate. */
|
|
309
|
+
private assertNoPercentile;
|
|
247
310
|
/** See query/compound-unique.ts: one rule and one message across engines. */
|
|
248
311
|
private assertIdentifiesOneRow;
|
|
249
312
|
/**
|
|
@@ -273,6 +336,11 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
273
336
|
* an already-RESOLVED where (relation filters pre-resolved to literal in-lists
|
|
274
337
|
* by {@link resolveRelationFilters}): the relation-key branch below still
|
|
275
338
|
* throws, so an unresolved relation filter can never leak into a join.
|
|
339
|
+
*
|
|
340
|
+
* `NOT` here is PowQL's two-valued complement. A caller's where reaches this
|
|
341
|
+
* only through {@link sqlTrueWhere} (inside {@link resolveRelationFilters},
|
|
342
|
+
* and in {@link applyGlobalFilter}), which leaves `NOT` only where the two
|
|
343
|
+
* readings agree.
|
|
276
344
|
*/
|
|
277
345
|
private buildWhere;
|
|
278
346
|
/**
|
|
@@ -306,6 +374,40 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
306
374
|
* read through `introspectPowdbDatabase`, or hand-written metadata.
|
|
307
375
|
*/
|
|
308
376
|
private assertDatetimePredicateSupported;
|
|
377
|
+
/**
|
|
378
|
+
* Refuse a value comparison on a `numeric` / `decimal` column. PowDB stores
|
|
379
|
+
* those as `str` (it has no decimal type, and `float` would lose digits), so
|
|
380
|
+
* every comparison, ordering and aggregate the engine could run on them is a
|
|
381
|
+
* TEXT comparison: `'7.50' > '7.5'`, `'10' < '9'`, and `'7.5' = '7.50'` is
|
|
382
|
+
* false; arithmetic on a `str` yields NULL. Null checks, reads and plain
|
|
383
|
+
* writes are unaffected.
|
|
384
|
+
*/
|
|
385
|
+
private assertDecimalComparable;
|
|
386
|
+
/** The labels of `col`'s enum type, or `undefined` when it is not an enum column. */
|
|
387
|
+
private enumLabels;
|
|
388
|
+
/**
|
|
389
|
+
* E003 unless `value` is one of the enum column's labels. PostgreSQL refuses
|
|
390
|
+
* any other value (22P02, which Turbine reports as E003) whether it is
|
|
391
|
+
* written or compared, and the label set is exact: case and spelling count.
|
|
392
|
+
* The value itself is not echoed, only its kind.
|
|
393
|
+
*/
|
|
394
|
+
private assertEnumLabel;
|
|
395
|
+
/**
|
|
396
|
+
* Refuse an ORDERING of an enum column (orderBy, `_min` / `_max`). PostgreSQL
|
|
397
|
+
* orders an enum by the position of its labels in the type's declaration;
|
|
398
|
+
* PowDB stores the label text and would order it alphabetically, a different
|
|
399
|
+
* answer with no error. Range filters (`gt` / `gte` / `lt` / `lte`) do not come
|
|
400
|
+
* here: they compile to the exact set of labels on that side of the operand.
|
|
401
|
+
*/
|
|
402
|
+
private assertEnumOrderable;
|
|
403
|
+
/**
|
|
404
|
+
* An aggregate over an enum column: `_min` / `_max` order it (see
|
|
405
|
+
* {@link assertEnumOrderable}); `_sum` / `_avg` have no meaning on a label,
|
|
406
|
+
* which PostgreSQL refuses as E003 (42883, no such function).
|
|
407
|
+
*/
|
|
408
|
+
private assertEnumAggregate;
|
|
409
|
+
/** The E003 for an operand that is not a comparable value for its column. */
|
|
410
|
+
private operandError;
|
|
309
411
|
/** Build a single `field: value | operator` condition. */
|
|
310
412
|
private buildFieldCondition;
|
|
311
413
|
/**
|
|
@@ -348,14 +450,47 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
348
450
|
private buildJsonPathCondition;
|
|
349
451
|
/** Bind a value, lowercasing for case-insensitive comparisons. */
|
|
350
452
|
private bind;
|
|
351
|
-
/**
|
|
352
|
-
|
|
453
|
+
/**
|
|
454
|
+
* A bound filter operand. An integral number compared with a float column is
|
|
455
|
+
* cast to float in the statement: the typed wire carries an integral number as
|
|
456
|
+
* an int, and the engine compares int with float by type tag inside `not`,
|
|
457
|
+
* `or` and `in` (on 0.20 `not (.rating = 4)` matches the 4.0 row and
|
|
458
|
+
* `.rating in (4, 5)` matches nothing).
|
|
459
|
+
*/
|
|
460
|
+
private filterOperand;
|
|
461
|
+
/**
|
|
462
|
+
* `contains` / `startsWith` / `endsWith` against `expr` (a column or a JSON
|
|
463
|
+
* path), matching `value` literally.
|
|
464
|
+
*
|
|
465
|
+
* PowQL's `like` has NO escape character: `%` and `_` in the pattern are
|
|
466
|
+
* always wildcards and `\` is an ordinary character. So a prefix or suffix
|
|
467
|
+
* test never goes through `like`: it compares the leading or trailing
|
|
468
|
+
* `length($v)` characters with `substring`, which is exact for every value
|
|
469
|
+
* on every engine version (and sidesteps the pre-0.27 matcher, which missed
|
|
470
|
+
* text containing a literal `%`). `contains` has no such form, since PowQL
|
|
471
|
+
* has no position function, so a value carrying `%` or `_` is refused rather
|
|
472
|
+
* than sent as a pattern that means something else.
|
|
473
|
+
*/
|
|
474
|
+
private buildStringMatch;
|
|
353
475
|
/**
|
|
354
476
|
* `lhs [not] in ($1, $2, …)`, empty list collapses to a constant.
|
|
355
477
|
*
|
|
356
478
|
* A PowDB-native `datetime` column takes the expanded form instead (see
|
|
357
479
|
* {@link buildDatetimeInList}): its `in` list is still broken upstream at 0.20.
|
|
358
480
|
*/
|
|
481
|
+
/**
|
|
482
|
+
* The enum-specific shapes of one operator on an enum column, or `undefined`
|
|
483
|
+
* for an operator compiled the ordinary way (equality, `in` / `notIn`, `not`,
|
|
484
|
+
* whose labels {@link param} checks).
|
|
485
|
+
*
|
|
486
|
+
* `gt` / `gte` / `lt` / `lte` compile to `in` over the labels on that side of
|
|
487
|
+
* the operand in DECLARATION order, which is what PostgreSQL compares; the
|
|
488
|
+
* text comparison PowDB would run is alphabetical, a different answer. A null
|
|
489
|
+
* operand matches no row, as `col > NULL` does. Case-insensitive matching and
|
|
490
|
+
* `contains` / `startsWith` / `endsWith` are E003: PostgreSQL has no `lower`
|
|
491
|
+
* or `LIKE` on an enum (42883).
|
|
492
|
+
*/
|
|
493
|
+
private enumRangeCondition;
|
|
359
494
|
private buildInList;
|
|
360
495
|
/**
|
|
361
496
|
* `in` / `not in` on a PowDB-native `datetime` column, expanded into the
|
|
@@ -405,31 +540,115 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
405
540
|
*/
|
|
406
541
|
private keyChunkSize;
|
|
407
542
|
/**
|
|
408
|
-
* Pre-resolve every relation filter
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
* emits only `in (<literal list>)`.
|
|
543
|
+
* Pre-resolve every relation filter in a where clause into a plain scalar
|
|
544
|
+
* condition on the **local key**, by running the inner predicate as its own
|
|
545
|
+
* query and materializing the matching keys as a literal list. The compiled
|
|
546
|
+
* where is then relation-free and `buildWhere` emits only `in (<literal list>)`.
|
|
413
547
|
*
|
|
414
548
|
* Why not an IN-subquery (`.k in (Target filter <e> { .fk })`)? PowDB's
|
|
415
549
|
* executor caches a subquery's result by **plan shape, ignoring the literal**,
|
|
416
550
|
* so a second subquery of the same shape with a different value returns the
|
|
417
551
|
* first one's stale rows (reproduced live on the embedded engine; the
|
|
418
552
|
* single-statement literal `in (list)` form is always correct). Resolving
|
|
419
|
-
* client-side trades extra round-trips for correctness, and recurses
|
|
553
|
+
* client-side trades extra round-trips for correctness, and recurses: nested
|
|
420
554
|
* relation filters in the inner predicate resolve when the target query runs.
|
|
555
|
+
*
|
|
556
|
+
* `skip` is the query's `skipGlobalFilters`, forwarded to every target query
|
|
557
|
+
* so the target's global filter bounds the related rows exactly as the SQL
|
|
558
|
+
* engines' EXISTS does, and an opt-out reaches the targets as it does there.
|
|
421
559
|
*/
|
|
422
560
|
private resolveRelationFilters;
|
|
423
|
-
/**
|
|
561
|
+
/**
|
|
562
|
+
* {@link resolveRelationFilters} over a where already in {@link sqlTrueWhere}'s
|
|
563
|
+
* form (`AND` / `OR` arrays, `NOT` objects).
|
|
564
|
+
*/
|
|
565
|
+
private resolveRelationFiltersIn;
|
|
566
|
+
/**
|
|
567
|
+
* Resolve one relation filter to a relation-free condition on the local key,
|
|
568
|
+
* with the SQL engines' meaning for every branch:
|
|
569
|
+
*
|
|
570
|
+
* some / is EXISTS a related row matching the inner where
|
|
571
|
+
* none / isNot NOT EXISTS such a row (true for a NULL local key)
|
|
572
|
+
* every NOT EXISTS a related row for which the inner where is FALSE
|
|
573
|
+
* is: null NOT EXISTS any related row
|
|
574
|
+
* isNot: null EXISTS a related row
|
|
575
|
+
*
|
|
576
|
+
* A bare object on a to-one relation is an implicit `is` (the shared
|
|
577
|
+
* {@link normalizeRelationFilter} rule). Branches combine with AND. A shape
|
|
578
|
+
* that names no branch, or names something else, is refused: compiling it to
|
|
579
|
+
* nothing would match every row, and a mutation carrying it would write them.
|
|
580
|
+
* Returns `null` when every branch key is `undefined` (an absent filter).
|
|
581
|
+
*/
|
|
424
582
|
private resolveRelationCondition;
|
|
425
|
-
/**
|
|
426
|
-
private
|
|
583
|
+
/** A fresh interface over a relation's target table, for an internal fetch. */
|
|
584
|
+
private relationTargetQi;
|
|
585
|
+
/**
|
|
586
|
+
* `EXISTS` (or `NOT EXISTS`, when `exists` is false) a related row matching
|
|
587
|
+
* `inner`, as a condition on this table's local key.
|
|
588
|
+
*
|
|
589
|
+
* The NOT EXISTS form keeps a NULL local key: such a row has no related row,
|
|
590
|
+
* so it qualifies. PowQL's `not in` alone would drop it.
|
|
591
|
+
*/
|
|
592
|
+
private relationMatch;
|
|
593
|
+
/**
|
|
594
|
+
* hasMany / hasOne / belongsTo: the local field, and the distinct correlation
|
|
595
|
+
* keys of the target rows matching `inner` (inside the target's global filter).
|
|
596
|
+
* hasMany/hasOne: local = our referenceKey, collected = the child's foreignKey.
|
|
597
|
+
* belongsTo: local = our foreignKey, collected = the target's referenceKey.
|
|
598
|
+
*/
|
|
599
|
+
private directRelationKeys;
|
|
600
|
+
/**
|
|
601
|
+
* The distinct non-null values of `field` over this table's rows matching
|
|
602
|
+
* `where` (inside this table's global filter, honouring `skip`), refused
|
|
603
|
+
* past {@link MAX_RELATION_FILTER_KEYS}.
|
|
604
|
+
*/
|
|
605
|
+
private collectRelationKeys;
|
|
606
|
+
/** Dedupe correlation keys by value (a Date or bigint by its value, not identity) and enforce the cap. */
|
|
607
|
+
private distinctKeys;
|
|
608
|
+
/** manyToMany: the source key field, and the source keys linked (through the junction) to targets matching `inner`. */
|
|
609
|
+
private manyToManySourceKeys;
|
|
610
|
+
/**
|
|
611
|
+
* Rows where `where` is TRUE under SQL three-valued logic. PowQL's own
|
|
612
|
+
* evaluation already excludes a NULL from every comparison, so this differs
|
|
613
|
+
* from `where` only under `NOT`, where PowQL takes the plain complement and
|
|
614
|
+
* SQL keeps a NULL comparison unknown.
|
|
615
|
+
*
|
|
616
|
+
* Combinators are read by the shared {@link combinatorBranches} rule, so a
|
|
617
|
+
* shape the SQL engines refuse is refused here (E003), and the output uses
|
|
618
|
+
* one spelling: `AND` / `OR` arrays and `NOT` objects. `OR: []` stays as
|
|
619
|
+
* written and compiles to no row.
|
|
620
|
+
*/
|
|
621
|
+
private sqlTrueWhere;
|
|
622
|
+
/**
|
|
623
|
+
* Rows where `where` is FALSE under SQL three-valued logic, the complement
|
|
624
|
+
* PowQL's two-valued `not` cannot express: a comparison against a NULL
|
|
625
|
+
* column is unknown, which is neither TRUE nor FALSE, so the row belongs to
|
|
626
|
+
* neither set. Relation filters (EXISTS) are two-valued and negate plainly.
|
|
627
|
+
*
|
|
628
|
+
* A sub-where that compiles to no condition is TRUE, so it is FALSE for no
|
|
629
|
+
* row and contributes nothing; `OR: []` is FALSE for every row.
|
|
630
|
+
*/
|
|
631
|
+
private sqlFalseWhere;
|
|
632
|
+
/**
|
|
633
|
+
* Whether a where compiles to no condition, as {@link buildWhere} and the
|
|
634
|
+
* SQL where walk both read it: only absent keys, and `AND` / `NOT` whose
|
|
635
|
+
* branches all compile to nothing (`AND: []`, `NOT: [{}]`). Any `OR` is a
|
|
636
|
+
* condition: `OR: []` matches no row, and an `OR` with a branch that has no
|
|
637
|
+
* condition is constant TRUE (`OR: [{}]`), which `NOT` negates. So is any
|
|
638
|
+
* column or relation key.
|
|
639
|
+
*/
|
|
640
|
+
private compilesToNothing;
|
|
641
|
+
/** A where clause that matches every row (the primary key is null or not null). */
|
|
642
|
+
private trueWhere;
|
|
643
|
+
/** A where clause that matches no row (an empty `in` on the primary key). */
|
|
644
|
+
private falseWhere;
|
|
427
645
|
/**
|
|
428
646
|
* Resolve the set of columns to project, honouring `select` / `omit` and the
|
|
429
647
|
* query-level `includePii` opt-in. PII-tagged (`defineSchema` `pii: true`)
|
|
430
648
|
* columns are EXCLUDED from a default (or omit-only) projection unless
|
|
431
|
-
* `includePii` is
|
|
432
|
-
*
|
|
649
|
+
* `includePii: UNSAFE` is passed, and a `select` naming one without it is
|
|
650
|
+
* refused (E003), as on the SQL engines. Untagged tables project exactly as
|
|
651
|
+
* before.
|
|
433
652
|
*/
|
|
434
653
|
/**
|
|
435
654
|
* Resolve one projection field name, or throw. PowQL already refused an
|
|
@@ -472,6 +691,14 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
472
691
|
* every consumer of the key (relation stitching, reselect) has finished with
|
|
473
692
|
* it. A no-op, and free, when nothing was forced.
|
|
474
693
|
*/
|
|
694
|
+
/**
|
|
695
|
+
* The columns of this table that the post-fetch relation loaders read off
|
|
696
|
+
* each parent row for `withClause`: a belongsTo's foreign key, a hasMany /
|
|
697
|
+
* hasOne / manyToMany's reference key, and the same for every relation a
|
|
698
|
+
* `_count` names. An unknown name contributes nothing; the loader raises its
|
|
699
|
+
* E005.
|
|
700
|
+
*/
|
|
701
|
+
private loaderParentKeyColumns;
|
|
475
702
|
private stripForcedPk;
|
|
476
703
|
/**
|
|
477
704
|
* The snake_case names of this table's PII-tagged columns. Empty for a table
|
|
@@ -582,7 +809,7 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
582
809
|
* coerces its string cells correctly. Defaults to the pool capability for the
|
|
583
810
|
* rare caller with no per-result flag (hand-built test pools). */
|
|
584
811
|
private shape;
|
|
585
|
-
findMany(args?: FindManyArgs<T>): Promise<T[]>;
|
|
812
|
+
findMany<W extends TypedWithClause = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args?: FindManyArgs<T, NoRelations, W, S, O>): Promise<QueryResult<T, NoRelations, W, S, O>[]>;
|
|
586
813
|
/**
|
|
587
814
|
* Compile the findMany select into PowQL (no execution), pushing values into
|
|
588
815
|
* `params`. Returns the query plus the RESOLVED where (relation filters
|
|
@@ -613,10 +840,10 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
613
840
|
* too, so both engines agree.
|
|
614
841
|
*/
|
|
615
842
|
explain(args?: FindManyArgs<T>): Promise<string[]>;
|
|
616
|
-
findUnique(args: FindUniqueArgs<T>): Promise<T | null>;
|
|
617
|
-
findFirst(args?: FindManyArgs<T>): Promise<T | null>;
|
|
618
|
-
findUniqueOrThrow(args: FindUniqueArgs<T>): Promise<T
|
|
619
|
-
findFirstOrThrow(args?: FindManyArgs<T>): Promise<T
|
|
843
|
+
findUnique<W extends TypedWithClause = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: FindUniqueArgs<T, NoRelations, W, S, O>): Promise<QueryResult<T, NoRelations, W, S, O> | null>;
|
|
844
|
+
findFirst<W extends TypedWithClause = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args?: FindManyArgs<T, NoRelations, W, S, O>): Promise<QueryResult<T, NoRelations, W, S, O> | null>;
|
|
845
|
+
findUniqueOrThrow<W extends TypedWithClause = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: FindUniqueArgs<T, NoRelations, W, S, O>): Promise<QueryResult<T, NoRelations, W, S, O>>;
|
|
846
|
+
findFirstOrThrow<W extends TypedWithClause = {}, S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args?: FindManyArgs<T, NoRelations, W, S, O>): Promise<QueryResult<T, NoRelations, W, S, O>>;
|
|
620
847
|
/**
|
|
621
848
|
* Load each requested relation for `parents` and attach it onto each row.
|
|
622
849
|
*
|
|
@@ -629,6 +856,32 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
629
856
|
* either way (the join reuses the same stitch / shape helpers).
|
|
630
857
|
*/
|
|
631
858
|
private loadRelations;
|
|
859
|
+
/**
|
|
860
|
+
* Refuse a `_count` anywhere below the top-level `with`, as the SQL engines
|
|
861
|
+
* do (E005, their message). Checked over the whole tree before anything runs,
|
|
862
|
+
* because a loader re-enters the child table's public findMany, where a
|
|
863
|
+
* nested `_count` would otherwise read as top level and be counted.
|
|
864
|
+
*/
|
|
865
|
+
private assertCountTopLevelOnly;
|
|
866
|
+
/**
|
|
867
|
+
* The reserved `with: { _count: ... }` key: one count per selected to-many
|
|
868
|
+
* relation, attached as `_count: { rel: n }` (0 for a parent with no rows),
|
|
869
|
+
* which is the SQL engines' output. The relations are selected by the shared
|
|
870
|
+
* `resolveCountRelations`, so `true` counts every to-many relation and the
|
|
871
|
+
* refusals match. Each count honours the counted table's global filter the
|
|
872
|
+
* way the SQL engines' correlated `COUNT(*)` does: hasMany counts the
|
|
873
|
+
* surviving child rows, manyToMany counts junction rows whose TARGET
|
|
874
|
+
* survives. One grouped query per relation per key chunk.
|
|
875
|
+
*/
|
|
876
|
+
private loadRelationCounts;
|
|
877
|
+
/** Child rows per parent key for a hasMany `_count`, through the child's own groupBy. */
|
|
878
|
+
private countHasMany;
|
|
879
|
+
/**
|
|
880
|
+
* Junction rows per parent key for a manyToMany `_count`. When the target
|
|
881
|
+
* table has a global filter in force, only junction rows whose target row
|
|
882
|
+
* survives it are counted, as the SQL engines' `EXISTS` on the target does.
|
|
883
|
+
*/
|
|
884
|
+
private countManyToMany;
|
|
632
885
|
/**
|
|
633
886
|
* manyToMany nested read, a three-hop batched loader (no `json_agg`/join
|
|
634
887
|
* pushdown): (1) read the junction rows for all parents in `sourceKey in (…)`
|
|
@@ -707,6 +960,8 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
707
960
|
* to literal in-lists before the base query ran); the relation where is resolved
|
|
708
961
|
* on the target the same way before qualifying, so a nested relation filter in
|
|
709
962
|
* the relation `where` never reaches the join unresolved. Params bind in order.
|
|
963
|
+
* Each side carries its own table's global filter under the query's `skip`,
|
|
964
|
+
* so the join returns exactly the rows the loaders would.
|
|
710
965
|
*/
|
|
711
966
|
private joinFilter;
|
|
712
967
|
/** Group join rows by their (normalized) `__tpk`, stripping it and shaping each child. */
|
|
@@ -762,6 +1017,10 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
762
1017
|
* Aliases share the parent statement's counter, so arbitrarily deep and
|
|
763
1018
|
* self-referential trees stay collision-free (the same discipline as the SQL
|
|
764
1019
|
* engine's json_agg subqueries).
|
|
1020
|
+
*
|
|
1021
|
+
* The target's global filter is ANDed into the block's filter at every level,
|
|
1022
|
+
* under the query's `skip`, exactly as the SQL engines AND it into each
|
|
1023
|
+
* relation subquery: a block that omitted it handed back another tenant's rows.
|
|
765
1024
|
*/
|
|
766
1025
|
private buildNestedBlock;
|
|
767
1026
|
/**
|
|
@@ -807,7 +1066,8 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
807
1066
|
* link path would regress a hot path for no gain. Requires: single-column
|
|
808
1067
|
* belongsTo; no relation `with` / `where` / `distinct` / `orderBy` /
|
|
809
1068
|
* `limit` / `offset` (a scalar path has no per-hop filter/order and cannot
|
|
810
|
-
* reproduce those, such inputs stay on the loader for exact parity);
|
|
1069
|
+
* reproduce those, such inputs stay on the loader for exact parity); no
|
|
1070
|
+
* global filter on the target, for the same reason; a link
|
|
811
1071
|
* name and all projected columns that are bare identifiers (a quoted segment in
|
|
812
1072
|
* a dotted link path is outside the verified spelling, fall back); and a
|
|
813
1073
|
* DECLARED link that verifiably matches (`findMatchingLink`).
|
|
@@ -841,13 +1101,28 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
841
1101
|
* it and the trailing `returning` reads it back, as is any non-string PK.
|
|
842
1102
|
*/
|
|
843
1103
|
private applyPkDefault;
|
|
1104
|
+
/**
|
|
1105
|
+
* Fill every omitted column that declares a default, since PowDB has no
|
|
1106
|
+
* column defaults of its own (its only generated value is `auto`, which is
|
|
1107
|
+
* left to the engine). Without this an omitted defaulted column was written
|
|
1108
|
+
* as NULL, silently, or failed NOT NULL where every SQL engine applied the
|
|
1109
|
+
* default.
|
|
1110
|
+
*
|
|
1111
|
+
* "Omitted" means absent or `undefined` under BOTH spellings, exactly the
|
|
1112
|
+
* columns a SQL insert leaves to the database; an explicit `null` stays
|
|
1113
|
+
* `null`. The value comes from the column's declared default expression,
|
|
1114
|
+
* evaluated per row (`now()` is the insert time). An expression this cannot
|
|
1115
|
+
* evaluate faithfully, or metadata that does not carry the expression, is
|
|
1116
|
+
* refused rather than guessed.
|
|
1117
|
+
*/
|
|
1118
|
+
private applyColumnDefaults;
|
|
844
1119
|
/**
|
|
845
1120
|
* The table name as a PowQL type reference, backtick-quoted when it is a
|
|
846
1121
|
* reserved word (e.g. a table named `order`). Used in every emitted
|
|
847
1122
|
* statement; plain `this.table` stays in error messages.
|
|
848
1123
|
*/
|
|
849
1124
|
private get qt();
|
|
850
|
-
create(args: CreateArgs<T>): Promise<T
|
|
1125
|
+
create<S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: CreateArgs<T, NoRelations, S, O>): Promise<FieldResult<T, S, O>>;
|
|
851
1126
|
/**
|
|
852
1127
|
* Refuse a `createMany` whose rows do not all name the SAME fields.
|
|
853
1128
|
*
|
|
@@ -869,13 +1144,28 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
869
1144
|
* byte-identical PowQL.
|
|
870
1145
|
*/
|
|
871
1146
|
private assertUniformCreateManyRows;
|
|
872
|
-
createMany(args: CreateManyArgs<T>): Promise<T[]>;
|
|
873
|
-
update(args: UpdateArgs<T>): Promise<T
|
|
1147
|
+
createMany<S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: CreateManyArgs<T, OptionalInput<T>, S, O>): Promise<FieldResult<T, S, O>[]>;
|
|
1148
|
+
update<S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: UpdateArgs<T, NoRelations, S, O>): Promise<FieldResult<T, S, O>>;
|
|
874
1149
|
updateMany(args: UpdateManyArgs<T>): Promise<{
|
|
875
1150
|
count: number;
|
|
876
1151
|
}>;
|
|
877
1152
|
/** Compile `data` into PowQL update assignments, including atomic operators. */
|
|
878
1153
|
private buildUpdateAssignments;
|
|
1154
|
+
/**
|
|
1155
|
+
* The atomic operator an update value names, or `null` for a plain value.
|
|
1156
|
+
* The SQL engines' `setOperatorOf` rule: a plain object with EXACTLY one key
|
|
1157
|
+
* from {@link UPDATE_OPERATOR_KEYS}, and on a json column only `set`, since
|
|
1158
|
+
* an object there IS the document (`{ increment: 1 }` is the document
|
|
1159
|
+
* `{"increment":1}`, and `{ set: doc }` writes a document shaped like
|
|
1160
|
+
* `{ set: ... }`).
|
|
1161
|
+
*/
|
|
1162
|
+
private setOperatorOf;
|
|
1163
|
+
/**
|
|
1164
|
+
* A one-key plain object that is not an update operator, written to a
|
|
1165
|
+
* non-json column, is a misspelled operator (`{ incremnt: 1 }`): refused with
|
|
1166
|
+
* the SQL engines' message rather than stored as text.
|
|
1167
|
+
*/
|
|
1168
|
+
private assertBindableSetValue;
|
|
879
1169
|
private isTxScoped;
|
|
880
1170
|
private nestedCreate;
|
|
881
1171
|
private nestedUpdate;
|
|
@@ -883,11 +1173,11 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
883
1173
|
private runInImplicitTx;
|
|
884
1174
|
/** Already inside a transaction: build a context whose table accessors reuse the pinned pool. */
|
|
885
1175
|
private buildNestedCtx;
|
|
886
|
-
delete(args: DeleteArgs<T>): Promise<T
|
|
1176
|
+
delete<S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: DeleteArgs<T, NoRelations, S, O>): Promise<FieldResult<T, S, O>>;
|
|
887
1177
|
deleteMany(args: DeleteManyArgs<T>): Promise<{
|
|
888
1178
|
count: number;
|
|
889
1179
|
}>;
|
|
890
|
-
upsert(args: UpsertArgs<T>): Promise<T
|
|
1180
|
+
upsert<S extends Record<string, boolean> | undefined = undefined, O extends Record<string, boolean> | undefined = undefined>(args: UpsertArgs<T, NoRelations, S, O>): Promise<FieldResult<T, S, O>>;
|
|
891
1181
|
/**
|
|
892
1182
|
* `upsert` as Prisma defines it, for every shape the native `upsert … on`
|
|
893
1183
|
* statement cannot express: find the row `where` names, update it if it
|
|
@@ -950,8 +1240,8 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
950
1240
|
* probe-only discipline `nestedProjections` follows.
|
|
951
1241
|
*/
|
|
952
1242
|
private get groupsAggregatesInOneStatement();
|
|
953
|
-
aggregate(args:
|
|
954
|
-
groupBy(args:
|
|
1243
|
+
aggregate<A extends AggregateArgs<T>>(args: A): Promise<AggregateResultOf<T, A>>;
|
|
1244
|
+
groupBy<A extends GroupByArgs<T>>(args: A): Promise<GroupByResult<T, A>[]>;
|
|
955
1245
|
/** Validate a JSON-path target (group key / aggregate target): non-empty array of keys/indexes. */
|
|
956
1246
|
private assertJsonPath;
|
|
957
1247
|
/**
|
|
@@ -979,19 +1269,33 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
979
1269
|
private buildGroupOrder;
|
|
980
1270
|
/** Resolve a groupBy order direction, refusing `nulls: 'first'` (E017); `nulls: 'last'` is a no-op. */
|
|
981
1271
|
private groupOrderDir;
|
|
982
|
-
findManyStream(): AsyncGenerator<
|
|
983
|
-
findManyStreamBatches(): AsyncGenerator<
|
|
1272
|
+
findManyStream(): AsyncGenerator<never, void, undefined>;
|
|
1273
|
+
findManyStreamBatches(): AsyncGenerator<never, void, undefined>;
|
|
1274
|
+
private deferredUnsupported;
|
|
1275
|
+
buildFindMany(_args?: unknown): never;
|
|
1276
|
+
buildFindFirst(_args?: unknown): never;
|
|
1277
|
+
buildFindFirstOrThrow(_args?: unknown): never;
|
|
1278
|
+
buildFindUnique(_args?: unknown): never;
|
|
1279
|
+
buildFindUniqueOrThrow(_args?: unknown): never;
|
|
1280
|
+
buildCount(_args?: unknown): never;
|
|
1281
|
+
buildAggregate(_args?: unknown): never;
|
|
1282
|
+
buildGroupBy(_args?: unknown): never;
|
|
1283
|
+
buildCreate(_args?: unknown): never;
|
|
1284
|
+
buildCreateMany(_args?: unknown): never;
|
|
1285
|
+
buildUpdate(_args?: unknown): never;
|
|
1286
|
+
buildUpdateMany(_args?: unknown): never;
|
|
1287
|
+
buildDelete(_args?: unknown): never;
|
|
1288
|
+
buildDeleteMany(_args?: unknown): never;
|
|
1289
|
+
buildUpsert(_args?: unknown): never;
|
|
1290
|
+
/** SQL template cache counters. PowDB keeps no statement cache, so every counter is zero. */
|
|
1291
|
+
cacheStats(): {
|
|
1292
|
+
hits: number;
|
|
1293
|
+
misses: number;
|
|
1294
|
+
hitRate: number;
|
|
1295
|
+
size: number;
|
|
1296
|
+
};
|
|
984
1297
|
/** Reselect a single row by its single-column primary key value. */
|
|
985
1298
|
private reselectByPk;
|
|
986
|
-
/**
|
|
987
|
-
* Empty-where guard, blocks accidental whole-table writes. Mirrors the SQL
|
|
988
|
-
* path's `assertMutationHasPredicate` (query/builder.ts): it gates on the
|
|
989
|
-
* *compiled* PowQL filter fragment, NOT the shape of the `where` object. A
|
|
990
|
-
* `where` whose conditions all evaporate during compilation, `{}`,
|
|
991
|
-
* `{ id: undefined }`, `{ OR: [] }`, `{ AND: [] }`, `{ NOT: {} }`,
|
|
992
|
-
* `{ OR: [{ f: undefined }] }`, compiles to the empty string and is refused,
|
|
993
|
-
* because emitting a filter-less write would hit every row.
|
|
994
|
-
*/
|
|
995
1299
|
/**
|
|
996
1300
|
* AND this table's configured global filter (soft-delete / multi-tenancy)
|
|
997
1301
|
* onto an ALREADY-COMPILED user filter, pushing its params after the user's.
|
|
@@ -1012,5 +1316,44 @@ export declare class PowqlInterface<T extends object = Record<string, unknown>>
|
|
|
1012
1316
|
* column references the same way they qualify the user's.
|
|
1013
1317
|
*/
|
|
1014
1318
|
private applyGlobalFilter;
|
|
1319
|
+
/**
|
|
1320
|
+
* Tables whose global filter is being resolved by an operation above this
|
|
1321
|
+
* interface. A relation filter inside a global filter runs its own query on
|
|
1322
|
+
* the related table, which applies THAT table's filter, so two filters that
|
|
1323
|
+
* reach each other through relations would resolve forever; each table's
|
|
1324
|
+
* filter applies once per chain instead.
|
|
1325
|
+
*/
|
|
1326
|
+
private get globalFilterStack();
|
|
1327
|
+
/** Whether this table's global filter constrains an operation under `skip`. */
|
|
1328
|
+
private hasGlobalFilter;
|
|
1329
|
+
/**
|
|
1330
|
+
* This table's global filter for one operation, ready for
|
|
1331
|
+
* {@link applyGlobalFilter}: read under SQL three-valued logic, with every
|
|
1332
|
+
* relation filter in it (`posts: { some: ... }`, `user: { is: ... }`)
|
|
1333
|
+
* resolved to a literal key list by the same client-side resolution a
|
|
1334
|
+
* caller's `where` gets. The related table's own global filter bounds those
|
|
1335
|
+
* lookups, as on the SQL engines, and `skip` reaches them too.
|
|
1336
|
+
*/
|
|
1337
|
+
private globalFilterWhere;
|
|
1338
|
+
/** Whether `where` holds a relation filter at any combinator depth. */
|
|
1339
|
+
private namesRelation;
|
|
1340
|
+
/**
|
|
1341
|
+
* Empty-where guard, blocks accidental whole-table writes. Mirrors the SQL
|
|
1342
|
+
* path's `assertMutationHasPredicate` (query/where.ts): it gates on the
|
|
1343
|
+
* *compiled* PowQL filter fragment, NOT the shape of the `where` object, so a
|
|
1344
|
+
* `where` whose conditions all evaporate during compilation (`{}`,
|
|
1345
|
+
* `{ id: undefined }`, `{ AND: [] }`, `{ NOT: {} }`) is refused. A where that
|
|
1346
|
+
* compiles but is TRUE for every row (`NOT: { OR: [] }`, `id: { notIn: [] }`)
|
|
1347
|
+
* writes every row just the same, so `userWhere`, the caller's where before
|
|
1348
|
+
* relation filters were resolved, is folded by the SQL engines' rule
|
|
1349
|
+
* (`foldWhereFor`) and refused too.
|
|
1350
|
+
*
|
|
1351
|
+
* The fold also reads the schema's NOT NULL columns, as the SQL guard does:
|
|
1352
|
+
* `{ name: { not: null } }` or `NOT: { name: null }` on a NOT NULL column is
|
|
1353
|
+
* TRUE for every row (PowDB's `required` holds the same guarantee). It does
|
|
1354
|
+
* NOT trust foreign keys: PowDB declares none, so an orphan row is possible
|
|
1355
|
+
* and a belongsTo `is: {}` stays a condition.
|
|
1356
|
+
*/
|
|
1015
1357
|
private assertCompiledWhere;
|
|
1016
1358
|
}
|
|
1359
|
+
export {};
|