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
|
@@ -10,15 +10,30 @@
|
|
|
10
10
|
* stay class-resident, reached through the ctx. See builder.ts for the thin
|
|
11
11
|
* delegating methods and the async execute wrappers.
|
|
12
12
|
*/
|
|
13
|
-
import type
|
|
13
|
+
import { type ReturningSelection } from '../dialect.js';
|
|
14
14
|
import type { TableMetadata } from '../schema.js';
|
|
15
15
|
import type { DeferredQuery } from './deferred.js';
|
|
16
16
|
import type { CreateArgs, CreateManyArgs, DeleteArgs, DeleteManyArgs, UpdateArgs, UpdateManyArgs, UpsertArgs } from './types.js';
|
|
17
17
|
import type { BuilderCtx } from './where.js';
|
|
18
18
|
/**
|
|
19
|
-
* Normalize one `data` value before it is bound as a write param.
|
|
19
|
+
* Normalize one `data` value before it is bound as a write param. This is THE
|
|
20
|
+
* write bind seam: create, createMany, update, updateMany, both halves of
|
|
21
|
+
* upsert, the cache-hit param collectors and (through those public methods)
|
|
22
|
+
* the nested-write engine all bind through it.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
24
|
+
* JSON columns (json / jsonb):
|
|
25
|
+
*
|
|
26
|
+
* - A JS array is serialized with `JSON.stringify`. The drivers' default
|
|
27
|
+
* array serialization is a Postgres ARRAY literal, so `[]` was stored as the
|
|
28
|
+
* object `{}`, `["a"]` failed with 22P02, and `createMany`'s UNNEST
|
|
29
|
+
* transpose flattened `[1, 2, 3]` into three rows.
|
|
30
|
+
* - A {@link jsonValue} wrapper is serialized with `JSON.stringify`, which is
|
|
31
|
+
* how a JSON string or a JSON `null` is written.
|
|
32
|
+
* - A JS string is RAW JSON TEXT and passes through untouched, so
|
|
33
|
+
* `JSON.stringify(value)` callers keep storing the parsed value. A plain
|
|
34
|
+
* object passes through too: every driver already serializes it as JSON.
|
|
35
|
+
*
|
|
36
|
+
* Temporal columns, a JS `Date`:
|
|
22
37
|
*
|
|
23
38
|
* 1. A time-of-day column (`time` / `timetz`), the driver serializes a `Date`
|
|
24
39
|
* as a full ISO timestamp with the process offset and Postgres answers
|
|
@@ -28,14 +43,22 @@ import type { BuilderCtx } from './where.js';
|
|
|
28
43
|
* non-UTC process the stored value is wrong and (because the read path
|
|
29
44
|
* interprets an offset-less value as UTC) does not round-trip. Rewritten to
|
|
30
45
|
* the UTC components, mirroring `parseDbDate`. See `toLocalDateTimeLiteral`
|
|
31
|
-
* in query/utils.ts.
|
|
46
|
+
* in query/utils.ts. `timestamptz` is deliberately untouched: it stores a
|
|
47
|
+
* real instant and the driver's local-offset string is already correct.
|
|
32
48
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
49
|
+
* A plain object or an array bound to a known scalar column (text, int, uuid,
|
|
50
|
+
* ...) is refused with E003, and so is a `Map` or `Set` anywhere; see
|
|
51
|
+
* {@link assertScalarBindable} and {@link assertNotCollection}.
|
|
35
52
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
53
|
+
* Expressions (`expr.*`, `col()`) never bind as a value: the update paths
|
|
54
|
+
* compile them before reaching here, so one that arrives is in a position that
|
|
55
|
+
* takes values only (create data, `{ set }`) and is refused. An unbranded
|
|
56
|
+
* object shaped like one is refused on a non-JSON column on every engine.
|
|
57
|
+
*
|
|
58
|
+
* Every other value is returned by identity, so a primitive costs one check
|
|
59
|
+
* and no lookup. The exception is a string on an engine that defines the
|
|
60
|
+
* dialect's `checkTextWrite` (SQLite), which is checked against its column's
|
|
61
|
+
* type first; see {@link checkTextWrite}.
|
|
39
62
|
*/
|
|
40
63
|
export declare function coerceWriteValue(qi: BuilderCtx, key: string, value: unknown): unknown;
|
|
41
64
|
/**
|
|
@@ -44,21 +67,60 @@ export declare function coerceWriteValue(qi: BuilderCtx, key: string, value: unk
|
|
|
44
67
|
* return rows from non-RETURNING engines. Reuses the same parameterized WHERE
|
|
45
68
|
* builder as reads, so no user value is interpolated.
|
|
46
69
|
*/
|
|
47
|
-
export declare function buildReselectByWhere(qi: BuilderCtx, whereObj: Record<string, unknown>, projection?: WriteProjection): {
|
|
70
|
+
export declare function buildReselectByWhere(qi: BuilderCtx, whereObj: Record<string, unknown>, projection?: WriteProjection, lockRows?: boolean): {
|
|
48
71
|
sql: string;
|
|
49
72
|
params: unknown[];
|
|
50
73
|
};
|
|
51
74
|
export declare function buildCreate<T extends object>(qi: BuilderCtx, args: CreateArgs<T>, projection?: WriteProjection): DeferredQuery<T>;
|
|
52
75
|
/**
|
|
53
|
-
* Build the `'reselect'` plan for {@link buildCreate}: run the INSERT,
|
|
54
|
-
* `SELECT
|
|
55
|
-
*
|
|
56
|
-
*
|
|
76
|
+
* Build the `'reselect'` plan for {@link buildCreate} (MySQL): run the INSERT,
|
|
77
|
+
* then `SELECT ... WHERE <key> = ?` by a key whose value is known exactly
|
|
78
|
+
* (see {@link createReselectKey}). Returns `undefined` unless the dialect's
|
|
79
|
+
* result strategy is `'reselect'`, so the RETURNING engines pay nothing.
|
|
57
80
|
*/
|
|
58
81
|
export declare function makeCreateReselect<T extends object>(qi: BuilderCtx, insertSql: string, insertParams: unknown[], data: Record<string, unknown>, projection?: WriteProjection): DeferredQuery<T>['reselect'];
|
|
59
|
-
export declare function buildCreateMany<T extends object>(qi: BuilderCtx, args: CreateManyArgs<T
|
|
82
|
+
export declare function buildCreateMany<T extends object>(qi: BuilderCtx, args: CreateManyArgs<T>, overBindLimit?: 'refuse' | 'allow', projection?: WriteProjection): DeferredQuery<T[]>;
|
|
83
|
+
/**
|
|
84
|
+
* `createMany()` as the statements it runs: one when the rows fit one
|
|
85
|
+
* statement, else consecutive chunks that each do. The whole call is validated
|
|
86
|
+
* once, before any chunk is built, so a refusal (a duplicate conflict key in
|
|
87
|
+
* the last chunk included) sends nothing, and the chunks are sized before any
|
|
88
|
+
* statement is built, so no engine's own per-statement check refuses one.
|
|
89
|
+
*
|
|
90
|
+
* Built eagerly and synchronously: the chunks read state the call set on the
|
|
91
|
+
* builder (`skipGlobalFilters`), which a concurrent call could change across
|
|
92
|
+
* an await.
|
|
93
|
+
*/
|
|
94
|
+
export declare function planCreateMany<T extends object>(qi: BuilderCtx, args: CreateManyArgs<T>, projection?: WriteProjection): {
|
|
95
|
+
chunks: DeferredQuery<T[]>[];
|
|
96
|
+
rowsPerChunk: number;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* `err` from running a `createMany({ onConflict })`, with the engine's
|
|
100
|
+
* "one statement touched one row twice" errors (PostgreSQL 21000, SQL Server
|
|
101
|
+
* 8672) turned into the E003 that names the cause. Anything else is returned
|
|
102
|
+
* as it was.
|
|
103
|
+
*/
|
|
104
|
+
export declare function explainConflictKeyCollision(qi: BuilderCtx, args: {
|
|
105
|
+
readonly onConflict?: unknown;
|
|
106
|
+
}, err: unknown): unknown;
|
|
60
107
|
export declare function buildUpdate<T extends object>(qi: BuilderCtx, args: UpdateArgs<T>, projection?: WriteProjection): DeferredQuery<T>;
|
|
61
108
|
export declare function buildDelete<T extends object>(qi: BuilderCtx, args: DeleteArgs<T>, projection?: WriteProjection): DeferredQuery<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Refuse `limit` / `take` / `offset` / `skip` on `updateMany` / `deleteMany`.
|
|
111
|
+
* No engine applies them to a bulk write here, so `deleteMany({ where, limit:
|
|
112
|
+
* 1000 })` used to touch every matching row. Shared with the PowDB engine.
|
|
113
|
+
*/
|
|
114
|
+
export declare function assertNoBulkWritePaging(table: string, operation: 'updateMany' | 'deleteMany', args: object): void;
|
|
115
|
+
/**
|
|
116
|
+
* Refuse `optimisticLock` on a write that does not implement it. It is an
|
|
117
|
+
* `update` option; on a sibling method it used to be ignored, so a stale
|
|
118
|
+
* write went through with no error, which is the one outcome the option
|
|
119
|
+
* exists to prevent. The message names the equivalent for each method.
|
|
120
|
+
*/
|
|
121
|
+
export declare function assertNoOptimisticLock(qi: BuilderCtx, args: object, operation: OptimisticLockRefusal): void;
|
|
122
|
+
/** The equivalent of a version check for each write that refuses `optimisticLock`. */
|
|
123
|
+
type OptimisticLockRefusal = 'upsert' | 'updateMany' | 'delete' | 'deleteMany';
|
|
62
124
|
/**
|
|
63
125
|
* Why an `upsert` cannot run as this engine's single conflict statement, or
|
|
64
126
|
* `null` when it can. The one authority for that decision: `upsert()` asks it
|
|
@@ -72,6 +134,11 @@ export declare function buildDelete<T extends object>(qi: BuilderCtx, args: Dele
|
|
|
72
134
|
* - `empty-update`: an `update` with no fields has no `DO UPDATE SET` to emit;
|
|
73
135
|
* every engine rejected the statement as a syntax error. Prisma reads it as
|
|
74
136
|
* "create it if it is missing", which the lookup answers.
|
|
137
|
+
* - `other-unique-key` (MySQL): `ON DUPLICATE KEY UPDATE` has no conflict
|
|
138
|
+
* target and updates whichever row a unique key collides on first, so when
|
|
139
|
+
* `create` could also collide on a unique key `where` does not pin (the
|
|
140
|
+
* primary key included), it could update a row `where` does not name
|
|
141
|
+
* (otherCollidingUniqueKey).
|
|
75
142
|
* - `global-filter`: MySQL's `ON DUPLICATE KEY UPDATE` has no predicate slot
|
|
76
143
|
* and SQL Server's MERGE cannot take the builder's column references there,
|
|
77
144
|
* so the table's global filter cannot guard the conflict update. The lookup
|
|
@@ -80,7 +147,7 @@ export declare function buildDelete<T extends object>(qi: BuilderCtx, args: Dele
|
|
|
80
147
|
*
|
|
81
148
|
* Reads `currentSkip`, so it resolves `skipGlobalFilters` itself first.
|
|
82
149
|
*/
|
|
83
|
-
export type UpsertLookupReason = 'where-differs' | 'empty-update' | 'global-filter';
|
|
150
|
+
export type UpsertLookupReason = 'where-differs' | 'empty-update' | 'other-unique-key' | 'global-filter';
|
|
84
151
|
export declare function upsertLookupReason<T extends object>(qi: BuilderCtx, args: UpsertArgs<T>): UpsertLookupReason | null;
|
|
85
152
|
export declare function buildUpsert<T extends object>(qi: BuilderCtx, args: UpsertArgs<T>, projection?: WriteProjection): DeferredQuery<T>;
|
|
86
153
|
export declare function buildUpdateMany<T extends object>(qi: BuilderCtx, args: UpdateManyArgs<T>): DeferredQuery<{
|
|
@@ -92,8 +159,8 @@ export declare function buildDeleteMany<T extends object>(qi: BuilderCtx, args:
|
|
|
92
159
|
/**
|
|
93
160
|
* The snake_case names of a table's PII-tagged (`defineSchema` `pii: true`)
|
|
94
161
|
* columns. PII columns are excluded from default projections (findMany /
|
|
95
|
-
* findUnique / relation subqueries / batched loads) unless
|
|
96
|
-
*
|
|
162
|
+
* findUnique / relation subqueries / batched loads) unless a read passes
|
|
163
|
+
* `includePii: UNSAFE`; naming one in `select` without it is E003. Returns an
|
|
97
164
|
* empty set for any table with no PII column, so untagged schemas keep their
|
|
98
165
|
* byte-identical SQL.
|
|
99
166
|
*/
|
|
@@ -102,8 +169,8 @@ export declare function piiColumns(_qi: BuilderCtx, meta: TableMetadata): Set<st
|
|
|
102
169
|
* The camelCase field names of a table's PII-tagged columns: the read-side
|
|
103
170
|
* counterpart of {@link piiColumns} applied to already-parsed entities.
|
|
104
171
|
* Used to strip PII from a write's RETURNING/reselect row (writes accept no
|
|
105
|
-
* `includePii
|
|
106
|
-
*
|
|
172
|
+
* `includePii`, and a PII column named in a write's `select` is E003, so their
|
|
173
|
+
* returned row never carries one; you may still write PII fields freely).
|
|
107
174
|
*/
|
|
108
175
|
export declare function piiFields(_qi: BuilderCtx, meta: TableMetadata): string[];
|
|
109
176
|
/**
|
|
@@ -114,9 +181,10 @@ export declare function piiFields(_qi: BuilderCtx, meta: TableMetadata): string[
|
|
|
114
181
|
* resolve to a column or the call throws E003, a relation name gets its own
|
|
115
182
|
* message, `select` must name something, `select` and `omit` are exclusive, the
|
|
116
183
|
* list is in TABLE order (a caller's key order must not mint distinct
|
|
117
|
-
* statements), and
|
|
118
|
-
*
|
|
119
|
-
* module because relations.ts already imports
|
|
184
|
+
* statements), and PII is never returned: a write takes no `includePii`, so a
|
|
185
|
+
* PII column named in `select` is E003 and `omit` leaves PII excluded.
|
|
186
|
+
* (builder.ts rather than this module because relations.ts already imports
|
|
187
|
+
* this one.)
|
|
120
188
|
*
|
|
121
189
|
* The point is bytes: `RETURNING *` sends back every column, a large JSON
|
|
122
190
|
* payload included, on every insert. Measured with a 3.1 KB jsonb column at
|
|
@@ -143,8 +211,9 @@ export declare function writeProjectionCacheSegment(projection: WriteProjection
|
|
|
143
211
|
* column so the PII values never leave the database on a write. A PII-tagged
|
|
144
212
|
* PRIMARY KEY column is kept in the projection regardless (the returned row
|
|
145
213
|
* must stay addressable): tag sensitive data, not keys, a PII PK is
|
|
146
|
-
* documented out of scope for stripping. Writes accept no `
|
|
147
|
-
*
|
|
214
|
+
* documented out of scope for stripping. Writes accept no `includePii` and
|
|
215
|
+
* their `select` cannot name a PII column, so this is the whole write-return
|
|
216
|
+
* policy at the SQL level;
|
|
148
217
|
* {@link parseWriteRow} remains as a defense-in-depth strip (a no-op once the
|
|
149
218
|
* SQL already excludes the columns). Derived purely from static per-table
|
|
150
219
|
* schema metadata, so the write SQL cache needs no extra key segment.
|
|
@@ -204,32 +273,22 @@ export declare function assertWritable(qi: BuilderCtx, operation: string): void;
|
|
|
204
273
|
*/
|
|
205
274
|
export declare function assertNoGeneratedColumns(qi: BuilderCtx, data: Record<string, unknown>, operation: string): void;
|
|
206
275
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* it has EXACTLY one key that is one of the 5 operator keys, this avoids
|
|
212
|
-
* misinterpreting JSON column values like `{ set: 'x' }` as operators
|
|
213
|
-
* (real operator objects always have exactly one key, and a plain JSON
|
|
214
|
-
* payload that happens to have a single `set` key is extremely unusual).
|
|
215
|
-
* Multi-key objects are always treated as plain (JSON) values.
|
|
216
|
-
*
|
|
217
|
-
* Returns the SQL fragment (e.g., `"view_count" = "view_count" + $3`) and
|
|
218
|
-
* pushes any required params onto the shared params array so that WHERE
|
|
219
|
-
* clause numbering continues correctly afterward.
|
|
276
|
+
* The atomic operator a SET value names, or `null` when it is a plain value.
|
|
277
|
+
* THE one rule, read by the SET build, its fingerprint and its cache-hit param
|
|
278
|
+
* collector, so the three cannot disagree about whether a value is an
|
|
279
|
+
* operator.
|
|
220
280
|
*
|
|
221
|
-
* `
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* column at all, so their SQL is byte-identical with or without a qualifier.
|
|
281
|
+
* A branded expression or `col()` reference is checked FIRST and answers
|
|
282
|
+
* `'expr'`: it is a frozen plain object too, and must never reach the
|
|
283
|
+
* operator test below. An operator is a plain object with EXACTLY one key from
|
|
284
|
+
* {@link UPDATE_OPERATOR_KEYS}. On a json/jsonb column only `set` is an
|
|
285
|
+
* operator: an object there IS the JSON value, so `{ increment: 1 }` is the
|
|
286
|
+
* document `{"increment":1}`, and `{ set: doc }` is the way to write a
|
|
287
|
+
* document that is itself shaped like `{ set: ... }`.
|
|
229
288
|
*/
|
|
230
|
-
export declare function
|
|
289
|
+
export declare function setOperatorOf(qi: BuilderCtx, key: string, value: unknown): string | null;
|
|
231
290
|
/**
|
|
232
|
-
* Reject a `data` value that reached {@link
|
|
291
|
+
* Reject a `data` value that reached {@link buildSetClauses}'s plain-value
|
|
233
292
|
* fallthrough as a plain object with exactly ONE key that is not a known
|
|
234
293
|
* atomic operator. On a scalar column that shape can only be a misspelled
|
|
235
294
|
* operator (`{ incremnt: 1 }`, `{ bogus: 'x' }`); binding it plainly writes the
|
|
@@ -248,10 +307,13 @@ export declare function buildSetClause(qi: BuilderCtx, key: string, value: unkno
|
|
|
248
307
|
export declare function assertBindableSetValue(qi: BuilderCtx, key: string, value: unknown): void;
|
|
249
308
|
/**
|
|
250
309
|
* Fingerprint SET clauses for update/updateMany.
|
|
251
|
-
* Captures key names + operator types (set/increment/etc) but not values.
|
|
310
|
+
* Captures key names + operator types (set/increment/etc) but not values. An
|
|
311
|
+
* expression contributes `k:expr(<shape>)` from the same walk that compiles
|
|
312
|
+
* it, so a statement without one keeps its key byte-identical.
|
|
252
313
|
*/
|
|
253
314
|
export declare function fingerprintSet(qi: BuilderCtx, data: Record<string, unknown>): string;
|
|
254
315
|
/**
|
|
255
|
-
* Collect SET params for update/updateMany. Mirrors
|
|
316
|
+
* Collect SET params for update/updateMany. Mirrors buildSetClauses param order.
|
|
256
317
|
*/
|
|
257
318
|
export declare function collectSetParams(qi: BuilderCtx, data: Record<string, unknown>, params: unknown[]): void;
|
|
319
|
+
export {};
|