@prisma/orm-family-sql 8.0.0-rc.1-dev.44 → 8.0.0-rc.1-dev.46
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/{aggregate-descriptor-registry-CTo0ry7h.mjs → aggregate-descriptor-registry-C7hel5O7.mjs} +2 -2
- package/dist/{aggregate-descriptor-registry-CTo0ry7h.mjs.map → aggregate-descriptor-registry-C7hel5O7.mjs.map} +1 -1
- package/dist/{ast-D8qqdDX_.d.mts → ast-HFcfQZr-.d.mts} +3 -3
- package/dist/{ast-D8qqdDX_.d.mts.map → ast-HFcfQZr-.d.mts.map} +1 -1
- package/dist/{ast-BJdOHZrL.mjs → ast-Lbl4VwqP.mjs} +2 -2
- package/dist/ast-Lbl4VwqP.mjs.map +1 -0
- package/dist/{authoring-type-constructors-Blqoa2Ua-CvHn00xx.mjs → authoring-type-constructors-Blqoa2Ua-DqvNCOb2.mjs} +2 -2
- package/dist/{authoring-type-constructors-Blqoa2Ua-CvHn00xx.mjs.map → authoring-type-constructors-Blqoa2Ua-DqvNCOb2.mjs.map} +1 -1
- package/dist/builder.d.mts +2 -2
- package/dist/builder__runtime.d.mts +6 -6
- package/dist/builder__runtime.mjs +20 -3
- package/dist/builder__runtime.mjs.map +1 -1
- package/dist/builder__types.d.mts +2 -2
- package/dist/{config-types-B6cQRwJw.mjs → config-types-gAm54C_v.mjs} +2 -2
- package/dist/{config-types-B6cQRwJw.mjs.map → config-types-gAm54C_v.mjs.map} +1 -1
- package/dist/{contract-builder-vdfvmuiO.mjs → contract-builder-D4a5dT7j.mjs} +2 -2
- package/dist/{contract-builder-vdfvmuiO.mjs.map → contract-builder-D4a5dT7j.mjs.map} +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/contract.d.mts +1 -1
- package/dist/contract.mjs +1 -1
- package/dist/contract__foreign-key-materialization.d.mts +1 -1
- package/dist/contract__foreign-key-materialization.mjs +1 -1
- package/dist/{control-DAkNosoF.mjs → control-D3cB5YQp.mjs} +2 -2
- package/dist/{control-DAkNosoF.mjs.map → control-D3cB5YQp.mjs.map} +1 -1
- package/dist/{control-DssujEJW.d.mts → control-DTLJ1WtZ.d.mts} +6 -6
- package/dist/{control-DssujEJW.d.mts.map → control-DTLJ1WtZ.d.mts.map} +1 -1
- package/dist/{control-adapter-C99J7aEF-Vx9xXYOy.d.mts → control-adapter-C99J7aEF-B7eQd7vD.d.mts} +4 -4
- package/dist/{control-adapter-C99J7aEF-Vx9xXYOy.d.mts.map → control-adapter-C99J7aEF-B7eQd7vD.d.mts.map} +1 -1
- package/dist/control-adapter-MZJQiwcE.d.mts +1 -0
- package/dist/{db-C5jmOFPM-Cd-fni61.d.mts → db-D18PrXKW-DvTv4JFn.d.mts} +136 -8
- package/dist/db-D18PrXKW-DvTv4JFn.d.mts.map +1 -0
- package/dist/{ddl-types-BtT82FGO-Du_-9SlZ.d.mts → ddl-types-CXx4vPz6-BsgrnSUY.d.mts} +3 -3
- package/dist/{ddl-types-BtT82FGO-Du_-9SlZ.d.mts.map → ddl-types-CXx4vPz6-BsgrnSUY.d.mts.map} +1 -1
- package/dist/{derived-checks-DFMRmiAu-8jmha26I.mjs → derived-checks-DFMRmiAu-DGfB8aS4.mjs} +2 -2
- package/dist/{derived-checks-DFMRmiAu-8jmha26I.mjs.map → derived-checks-DFMRmiAu-DGfB8aS4.mjs.map} +1 -1
- package/dist/{diff-pl1Xal4J.d.mts → diff-DbTNVm2f.d.mts} +3 -3
- package/dist/{diff-pl1Xal4J.d.mts.map → diff-DbTNVm2f.d.mts.map} +1 -1
- package/dist/{expression-D30W-gkF.mjs → expression-CX5mTA-z.mjs} +54 -15
- package/dist/expression-CX5mTA-z.mjs.map +1 -0
- package/dist/{expression-Q_yaDQPb.d.mts → expression-FJK6Ar-d.d.mts} +96 -5
- package/dist/expression-FJK6Ar-d.d.mts.map +1 -0
- package/dist/family.d.mts +7 -7
- package/dist/family.mjs +2 -2
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +2 -2
- package/dist/family__control.mjs +1 -1
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__migration.d.mts +1 -1
- package/dist/family__pack.mjs +1 -1
- package/dist/family__psl-infer.mjs +1 -1
- package/dist/family__runtime.d.mts +1 -1
- package/dist/{foreign-key-materialization-DO9dvG7v.d.mts → foreign-key-materialization-CkvOzJWy.d.mts} +4 -4
- package/dist/{foreign-key-materialization-DO9dvG7v.d.mts.map → foreign-key-materialization-CkvOzJWy.d.mts.map} +1 -1
- package/dist/{foreign-key-materialization-DLOi1Ps0.mjs → foreign-key-materialization-Cu7-7LHl.mjs} +6 -5
- package/dist/foreign-key-materialization-Cu7-7LHl.mjs.map +1 -0
- package/dist/{index-DIHXLCbY.d.mts → index-C-vQOMY_.d.mts} +9 -9
- package/dist/{index-DIHXLCbY.d.mts.map → index-C-vQOMY_.d.mts.map} +1 -1
- package/dist/{interpreter-DaBA2fm--FFkq_gGd.mjs → interpreter-DyiUUAWh-DYdjIpiE.mjs} +5 -5
- package/dist/interpreter-DyiUUAWh-DYdjIpiE.mjs.map +1 -0
- package/dist/lane-query-builder.d.mts +1 -1
- package/dist/middleware--TtoxUiW.d.mts +1 -0
- package/dist/{middleware-BS7u8VFR-DyUcAFid.d.mts → middleware-AhTz1BOW-th-Suxuf.d.mts} +3 -3
- package/dist/{middleware-BS7u8VFR-DyUcAFid.d.mts.map → middleware-AhTz1BOW-th-Suxuf.d.mts.map} +1 -1
- package/dist/{migration-CGlaINey.d.mts → migration-CjDRZNep.d.mts} +2 -2
- package/dist/{migration-CGlaINey.d.mts.map → migration-CjDRZNep.d.mts.map} +1 -1
- package/dist/orm-client.d.mts +7 -7
- package/dist/orm-client.mjs +2 -2
- package/dist/plan-BHLdb0Z7.d.mts +2 -0
- package/dist/{plan-BC_trt1i-In5gOKCT.d.mts → plan-CDxduYaN-pLIyyJaB.d.mts} +9 -8
- package/dist/plan-CDxduYaN-pLIyyJaB.d.mts.map +1 -0
- package/dist/{plan-CkpcgUaM.mjs → plan-Dh0LbYIv-Crx5-ThG.mjs} +8 -7
- package/dist/plan-Dh0LbYIv-Crx5-ThG.mjs.map +1 -0
- package/dist/prepared-query-BJr50wPm-ChoqfJbX.mjs +22 -0
- package/dist/prepared-query-BJr50wPm-ChoqfJbX.mjs.map +1 -0
- package/dist/{prepared-statement-z9bBbTph-BlzhaRTY.d.mts → prepared-statement-9QpkE6JG-C430V3MO.d.mts} +82 -17
- package/dist/prepared-statement-9QpkE6JG-C430V3MO.d.mts.map +1 -0
- package/dist/{psl-infer-YhbKkybN.mjs → psl-infer-Dk5kgKre.mjs} +2 -2
- package/dist/{psl-infer-YhbKkybN.mjs.map → psl-infer-Dk5kgKre.mjs.map} +1 -1
- package/dist/{query-lane-context-gwWUcacE-DdWNrc8q.d.mts → query-lane-context-Qa-eddrE-kuZ8Z86-.d.mts} +3 -3
- package/dist/{query-lane-context-gwWUcacE-DdWNrc8q.d.mts.map → query-lane-context-Qa-eddrE-kuZ8Z86-.d.mts.map} +1 -1
- package/dist/query-lane-context-XMvk7fmY.d.mts +1 -0
- package/dist/relational-core.d.mts +12 -12
- package/dist/relational-core.mjs +5 -5
- package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
- package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
- package/dist/relational-core__ast.d.mts +4 -4
- package/dist/relational-core__ast.mjs +3 -3
- package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
- package/dist/relational-core__contract-free.d.mts +2 -2
- package/dist/relational-core__contract-free.mjs +1 -1
- package/dist/relational-core__contract-free.mjs.map +1 -1
- package/dist/relational-core__expression.d.mts +2 -2
- package/dist/relational-core__expression.mjs +1 -1
- package/dist/relational-core__middleware.d.mts +2 -2
- package/dist/relational-core__plan.d.mts +3 -3
- package/dist/relational-core__plan.mjs +1 -1
- package/dist/relational-core__query-lane-context.d.mts +2 -2
- package/dist/relational-core__types.d.mts +3 -3
- package/dist/{runtime-cPrAp99G.d.mts → runtime-DpKF2Yu2.d.mts} +3 -3
- package/dist/{runtime-cPrAp99G.d.mts.map → runtime-DpKF2Yu2.d.mts.map} +1 -1
- package/dist/runtime.d.mts +5 -5
- package/dist/runtime.mjs +143 -16
- package/dist/runtime.mjs.map +1 -1
- package/dist/runtime__internal__prepared-query.d.mts +2 -2
- package/dist/runtime__internal__prepared-query.mjs +2 -2
- package/dist/{sql-execution-plan-D0ZTnszb-DnCRtfQO.d.mts → sql-execution-plan--jKyLpe5-CMGhgO0M.d.mts} +5 -6
- package/dist/sql-execution-plan--jKyLpe5-CMGhgO0M.d.mts.map +1 -0
- package/dist/types-B0msOnBM.d.mts +1 -0
- package/dist/{types-C9FZXc9Q-C6LM1k-O.d.mts → types-CyxGtOOh-BggSa6Fe.d.mts} +7 -18
- package/dist/{types-C9FZXc9Q-C6LM1k-O.d.mts.map → types-CyxGtOOh-BggSa6Fe.d.mts.map} +1 -1
- package/dist/{types-B7_v-z12-De5tf8LE.mjs → types-Dt4e_jC--COeP8xzN.mjs} +68 -28
- package/dist/{types-B7_v-z12-De5tf8LE.mjs.map → types-Dt4e_jC--COeP8xzN.mjs.map} +1 -1
- package/dist/{types-IqZMLrFC-B0YziCVx.d.mts → types-IqZMLrFC-DcH8v_u3.d.mts} +2 -2
- package/dist/{types-IqZMLrFC-B0YziCVx.d.mts.map → types-IqZMLrFC-DcH8v_u3.d.mts.map} +1 -1
- package/dist/{types-DH6Sqzxu-DfzaLX0o.d.mts → types-v3qxLLxo-DCeKv7yY.d.mts} +43 -22
- package/dist/{types-DH6Sqzxu-DfzaLX0o.d.mts.map → types-v3qxLLxo-DCeKv7yY.d.mts.map} +1 -1
- package/package.json +18 -18
- package/dist/ast-BJdOHZrL.mjs.map +0 -1
- package/dist/control-adapter-CLID4Q6Z.d.mts +0 -1
- package/dist/db-C5jmOFPM-Cd-fni61.d.mts.map +0 -1
- package/dist/expression-D30W-gkF.mjs.map +0 -1
- package/dist/expression-Q_yaDQPb.d.mts.map +0 -1
- package/dist/foreign-key-materialization-DLOi1Ps0.mjs.map +0 -1
- package/dist/interpreter-DaBA2fm--FFkq_gGd.mjs.map +0 -1
- package/dist/middleware-Cy_OqpBi.d.mts +0 -1
- package/dist/plan-BC_trt1i-In5gOKCT.d.mts.map +0 -1
- package/dist/plan-CkpcgUaM.mjs.map +0 -1
- package/dist/plan-DrOMooQt.d.mts +0 -2
- package/dist/prepared-query-BDLztUzY-CaDR0Rqc.mjs +0 -14
- package/dist/prepared-query-BDLztUzY-CaDR0Rqc.mjs.map +0 -1
- package/dist/prepared-statement-z9bBbTph-BlzhaRTY.d.mts.map +0 -1
- package/dist/query-lane-context-D62vkQhf.d.mts +0 -1
- package/dist/sql-execution-plan-D0ZTnszb-DnCRtfQO.d.mts.map +0 -1
- package/dist/types-0c4HyrXd.d.mts +0 -1
package/dist/runtime.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as createSqlOperationRegistry } from "./dist-C_q1_QR9.mjs";
|
|
2
|
-
import { A as PreparedParamRef, H as isQueryAst } from "./types-
|
|
2
|
+
import { A as PreparedParamRef, H as isQueryAst } from "./types-Dt4e_jC--COeP8xzN.mjs";
|
|
3
3
|
import { t as collectOrderedParamRefs } from "./util-DQQgv2j1-D6INZaRG.mjs";
|
|
4
4
|
import { t as createSqlParamRefMutator } from "./middleware-CMr4CHNz-DHIUdxlm.mjs";
|
|
5
|
-
import { t as buildSqlAggregateDescriptorRegistry } from "./aggregate-descriptor-registry-
|
|
5
|
+
import { t as buildSqlAggregateDescriptorRegistry } from "./aggregate-descriptor-registry-C7hel5O7.mjs";
|
|
6
6
|
import { t as buildCodecDescriptorRegistry } from "./codec-descriptor-registry-N0dhtKaH.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { i as runPreparedQuery, n as preparedStatementQuery, r as runPreparedExecute, t as preparedStatementExecute } from "./prepared-query-BJr50wPm-ChoqfJbX.mjs";
|
|
8
8
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
@@ -17,7 +17,7 @@ import { AsyncIterableResult, RuntimeCore, checkAborted, checkMiddlewareCompatib
|
|
|
17
17
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
18
18
|
import { createExecutionStack } from "@prisma/orm-framework/components/execution";
|
|
19
19
|
import { hashContent } from "@prisma/orm-framework/utils/hash-content";
|
|
20
|
-
//#region ../../../2-sql/5-runtime/dist/exports-
|
|
20
|
+
//#region ../../../2-sql/5-runtime/dist/exports-BDzGy_bM.mjs
|
|
21
21
|
/**
|
|
22
22
|
* Build an {@link AstCodecResolver} bound to a descriptor registry and a per-call instance-context factory.
|
|
23
23
|
*
|
|
@@ -401,7 +401,7 @@ function evaluateAstLints(ast) {
|
|
|
401
401
|
}
|
|
402
402
|
break;
|
|
403
403
|
case "insert": break;
|
|
404
|
-
case "raw-
|
|
404
|
+
case "raw-query": break;
|
|
405
405
|
// v8 ignore next 2
|
|
406
406
|
default: assertNever(ast, `Unsupported AST kind: ${ast.kind}`);
|
|
407
407
|
}
|
|
@@ -439,7 +439,7 @@ function lints(options) {
|
|
|
439
439
|
const findings = [];
|
|
440
440
|
if (isQueryAst(plan.ast)) {
|
|
441
441
|
findings.push(...evaluateAstLints(plan.ast));
|
|
442
|
-
if (plan.ast.kind === "raw-
|
|
442
|
+
if (plan.ast.kind === "raw-query") findings.push(...evaluateRawGuardrails(plan).lints);
|
|
443
443
|
} else if (fallback !== "skip") findings.push(...evaluateRawGuardrails(plan).lints);
|
|
444
444
|
for (const lint of findings) {
|
|
445
445
|
const effectiveSeverity = getConfiguredSeverity(lint.code, options) ?? lint.severity;
|
|
@@ -478,6 +478,34 @@ var PreparedStatementImpl = class {
|
|
|
478
478
|
return runPreparedQuery(target, this, params, options);
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
|
+
/**
|
|
482
|
+
* The statistics-reporting sibling of {@link PreparedStatementImpl}. A plan
|
|
483
|
+
* declaring an affected-row count prepares into one of these, which carries
|
|
484
|
+
* the same lowered statement and bind slots and is consumed by executing it.
|
|
485
|
+
*
|
|
486
|
+
* The two classes are separate so the consumption a plan did not declare is
|
|
487
|
+
* absent from the value, not merely from its type.
|
|
488
|
+
*/
|
|
489
|
+
var PreparedExecutionImpl = class {
|
|
490
|
+
sql;
|
|
491
|
+
ast;
|
|
492
|
+
meta;
|
|
493
|
+
slots;
|
|
494
|
+
decodeContext;
|
|
495
|
+
paramMetadata;
|
|
496
|
+
constructor(internals) {
|
|
497
|
+
this.sql = internals.sql;
|
|
498
|
+
this.ast = internals.ast;
|
|
499
|
+
this.meta = internals.meta;
|
|
500
|
+
this.slots = internals.slots;
|
|
501
|
+
this.decodeContext = internals.decodeContext;
|
|
502
|
+
this.paramMetadata = internals.paramMetadata;
|
|
503
|
+
Object.freeze(this);
|
|
504
|
+
}
|
|
505
|
+
execute(target, params, options) {
|
|
506
|
+
return runPreparedExecute(target, this, params, options);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
481
509
|
function documentScopedCodecTypes(contract) {
|
|
482
510
|
return blindCast(contract.storage.types);
|
|
483
511
|
}
|
|
@@ -849,22 +877,52 @@ const WIRE_PREVIEW_LIMIT = 100;
|
|
|
849
877
|
const EMPTY_INCLUDE_ALIASES = /* @__PURE__ */ new Set();
|
|
850
878
|
function projectionListFromAst(ast) {
|
|
851
879
|
if (ast.kind === "select") return ast.projection;
|
|
852
|
-
if (ast.kind === "raw-sql") return;
|
|
853
880
|
return ast.returning;
|
|
854
881
|
}
|
|
855
882
|
function resolveProjectionCodec(item, contractCodecs) {
|
|
856
883
|
if (item.codec && contractCodecs) return contractCodecs.forCodecRef(item.codec);
|
|
857
884
|
}
|
|
858
885
|
const EMPTY_MANY_ALIASES = /* @__PURE__ */ new Set();
|
|
859
|
-
function
|
|
860
|
-
|
|
861
|
-
if (!projection || projection.length === 0) return {
|
|
886
|
+
function undecodedContext() {
|
|
887
|
+
return {
|
|
862
888
|
aliases: void 0,
|
|
863
889
|
codecs: /* @__PURE__ */ new Map(),
|
|
864
890
|
columnRefs: /* @__PURE__ */ new Map(),
|
|
865
891
|
includeAliases: EMPTY_INCLUDE_ALIASES,
|
|
866
|
-
manyAliases: EMPTY_MANY_ALIASES
|
|
892
|
+
manyAliases: EMPTY_MANY_ALIASES,
|
|
893
|
+
aliasSource: "projection"
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Decode context for a raw statement: the columns come from the row spec its
|
|
898
|
+
* author declared at the terminator, and each carries the codec that decodes
|
|
899
|
+
* it. A statement that reports an affected-row count declares no columns, so
|
|
900
|
+
* its single stats row passes through undecoded.
|
|
901
|
+
*
|
|
902
|
+
* The spec is the only description of the result — the runtime never parses
|
|
903
|
+
* the SQL — so it is also what a mismatched result set is measured against.
|
|
904
|
+
*/
|
|
905
|
+
function rawQueryDecodeContext(ast, contractCodecs) {
|
|
906
|
+
if (ast.result.kind === "affected-count") return undecodedContext();
|
|
907
|
+
const aliases = [];
|
|
908
|
+
const codecs = /* @__PURE__ */ new Map();
|
|
909
|
+
for (const [name, column] of Object.entries(ast.result.columns)) {
|
|
910
|
+
aliases.push(name);
|
|
911
|
+
if (contractCodecs) codecs.set(name, contractCodecs.forCodecRef({ codecId: column.codecId }));
|
|
912
|
+
}
|
|
913
|
+
return {
|
|
914
|
+
aliases,
|
|
915
|
+
codecs,
|
|
916
|
+
columnRefs: /* @__PURE__ */ new Map(),
|
|
917
|
+
includeAliases: EMPTY_INCLUDE_ALIASES,
|
|
918
|
+
manyAliases: EMPTY_MANY_ALIASES,
|
|
919
|
+
aliasSource: "row-spec"
|
|
867
920
|
};
|
|
921
|
+
}
|
|
922
|
+
function buildDecodeContext(ast, contractCodecs) {
|
|
923
|
+
if (ast.kind === "raw-query") return rawQueryDecodeContext(ast, contractCodecs);
|
|
924
|
+
const projection = projectionListFromAst(ast);
|
|
925
|
+
if (!projection || projection.length === 0) return undecodedContext();
|
|
868
926
|
const aliases = [];
|
|
869
927
|
const codecs = /* @__PURE__ */ new Map();
|
|
870
928
|
const columnRefs = /* @__PURE__ */ new Map();
|
|
@@ -886,7 +944,8 @@ function buildDecodeContext(ast, contractCodecs) {
|
|
|
886
944
|
codecs,
|
|
887
945
|
columnRefs,
|
|
888
946
|
includeAliases,
|
|
889
|
-
manyAliases
|
|
947
|
+
manyAliases,
|
|
948
|
+
aliasSource: "projection"
|
|
890
949
|
};
|
|
891
950
|
}
|
|
892
951
|
function previewWireValue(wireValue) {
|
|
@@ -988,7 +1047,11 @@ async function decodeRow(row, decodeCtx, rowCtx) {
|
|
|
988
1047
|
const signal = rowCtx.signal;
|
|
989
1048
|
const aliases = decodeCtx.aliases ?? Object.keys(row);
|
|
990
1049
|
if (decodeCtx.aliases !== void 0) {
|
|
991
|
-
for (const alias of decodeCtx.aliases) if (!Object.hasOwn(row, alias)) throw runtimeError("RUNTIME.
|
|
1050
|
+
for (const alias of decodeCtx.aliases) if (!Object.hasOwn(row, alias)) throw decodeCtx.aliasSource === "row-spec" ? runtimeError("RUNTIME.RAW_ROW_COLUMN_MISSING", `Raw statement result has no column "${alias}", which its row spec declares`, {
|
|
1051
|
+
column: alias,
|
|
1052
|
+
declaredColumns: decodeCtx.aliases,
|
|
1053
|
+
resultColumns: Object.keys(row)
|
|
1054
|
+
}) : runtimeError("RUNTIME.DECODE_FAILED", `Row missing projection alias "${alias}"`, {
|
|
992
1055
|
alias,
|
|
993
1056
|
expectedAliases: decodeCtx.aliases,
|
|
994
1057
|
presentKeys: Object.keys(row)
|
|
@@ -1298,6 +1361,9 @@ var SqlRuntimeBase = class extends RuntimeCore {
|
|
|
1298
1361
|
[preparedStatementQuery](ps, params, options) {
|
|
1299
1362
|
return this.runPreparedQueryAgainstQueryable(blindCast(ps), params, this.driver, options);
|
|
1300
1363
|
}
|
|
1364
|
+
[preparedStatementExecute](ps, params, options) {
|
|
1365
|
+
return this.runPreparedExecuteAgainstQueryable(blindCast(ps), params, this.driver, options);
|
|
1366
|
+
}
|
|
1301
1367
|
/**
|
|
1302
1368
|
* Returns the raw driver connection. The connection is a `SqlQueryable` — SQL
|
|
1303
1369
|
* issued on it runs below the middleware/codec/telemetry pipeline. It carries
|
|
@@ -1430,14 +1496,15 @@ var SqlRuntimeBase = class extends RuntimeCore {
|
|
|
1430
1496
|
});
|
|
1431
1497
|
const decodeContext = buildDecodeContext(finalPlan.ast, this.contractCodecs);
|
|
1432
1498
|
const paramMetadata = deriveParamMetadata(finalPlan.ast);
|
|
1433
|
-
|
|
1499
|
+
const internals = Object.freeze({
|
|
1434
1500
|
sql: lowered.sql,
|
|
1435
1501
|
ast: finalPlan.ast,
|
|
1436
1502
|
meta: finalPlan.meta,
|
|
1437
1503
|
slots: lowered.params,
|
|
1438
1504
|
decodeContext,
|
|
1439
1505
|
paramMetadata
|
|
1440
|
-
})
|
|
1506
|
+
});
|
|
1507
|
+
return blindCast(finalPlan.ast.kind === "raw-query" && finalPlan.ast.result.kind === "affected-count" ? new PreparedExecutionImpl(internals) : new PreparedStatementImpl(internals));
|
|
1441
1508
|
}
|
|
1442
1509
|
/** Query prepared rows against a caller-supplied queryable through the full pipeline. */
|
|
1443
1510
|
runPreparedQueryAgainstQueryable(ps, userParams, queryable, options) {
|
|
@@ -1477,6 +1544,50 @@ var SqlRuntimeBase = class extends RuntimeCore {
|
|
|
1477
1544
|
};
|
|
1478
1545
|
return new AsyncIterableResult(generator());
|
|
1479
1546
|
}
|
|
1547
|
+
/** Execute a prepared statement's statistics against a caller-supplied queryable through the full pipeline. */
|
|
1548
|
+
async runPreparedExecuteAgainstQueryable(ps, userParams, queryable, options) {
|
|
1549
|
+
this.ensureCodecRegistryValidated();
|
|
1550
|
+
const { codecCtx, middlewareCtx } = this.createQueryContexts(options);
|
|
1551
|
+
checkAborted(codecCtx, "stream");
|
|
1552
|
+
const preEncodeValues = resolvePreparedSlotValues(ps, userParams);
|
|
1553
|
+
const preEncodeExec = {
|
|
1554
|
+
sql: ps.sql,
|
|
1555
|
+
params: preEncodeValues,
|
|
1556
|
+
ast: ps.ast,
|
|
1557
|
+
meta: ps.meta
|
|
1558
|
+
};
|
|
1559
|
+
const mutator = createSqlParamRefMutator(preEncodeExec);
|
|
1560
|
+
await runBeforeExecuteChain(preEncodeExec, this.middleware, middlewareCtx, mutator);
|
|
1561
|
+
const exec = {
|
|
1562
|
+
sql: ps.sql,
|
|
1563
|
+
params: await encodeParamsWithMetadata(mutator.currentParams(), ps.paramMetadata, codecCtx, this.contractCodecs),
|
|
1564
|
+
ast: ps.ast,
|
|
1565
|
+
meta: ps.meta
|
|
1566
|
+
};
|
|
1567
|
+
await this.setupDriverExecution(exec);
|
|
1568
|
+
checkAborted(codecCtx, "stream");
|
|
1569
|
+
const handles = this.#preparedStatementHandles;
|
|
1570
|
+
const request = {
|
|
1571
|
+
sql: exec.sql,
|
|
1572
|
+
params: exec.params,
|
|
1573
|
+
preparedStatementHandle: {
|
|
1574
|
+
get: () => handles.get(ps),
|
|
1575
|
+
set: (value) => {
|
|
1576
|
+
handles.set(ps, value);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
const startedAt = Date.now();
|
|
1581
|
+
let outcome = "success";
|
|
1582
|
+
try {
|
|
1583
|
+
return await runExecuteWithMiddleware(exec, this.middleware, middlewareCtx, () => queryable.execute(request));
|
|
1584
|
+
} catch (error) {
|
|
1585
|
+
outcome = "runtime-error";
|
|
1586
|
+
throw error;
|
|
1587
|
+
} finally {
|
|
1588
|
+
this.recordTelemetry(exec, outcome, Date.now() - startedAt);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1480
1591
|
async connection() {
|
|
1481
1592
|
const driverConn = await this.driver.acquireConnection();
|
|
1482
1593
|
const self = this;
|
|
@@ -1508,6 +1619,12 @@ var SqlRuntimeBase = class extends RuntimeCore {
|
|
|
1508
1619
|
...options,
|
|
1509
1620
|
scope: "connection"
|
|
1510
1621
|
});
|
|
1622
|
+
},
|
|
1623
|
+
[preparedStatementExecute](ps, params, options) {
|
|
1624
|
+
return self.runPreparedExecuteAgainstQueryable(blindCast(ps), params, driverConn, {
|
|
1625
|
+
...options,
|
|
1626
|
+
scope: "connection"
|
|
1627
|
+
});
|
|
1511
1628
|
}
|
|
1512
1629
|
};
|
|
1513
1630
|
}
|
|
@@ -1537,6 +1654,12 @@ var SqlRuntimeBase = class extends RuntimeCore {
|
|
|
1537
1654
|
...options,
|
|
1538
1655
|
scope: "transaction"
|
|
1539
1656
|
});
|
|
1657
|
+
},
|
|
1658
|
+
[preparedStatementExecute](ps, params, options) {
|
|
1659
|
+
return self.runPreparedExecuteAgainstQueryable(blindCast(ps), params, driverTx, {
|
|
1660
|
+
...options,
|
|
1661
|
+
scope: "transaction"
|
|
1662
|
+
});
|
|
1540
1663
|
}
|
|
1541
1664
|
};
|
|
1542
1665
|
}
|
|
@@ -1624,6 +1747,10 @@ async function withTransaction(runtime, fn) {
|
|
|
1624
1747
|
[preparedStatementQuery](ps, params, options) {
|
|
1625
1748
|
if (invalidated) throw transactionClosedError();
|
|
1626
1749
|
return new AsyncIterableResult(guardedStream(runPreparedQuery(transaction, ps, params, options)));
|
|
1750
|
+
},
|
|
1751
|
+
[preparedStatementExecute](ps, params, options) {
|
|
1752
|
+
if (invalidated) throw transactionClosedError();
|
|
1753
|
+
return runPreparedExecute(transaction, ps, params, options);
|
|
1627
1754
|
}
|
|
1628
1755
|
};
|
|
1629
1756
|
let connectionDisposed = false;
|
|
@@ -1667,6 +1794,6 @@ async function withTransaction(runtime, fn) {
|
|
|
1667
1794
|
}
|
|
1668
1795
|
}
|
|
1669
1796
|
//#endregion
|
|
1670
|
-
export { PreparedStatementImpl, SqlRuntimeBase, budgets, createAstCodecRegistry, createExecutionContext, createSqlExecutionStack, deriveParamMetadata, encodeParamsWithMetadata, extractCodecIds, lints, lowerSqlPlan, validateCodecRegistryCompleteness, validateContractCodecMappings, withTransaction };
|
|
1797
|
+
export { PreparedExecutionImpl, PreparedStatementImpl, SqlRuntimeBase, budgets, createAstCodecRegistry, createExecutionContext, createSqlExecutionStack, deriveParamMetadata, encodeParamsWithMetadata, extractCodecIds, lints, lowerSqlPlan, validateCodecRegistryCompleteness, validateContractCodecMappings, withTransaction };
|
|
1671
1798
|
|
|
1672
1799
|
//# sourceMappingURL=runtime.mjs.map
|