@prisma/orm-target-mysql 0.0.0-stage → 8.0.0-rc.21-dev.23
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/LICENSE +201 -0
- package/README.md +20 -2
- package/dist/adapter-_WBomuTw.d.mts +27 -0
- package/dist/adapter-_WBomuTw.d.mts.map +1 -0
- package/dist/adapter.d.mts +6 -0
- package/dist/adapter.mjs +3 -0
- package/dist/adapter__adapter.d.mts +2 -0
- package/dist/adapter__adapter.mjs +2 -0
- package/dist/adapter__codec-types.d.mts +3 -0
- package/dist/adapter__codec-types.mjs +1 -0
- package/dist/adapter__control.d.mts +2 -0
- package/dist/adapter__control.mjs +2 -0
- package/dist/adapter__runtime.d.mts +2 -0
- package/dist/adapter__runtime.mjs +417 -0
- package/dist/adapter__runtime.mjs.map +1 -0
- package/dist/codec-descriptor-DXyubAS6-siA0R8Ow.d.mts +43 -0
- package/dist/codec-descriptor-DXyubAS6-siA0R8Ow.d.mts.map +1 -0
- package/dist/codec-descriptor-Du6DSz-3-ytBCu_mq.mjs +93 -0
- package/dist/codec-descriptor-Du6DSz-3-ytBCu_mq.mjs.map +1 -0
- package/dist/codec-descriptor-J3TP08l8-ekLvUVxW.d.mts +1 -0
- package/dist/codec-descriptor-oLRh9E29.d.mts +2 -0
- package/dist/codec-ids-BHUwoNOM.d.mts +2 -0
- package/dist/codec-ids-C00hAFkc.mjs +2 -0
- package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs +10 -0
- package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs.map +1 -0
- package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts +10 -0
- package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts.map +1 -0
- package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts +21 -0
- package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts.map +1 -0
- package/dist/codec-types-Bo3Jfilx.d.mts +1 -0
- package/dist/codec-types-Ja2kLzLS.d.mts +1 -0
- package/dist/codecs-C00kjHgh.mjs +282 -0
- package/dist/codecs-C00kjHgh.mjs.map +1 -0
- package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts +102 -0
- package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts.map +1 -0
- package/dist/codecs-DM61agRr.d.mts +21 -0
- package/dist/codecs-DM61agRr.d.mts.map +1 -0
- package/dist/contract-contributions-B9njRJbt-ClEtrK2L.mjs +14 -0
- package/dist/contract-contributions-B9njRJbt-ClEtrK2L.mjs.map +1 -0
- package/dist/contract-free-BvCdx_Ee.mjs +71 -0
- package/dist/contract-free-BvCdx_Ee.mjs.map +1 -0
- package/dist/contract-free-Cw9Mjcro.d.mts +22 -0
- package/dist/contract-free-Cw9Mjcro.d.mts.map +1 -0
- package/dist/control-C9zxRXNN.mjs +74 -0
- package/dist/control-C9zxRXNN.mjs.map +1 -0
- package/dist/control-DHkZbo58.d.mts +25 -0
- package/dist/control-DHkZbo58.d.mts.map +1 -0
- package/dist/control-Ez_PtlFI.d.mts +121 -0
- package/dist/control-Ez_PtlFI.d.mts.map +1 -0
- package/dist/control-WTY7Jpxk.mjs +577 -0
- package/dist/control-WTY7Jpxk.mjs.map +1 -0
- package/dist/control-_4epnrIW.d.mts +27 -0
- package/dist/control-_4epnrIW.d.mts.map +1 -0
- package/dist/control-tables-CHw2F-rg.d.mts +9 -0
- package/dist/control-tables-CHw2F-rg.d.mts.map +1 -0
- package/dist/control-tables-CcQ77JE7-CxTQYoQJ.mjs +9 -0
- package/dist/control-tables-CcQ77JE7-CxTQYoQJ.mjs.map +1 -0
- package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs +42 -0
- package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs.map +1 -0
- package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts +52 -0
- package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts.map +1 -0
- package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs +181 -0
- package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs.map +1 -0
- package/dist/data-types-SXrh0Lou.d.mts +8 -0
- package/dist/data-types-SXrh0Lou.d.mts.map +1 -0
- package/dist/ddl-CT6DPEqg.d.mts +1 -0
- package/dist/ddl-DDmMHyA_-Bb8sXoS0.mjs +12 -0
- package/dist/ddl-DDmMHyA_-Bb8sXoS0.mjs.map +1 -0
- package/dist/default-normalizer-BBhGpw7r.d.mts +27 -0
- package/dist/default-normalizer-BBhGpw7r.d.mts.map +1 -0
- package/dist/default-normalizer-BDUgHXUn-Xk7HQJuI.mjs +90 -0
- package/dist/default-normalizer-BDUgHXUn-Xk7HQJuI.mjs.map +1 -0
- package/dist/descriptor-meta-BurjcSiU-Cbk2L1jf.mjs +82 -0
- package/dist/descriptor-meta-BurjcSiU-Cbk2L1jf.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs +17 -0
- package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs.map +1 -0
- package/dist/driver.d.mts +3 -0
- package/dist/driver.mjs +2 -0
- package/dist/driver__control.d.mts +2 -0
- package/dist/driver__control.mjs +2 -0
- package/dist/driver__runtime.d.mts +2 -0
- package/dist/driver__runtime.mjs +325 -0
- package/dist/driver__runtime.mjs.map +1 -0
- package/dist/errors-BYhjQT7y.d.mts +10 -0
- package/dist/errors-BYhjQT7y.d.mts.map +1 -0
- package/dist/errors-rvH_F2Yj-BQrO_--u.mjs +20 -0
- package/dist/errors-rvH_F2Yj-BQrO_--u.mjs.map +1 -0
- package/dist/marker-lock-CmGvN4hw-Com29AtQ.mjs +51 -0
- package/dist/marker-lock-CmGvN4hw-Com29AtQ.mjs.map +1 -0
- package/dist/marker-lock-su6IxinO.d.mts +18 -0
- package/dist/marker-lock-su6IxinO.d.mts.map +1 -0
- package/dist/marker-read-aEaHihYj-Cyg16yn1.mjs +78 -0
- package/dist/marker-read-aEaHihYj-Cyg16yn1.mjs.map +1 -0
- package/dist/migration-DmlblTTw.d.mts +284 -0
- package/dist/migration-DmlblTTw.d.mts.map +1 -0
- package/dist/migration-tFuoN9GB.mjs +5 -0
- package/dist/mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs +160 -0
- package/dist/mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs.map +1 -0
- package/dist/nodes-CvcX47ot-B-ZaUYRj.mjs +25 -0
- package/dist/nodes-CvcX47ot-B-ZaUYRj.mjs.map +1 -0
- package/dist/nodes-xc0cR0_c-2YbhgEjb.d.mts +27 -0
- package/dist/nodes-xc0cR0_c-2YbhgEjb.d.mts.map +1 -0
- package/dist/pack-YVG-iBMQ.d.mts +1073 -0
- package/dist/pack-YVG-iBMQ.d.mts.map +1 -0
- package/dist/planner-target-details-D6g2uSp--C5NKHmCc.d.mts +12 -0
- package/dist/planner-target-details-D6g2uSp--C5NKHmCc.d.mts.map +1 -0
- package/dist/runner-C4r6yEd1-BWQrxW9q.mjs +1644 -0
- package/dist/runner-C4r6yEd1-BWQrxW9q.mjs.map +1 -0
- package/dist/runtime-BGyTXcQH.d.mts +36 -0
- package/dist/runtime-BGyTXcQH.d.mts.map +1 -0
- package/dist/runtime-CeuRr9nE.d.mts +29 -0
- package/dist/runtime-CeuRr9nE.d.mts.map +1 -0
- package/dist/runtime-Cl0BbTZq.d.mts +22 -0
- package/dist/runtime-Cl0BbTZq.d.mts.map +1 -0
- package/dist/sql-utils-BOS1c2QT.d.mts +30 -0
- package/dist/sql-utils-BOS1c2QT.d.mts.map +1 -0
- package/dist/sql-utils-Db0IQO_B-PaULnfrE.mjs +30 -0
- package/dist/sql-utils-Db0IQO_B-PaULnfrE.mjs.map +1 -0
- package/dist/sql-utils-RW0vJvDl.mjs +94 -0
- package/dist/sql-utils-RW0vJvDl.mjs.map +1 -0
- package/dist/statement-A6bbPBf1-q61iHQLb.mjs +483 -0
- package/dist/statement-A6bbPBf1-q61iHQLb.mjs.map +1 -0
- package/dist/target.d.mts +24 -0
- package/dist/target.mjs +19 -0
- package/dist/target__codec-descriptor.d.mts +3 -0
- package/dist/target__codec-descriptor.mjs +2 -0
- package/dist/target__codec-ids.d.mts +3 -0
- package/dist/target__codec-ids.mjs +3 -0
- package/dist/target__codec-types.d.mts +3 -0
- package/dist/target__codec-types.mjs +1 -0
- package/dist/target__codecs.d.mts +3 -0
- package/dist/target__codecs.mjs +2 -0
- package/dist/target__contract-free.d.mts +2 -0
- package/dist/target__contract-free.mjs +3 -0
- package/dist/target__control-tables.d.mts +2 -0
- package/dist/target__control-tables.mjs +2 -0
- package/dist/target__control.d.mts +3 -0
- package/dist/target__control.mjs +58 -0
- package/dist/target__control.mjs.map +1 -0
- package/dist/target__data-types.d.mts +3 -0
- package/dist/target__data-types.mjs +3 -0
- package/dist/target__ddl.d.mts +3 -0
- package/dist/target__ddl.mjs +2 -0
- package/dist/target__default-normalizer.d.mts +2 -0
- package/dist/target__default-normalizer.mjs +2 -0
- package/dist/target__errors.d.mts +2 -0
- package/dist/target__errors.mjs +2 -0
- package/dist/target__marker-lock.d.mts +2 -0
- package/dist/target__marker-lock.mjs +2 -0
- package/dist/target__migration.d.mts +2 -0
- package/dist/target__migration.mjs +3 -0
- package/dist/target__pack.d.mts +2 -0
- package/dist/target__pack.mjs +2 -0
- package/dist/target__runtime.d.mts +2 -0
- package/dist/target__runtime.mjs +17 -0
- package/dist/target__runtime.mjs.map +1 -0
- package/dist/target__sql-utils.d.mts +2 -0
- package/dist/target__sql-utils.mjs +3 -0
- package/package.json +71 -3
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { a as MYSQL_TEXT_CODEC_ID, i as MYSQL_INT_CODEC_ID, t as MYSQL_BIGINT_CODEC_ID } from "./codec-ids-cjxtOcLM-vFeQhgPm.mjs";
|
|
2
|
+
import { n as mysqlQueryNotYetSupported, t as mysqlError } from "./errors-rvH_F2Yj-BQrO_--u.mjs";
|
|
3
|
+
import { n as quoteIdentifier, t as escapeLiteral } from "./sql-utils-Db0IQO_B-PaULnfrE.mjs";
|
|
4
|
+
import { a as mysqlCodecDescriptorRegistry, t as assembleMysqlCodecRegistry } from "./codecs-C00kjHgh.mjs";
|
|
5
|
+
import { t as tokenizeMysqlSql } from "./sql-utils-RW0vJvDl.mjs";
|
|
6
|
+
import { t as mysqlAdapterCapabilities } from "./contract-contributions-B9njRJbt-ClEtrK2L.mjs";
|
|
7
|
+
import { i as readMarkerResult, n as mysqlAdapterDescriptorMeta } from "./marker-read-aEaHihYj-Cyg16yn1.mjs";
|
|
8
|
+
import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
9
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
10
|
+
import { collectOrderedParamRefs, isDdlNode } from "@prisma/orm-family-sql/relational-core/ast";
|
|
11
|
+
import { APP_SPACE_ID } from "@prisma/orm-framework/components/control";
|
|
12
|
+
//#region ../../../3-targets/mysql/2-adapter/dist/runtime.mjs
|
|
13
|
+
const INT_MIN = -(2 ** 31);
|
|
14
|
+
const INT_MAX = 2 ** 31 - 1;
|
|
15
|
+
function refuse(value) {
|
|
16
|
+
throw structuredError("RUNTIME.RAW_SQL_UNSUPPORTED_INTERPOLATION", "MySQL has no codec for this JS value in raw SQL: wrap it in `param(...)` with an explicit codec", { meta: { valueType: typeof value } });
|
|
17
|
+
}
|
|
18
|
+
/** The codec of a bare value interpolated into `fns.raw` or the raw lane on a MySQL client: integers, bigints and strings. */
|
|
19
|
+
const mysqlRawCodecInferer = { inferCodec(value) {
|
|
20
|
+
switch (typeof value) {
|
|
21
|
+
case "number":
|
|
22
|
+
if (!Number.isSafeInteger(value)) return refuse(value);
|
|
23
|
+
return value >= INT_MIN && value <= INT_MAX ? MYSQL_INT_CODEC_ID : refuse(value);
|
|
24
|
+
case "bigint": return MYSQL_BIGINT_CODEC_ID;
|
|
25
|
+
case "string": return MYSQL_TEXT_CODEC_ID;
|
|
26
|
+
default: return refuse(value);
|
|
27
|
+
}
|
|
28
|
+
} };
|
|
29
|
+
/** Refuses a lowered statement unless every placeholder is a numbered `?N` naming one of its parameters and every parameter has a placeholder. */
|
|
30
|
+
function assertPlaceholdersMatchParams(sql, paramCount) {
|
|
31
|
+
const tokens = tokenizeMysqlSql(sql).filter((token) => token.kind === "placeholder");
|
|
32
|
+
const placeholders = tokens.map((token) => token.text);
|
|
33
|
+
const numbers = tokens.map((token) => token.number ?? NaN);
|
|
34
|
+
if (numbers.every((number) => number >= 1 && number <= paramCount) && new Set(numbers).size === paramCount) return;
|
|
35
|
+
throw structuredError("RUNTIME.PARAM_PLACEHOLDER_MISMATCH", `The lowered MySQL statement writes placeholders ${JSON.stringify(placeholders)} for ${paramCount} parameter(s); each parameter must be written as its own numbered placeholder, and no other placeholder may appear.`, {
|
|
36
|
+
why: "A placeholder that does not match a parameter binds a value to the wrong place in the statement, or leaves a value unbound.",
|
|
37
|
+
fix: "Pass values into raw SQL through interpolation rather than writing a `?` in the SQL text.",
|
|
38
|
+
meta: {
|
|
39
|
+
placeholders,
|
|
40
|
+
params: paramCount
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Raises `group_concat_max_len` for this statement only, past any result a connection can send, so an ordered include does not depend on how the driver set up its session. MySQL takes `SET_VAR` only on the outermost `SELECT`.
|
|
46
|
+
*/
|
|
47
|
+
const GROUP_CONCAT_HINT = "/*+ SET_VAR(group_concat_max_len = 4294967295) */";
|
|
48
|
+
/** MySQL's documented way to write an `OFFSET` with no `LIMIT`: the largest row count it takes. */
|
|
49
|
+
const NO_LIMIT = "18446744073709551615";
|
|
50
|
+
function nodeKind(value) {
|
|
51
|
+
return typeof value === "object" && value !== null && "kind" in value ? String(value.kind) : "unknown";
|
|
52
|
+
}
|
|
53
|
+
function unsupported(feature, message) {
|
|
54
|
+
return mysqlError("RUNTIME.AST_UNSUPPORTED", message, { meta: {
|
|
55
|
+
target: "mysql",
|
|
56
|
+
feature
|
|
57
|
+
} });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Lowers a query AST to MySQL SQL. Each param is written as `?N`, N being its position in `collectOrderedParamRefs`, the order the runtime encodes and middleware edits params in; a param written twice is bound once. The driver fills the placeholders.
|
|
61
|
+
*/
|
|
62
|
+
function renderMysqlSql(ast, contract, codecs) {
|
|
63
|
+
const placeholderNumbers = /* @__PURE__ */ new Map();
|
|
64
|
+
const params = collectOrderedParamRefs(ast).map((ref, index) => {
|
|
65
|
+
placeholderNumbers.set(ref, index + 1);
|
|
66
|
+
return ref.kind === "prepared-param-ref" ? {
|
|
67
|
+
kind: "bind",
|
|
68
|
+
name: ref.name
|
|
69
|
+
} : {
|
|
70
|
+
kind: "literal",
|
|
71
|
+
value: ref.value
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
const ctx = {
|
|
75
|
+
contract,
|
|
76
|
+
codecs,
|
|
77
|
+
placeholderNumbers,
|
|
78
|
+
uses: { groupConcat: false }
|
|
79
|
+
};
|
|
80
|
+
const rendered = renderStatement(ast, ctx);
|
|
81
|
+
const sql = ctx.uses.groupConcat ? withGroupConcatHint(ast, rendered) : rendered;
|
|
82
|
+
assertPlaceholdersMatchParams(sql, params.length);
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
sql,
|
|
85
|
+
params
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Puts `GROUP_CONCAT_HINT` on the outermost `SELECT`; a statement without one would leave `GROUP_CONCAT` at the session's limit, which can cut an array after an element and still read as JSON, so it is refused. */
|
|
89
|
+
function withGroupConcatHint(ast, rendered) {
|
|
90
|
+
if (ast.kind !== "select" || !rendered.startsWith("SELECT ")) throw unsupported("ordered-array-outside-select", "MySQL can build an ordered JSON array only in a SELECT statement, whose outermost SELECT carries the hint that raises group_concat_max_len");
|
|
91
|
+
return `SELECT ${GROUP_CONCAT_HINT} ${rendered.slice(7)}`;
|
|
92
|
+
}
|
|
93
|
+
function renderStatement(ast, ctx) {
|
|
94
|
+
switch (ast.kind) {
|
|
95
|
+
case "select": return renderSelect(ast, ctx);
|
|
96
|
+
case "raw-query": return renderParts(ast.parts, ctx);
|
|
97
|
+
case "insert":
|
|
98
|
+
case "update":
|
|
99
|
+
case "delete": throw mysqlQueryNotYetSupported("Writing rows");
|
|
100
|
+
default: throw new InternalError(`Unsupported AST node kind: ${nodeKind(ast)}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function renderLimitOffset(keyword, value, ctx) {
|
|
104
|
+
if (value === void 0) return "";
|
|
105
|
+
if (typeof value === "number") return `${keyword} ${value}`;
|
|
106
|
+
return `${keyword} ${value.kind === "param-ref" || value.kind === "prepared-param-ref" ? placeholder(value, ctx) : renderExpr(value, ctx)}`;
|
|
107
|
+
}
|
|
108
|
+
function renderSelect(ast, ctx) {
|
|
109
|
+
if (ast.locking !== void 0 && ast.locking.length > 0) throw unsupported("locking-clause", "Row locks are not supported on MySQL yet, so a select cannot carry a locking clause such as FOR UPDATE");
|
|
110
|
+
if (ast.distinctOn !== void 0 && ast.distinctOn.length > 0) throw unsupported("distinct-on", "MySQL has no DISTINCT ON");
|
|
111
|
+
return [
|
|
112
|
+
`SELECT ${ast.distinct ? "DISTINCT " : ""}${renderProjection(ast.projection, ctx)}`,
|
|
113
|
+
ast.from === void 0 ? "" : `FROM ${renderSource(ast.from, ctx)}`,
|
|
114
|
+
ast.joins?.length ? ast.joins.map((join) => renderJoin(join, ctx)).join(" ") : "",
|
|
115
|
+
ast.where ? `WHERE ${renderExpr(ast.where, ctx)}` : "",
|
|
116
|
+
ast.groupBy?.length ? `GROUP BY ${ast.groupBy.map((e) => renderExpr(e, ctx)).join(", ")}` : "",
|
|
117
|
+
ast.having ? `HAVING ${renderExpr(ast.having, ctx)}` : "",
|
|
118
|
+
ast.orderBy?.length ? `ORDER BY ${renderOrderByItems(ast.orderBy, ctx)}` : "",
|
|
119
|
+
ast.limit === void 0 && ast.offset !== void 0 ? `LIMIT ${NO_LIMIT}` : renderLimitOffset("LIMIT", ast.limit, ctx),
|
|
120
|
+
renderLimitOffset("OFFSET", ast.offset, ctx)
|
|
121
|
+
].filter((part) => part.length > 0).join(" ");
|
|
122
|
+
}
|
|
123
|
+
function renderProjection(projection, ctx) {
|
|
124
|
+
return projection.map((item) => `${renderExpr(item.expr, ctx)} AS ${quoteIdentifier(item.alias)}`).join(", ");
|
|
125
|
+
}
|
|
126
|
+
function qualifyTable(table, ctx) {
|
|
127
|
+
if (table.namespaceId === void 0) return quoteIdentifier(table.name);
|
|
128
|
+
if (ctx.contract === void 0) throw new InternalError(`Table "${table.name}" carries namespace "${table.namespaceId}" but no contract was supplied to resolve it`);
|
|
129
|
+
const namespace = ctx.contract.storage.namespaces[table.namespaceId];
|
|
130
|
+
if (namespace?.qualifyTable === void 0) throw structuredError("RUNTIME.NAMESPACE_UNKNOWN", `Table "${table.name}" references namespace "${table.namespaceId}" which the contract does not materialise for SQL rendering`, { meta: {
|
|
131
|
+
table: table.name,
|
|
132
|
+
namespaceId: table.namespaceId,
|
|
133
|
+
reason: namespace === void 0 ? "not-present" : "not-materialised"
|
|
134
|
+
} });
|
|
135
|
+
return namespace.qualifyTable(table.name);
|
|
136
|
+
}
|
|
137
|
+
function renderTableSource(source, ctx) {
|
|
138
|
+
const qualified = qualifyTable(source, ctx);
|
|
139
|
+
return source.alias ? `${qualified} AS ${quoteIdentifier(source.alias)}` : qualified;
|
|
140
|
+
}
|
|
141
|
+
function renderSource(source, ctx) {
|
|
142
|
+
switch (source.kind) {
|
|
143
|
+
case "table-source": return renderTableSource(source, ctx);
|
|
144
|
+
case "derived-table-source": return `(${renderSelect(source.query, ctx)}) AS ${quoteIdentifier(source.alias)}`;
|
|
145
|
+
case "function-source": throw unsupported("function-source", `MySQL cannot select from the set-returning function ${source.fn}`);
|
|
146
|
+
default: return assertNever(source, `Unsupported source node kind: ${nodeKind(source)}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function renderExpr(expr, ctx) {
|
|
150
|
+
switch (expr.kind) {
|
|
151
|
+
case "column-ref": return renderColumn(expr);
|
|
152
|
+
case "identifier-ref": return quoteIdentifier(expr.name);
|
|
153
|
+
case "operation": return renderOperation(expr, ctx);
|
|
154
|
+
case "subquery": return renderSubquery(expr, ctx);
|
|
155
|
+
case "aggregate": return renderAggregate(expr, ctx);
|
|
156
|
+
case "window-func": return renderWindowFunc(expr, ctx);
|
|
157
|
+
case "function-call": return renderFunctionCall(expr, ctx);
|
|
158
|
+
case "cast": return renderCast(expr, ctx);
|
|
159
|
+
case "case": return renderCase(expr, ctx);
|
|
160
|
+
case "json-object": return renderJsonObject(expr, ctx);
|
|
161
|
+
case "json-array-agg": return renderJsonArrayAgg(expr, ctx);
|
|
162
|
+
case "binary": return renderBinary(expr, ctx);
|
|
163
|
+
case "and": return expr.exprs.length === 0 ? "TRUE" : `(${expr.exprs.map((part) => renderExpr(part, ctx)).join(" AND ")})`;
|
|
164
|
+
case "or": return expr.exprs.length === 0 ? "FALSE" : `(${expr.exprs.map((part) => renderExpr(part, ctx)).join(" OR ")})`;
|
|
165
|
+
case "exists": return `${expr.notExists ? "NOT " : ""}EXISTS (${renderSelect(expr.subquery, ctx)})`;
|
|
166
|
+
case "null-check": return renderNullCheck(expr, ctx);
|
|
167
|
+
case "not": return `NOT (${renderExpr(expr.expr, ctx)})`;
|
|
168
|
+
case "param-ref":
|
|
169
|
+
case "prepared-param-ref": return renderParam(expr, ctx);
|
|
170
|
+
case "literal": return renderLiteral(expr);
|
|
171
|
+
case "list": return renderList(expr, ctx);
|
|
172
|
+
case "raw-expr": return renderParts(expr.parts, ctx);
|
|
173
|
+
default: return assertNever(expr, `Unsupported expression node kind: ${nodeKind(expr)}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** Refuses raw SQL text that puts a digit right after an interpolated value: the value's `?N` and the digit would read as one larger placeholder, `?1` and `0` as `?10`. */
|
|
177
|
+
function assertNoDigitAfterParam(parts) {
|
|
178
|
+
parts.forEach((part, index) => {
|
|
179
|
+
const next = parts[index + 1];
|
|
180
|
+
if (typeof part !== "string" && (part.kind === "param-ref" || part.kind === "prepared-param-ref") && typeof next === "string" && /^\d/.test(next)) throw structuredError("RUNTIME.PARAM_PLACEHOLDER_MISMATCH", "Raw SQL puts a digit right after an interpolated value, which MySQL lowering would read as part of the value's placeholder", {
|
|
181
|
+
why: "Each value is written as a numbered placeholder, ?N, so a digit that follows it in the SQL text makes a different placeholder: ?1 followed by 0 reads as ?10.",
|
|
182
|
+
fix: "Put a space or an operator between the interpolated value and the digit.",
|
|
183
|
+
meta: {
|
|
184
|
+
reason: "digit-after-value",
|
|
185
|
+
part: index + 1
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function renderParts(parts, ctx) {
|
|
191
|
+
assertNoDigitAfterParam(parts);
|
|
192
|
+
return parts.map((part) => typeof part === "string" ? part : renderExpr(part, ctx)).join("");
|
|
193
|
+
}
|
|
194
|
+
function renderColumn(ref) {
|
|
195
|
+
return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A literal the code wrote: a number, a bigint, a boolean or NULL, such as the ORM's `1` and `fns.and(true, …)`. A `LiteralExpr` does not say where its value came from, and no part of Prisma writes a text, date or JSON literal into a MySQL runtime statement, so those are refused: a value of that kind can only be a caller's, which belongs in a param, sent apart from the SQL.
|
|
199
|
+
*/
|
|
200
|
+
function renderLiteral(expr) {
|
|
201
|
+
const { value } = expr;
|
|
202
|
+
if (value === null || value === void 0) return "NULL";
|
|
203
|
+
if (typeof value === "number") {
|
|
204
|
+
if (!Number.isFinite(value)) throw unsupported("non-finite-number", `MySQL has no literal for ${value}`);
|
|
205
|
+
return String(value);
|
|
206
|
+
}
|
|
207
|
+
if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
|
|
208
|
+
if (typeof value === "bigint") return String(value);
|
|
209
|
+
throw unsupported("value-literal", `MySQL lowering writes only numbers, booleans and NULL as literals; a ${value instanceof Date ? "date" : Array.isArray(value) ? "array" : typeof value} value must be a param`);
|
|
210
|
+
}
|
|
211
|
+
/** Renders each `{{self}}` and `{{argN}}` where the template writes it. */
|
|
212
|
+
function renderOperation(expr, ctx) {
|
|
213
|
+
return expr.lowering.template.replace(/\{\{(self|arg(\d+))\}\}/g, (_match, _name, index) => {
|
|
214
|
+
if (index === void 0) return renderExpr(expr.self, ctx);
|
|
215
|
+
const arg = expr.args[Number(index)];
|
|
216
|
+
return arg === void 0 ? "" : renderExpr(arg, ctx);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function renderSubquery(expr, ctx) {
|
|
220
|
+
if (expr.query.projection.length !== 1) throw structuredError("RUNTIME.AST_INVALID", "Subquery expressions must project exactly one column", { meta: { node: "subquery" } });
|
|
221
|
+
return `(${renderSelect(expr.query, ctx)})`;
|
|
222
|
+
}
|
|
223
|
+
/** Whether an operand must be parenthesised before an operator is written after it. A new expression kind fails to compile here until someone decides. */
|
|
224
|
+
function needsGrouping(expr) {
|
|
225
|
+
switch (expr.kind) {
|
|
226
|
+
case "operation":
|
|
227
|
+
case "subquery": return true;
|
|
228
|
+
case "column-ref":
|
|
229
|
+
case "identifier-ref":
|
|
230
|
+
case "aggregate":
|
|
231
|
+
case "window-func":
|
|
232
|
+
case "function-call":
|
|
233
|
+
case "cast":
|
|
234
|
+
case "case":
|
|
235
|
+
case "json-object":
|
|
236
|
+
case "json-array-agg":
|
|
237
|
+
case "binary":
|
|
238
|
+
case "and":
|
|
239
|
+
case "or":
|
|
240
|
+
case "exists":
|
|
241
|
+
case "null-check":
|
|
242
|
+
case "not":
|
|
243
|
+
case "param-ref":
|
|
244
|
+
case "prepared-param-ref":
|
|
245
|
+
case "literal":
|
|
246
|
+
case "list":
|
|
247
|
+
case "raw-expr": return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function grouped(expr, ctx) {
|
|
251
|
+
const rendered = renderExpr(expr, ctx);
|
|
252
|
+
return needsGrouping(expr) ? `(${rendered})` : rendered;
|
|
253
|
+
}
|
|
254
|
+
function renderNullCheck(expr, ctx) {
|
|
255
|
+
return `${grouped(expr.expr, ctx)} ${expr.isNull ? "IS NULL" : "IS NOT NULL"}`;
|
|
256
|
+
}
|
|
257
|
+
const BINARY_OPERATORS = {
|
|
258
|
+
eq: "=",
|
|
259
|
+
neq: "<>",
|
|
260
|
+
isNotDistinctFrom: "<=>",
|
|
261
|
+
gt: ">",
|
|
262
|
+
lt: "<",
|
|
263
|
+
gte: ">=",
|
|
264
|
+
lte: "<=",
|
|
265
|
+
like: "LIKE",
|
|
266
|
+
in: "IN",
|
|
267
|
+
notIn: "NOT IN"
|
|
268
|
+
};
|
|
269
|
+
function renderBinary(expr, ctx) {
|
|
270
|
+
if (expr.right.kind === "list" && expr.right.values.length === 0) {
|
|
271
|
+
if (expr.op === "in") return "FALSE";
|
|
272
|
+
if (expr.op === "notIn") return "TRUE";
|
|
273
|
+
}
|
|
274
|
+
const left = grouped(expr.left, ctx);
|
|
275
|
+
const right = renderExpr(expr.right, ctx);
|
|
276
|
+
if (expr.op === "isDistinctFrom") return `NOT (${left} <=> ${right})`;
|
|
277
|
+
return `${left} ${BINARY_OPERATORS[expr.op]} ${right}`;
|
|
278
|
+
}
|
|
279
|
+
function renderList(expr, ctx) {
|
|
280
|
+
if (expr.values.length === 0) return "(NULL)";
|
|
281
|
+
return `(${expr.values.map((value) => renderExpr(value, ctx)).join(", ")})`;
|
|
282
|
+
}
|
|
283
|
+
function renderAggregate(expr, ctx) {
|
|
284
|
+
const fn = expr.fn.toUpperCase();
|
|
285
|
+
return expr.expr ? `${fn}(${renderExpr(expr.expr, ctx)})` : `${fn}(*)`;
|
|
286
|
+
}
|
|
287
|
+
function renderWindowFunc(expr, ctx) {
|
|
288
|
+
const args = expr.args.map((arg) => renderExpr(arg, ctx)).join(", ");
|
|
289
|
+
const over = [expr.partitionBy?.length ? `PARTITION BY ${expr.partitionBy.map((e) => renderExpr(e, ctx)).join(", ")}` : "", expr.orderBy?.length ? `ORDER BY ${renderOrderByItems(expr.orderBy, ctx)}` : ""].filter((part) => part.length > 0).join(" ");
|
|
290
|
+
return `${expr.fn.toUpperCase()}(${args}) OVER (${over})`;
|
|
291
|
+
}
|
|
292
|
+
function renderFunctionCall(expr, ctx) {
|
|
293
|
+
return `${expr.fn}(${expr.args.map((arg) => renderExpr(arg, ctx)).join(", ")})`;
|
|
294
|
+
}
|
|
295
|
+
function renderCast(expr, ctx) {
|
|
296
|
+
return `CAST(${renderExpr(expr.expr, ctx)} AS ${expr.targetType})`;
|
|
297
|
+
}
|
|
298
|
+
function renderCase(expr, ctx) {
|
|
299
|
+
return `CASE ${expr.branches.map((branch) => `WHEN ${renderExpr(branch.condition, ctx)} THEN ${renderExpr(branch.value, ctx)}`).join(" ")}${expr.elseExpr === void 0 ? "" : ` ELSE ${renderExpr(expr.elseExpr, ctx)}`} END`;
|
|
300
|
+
}
|
|
301
|
+
function descriptorOf(codec, ctx, use) {
|
|
302
|
+
const descriptor = ctx.codecs.descriptorFor(codec.codecId);
|
|
303
|
+
if (descriptor === void 0) throw structuredError("RUNTIME.PARAM_REF_MISSING_CODEC", `MySQL lowering: ${use} carries codecId "${codec.codecId}" but the MySQL codec registry has no entry for it. Register the extension pack that contributes this codec.`, { meta: { codecId: codec.codecId } });
|
|
304
|
+
return descriptor;
|
|
305
|
+
}
|
|
306
|
+
function placeholder(ref, ctx) {
|
|
307
|
+
const number = ctx.placeholderNumbers.get(ref);
|
|
308
|
+
if (number === void 0) throw new InternalError("A param was written that the AST does not collect");
|
|
309
|
+
return `?${number}`;
|
|
310
|
+
}
|
|
311
|
+
/** A param as its numbered placeholder, refusing one whose codec the MySQL registry lacks. */
|
|
312
|
+
function renderParam(ref, ctx) {
|
|
313
|
+
if (ref.codec !== void 0) descriptorOf(ref.codec, ctx, "a parameter");
|
|
314
|
+
return placeholder(ref, ctx);
|
|
315
|
+
}
|
|
316
|
+
function projectThroughCodec(value, codec, ctx) {
|
|
317
|
+
return descriptorOf(codec, ctx, "a JSON projection").projectJson(value, codec);
|
|
318
|
+
}
|
|
319
|
+
function renderJsonValue(projection, ctx) {
|
|
320
|
+
return projection.accept({
|
|
321
|
+
codec: ({ value, codec }) => renderExpr(projectThroughCodec(value, codec, ctx), ctx),
|
|
322
|
+
native: ({ value }) => renderExpr(value, ctx),
|
|
323
|
+
document: ({ value }) => renderExpr(value, ctx)
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function renderJsonObject(expr, ctx) {
|
|
327
|
+
return `JSON_OBJECT(${expr.entries.flatMap((entry) => [`'${escapeLiteral(entry.key)}'`, renderJsonValue(entry.value, ctx)]).join(", ")})`;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The element of an ordered JSON array, as JSON text. A document already is JSON; a scalar goes through `JSON_ARRAY`, so a string arrives quoted and escaped.
|
|
331
|
+
*/
|
|
332
|
+
function renderJsonElementText(projection, ctx) {
|
|
333
|
+
const rendered = renderJsonValue(projection, ctx);
|
|
334
|
+
return projection.kind === "document" ? rendered : `JSON_EXTRACT(JSON_ARRAY(${rendered}), '$[0]')`;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* `JSON_ARRAYAGG` takes no `ORDER BY`, and MySQL drops a derived table's `ORDER BY` when the outer query aggregates, so an ordered array is built as text with `GROUP_CONCAT`, which keeps its own order, and cast to JSON. The statement raises `group_concat_max_len` past any result a connection can send (see `GROUP_CONCAT_HINT`), so `GROUP_CONCAT` never cuts the text short. Text longer than `max_allowed_packet` makes `CONCAT` return NULL with only a warning, which would read as an empty include; so an empty array is written only when there are no rows, and a NULL text with rows is replaced by text that is not JSON, which fails the cast and the statement with MySQL's invalid-JSON error. `JSON_ARRAYAGG` fails on its own when its result exceeds a packet. An empty array is `JSON_ARRAY()`, so the column stays JSON and a nested include stays an array.
|
|
338
|
+
*/
|
|
339
|
+
function renderJsonArrayAgg(expr, ctx) {
|
|
340
|
+
if (expr.orderBy === void 0) {
|
|
341
|
+
const aggregated = `JSON_ARRAYAGG(${renderJsonValue(expr.expr, ctx)})`;
|
|
342
|
+
return expr.onEmpty === "emptyArray" ? `COALESCE(${aggregated}, JSON_ARRAY())` : aggregated;
|
|
343
|
+
}
|
|
344
|
+
ctx.uses.groupConcat = true;
|
|
345
|
+
const text = `CONCAT('[', GROUP_CONCAT(${renderJsonElementText(expr.expr, ctx)} ORDER BY ${renderOrderByItems(expr.orderBy, ctx)} SEPARATOR ','), ']')`;
|
|
346
|
+
return `CASE WHEN COUNT(*) = 0 THEN ${expr.onEmpty === "emptyArray" ? "JSON_ARRAY()" : "NULL"} ELSE CAST(COALESCE(${text}, ${OVERSIZED_ARRAY_TEXT}) AS JSON) END`;
|
|
347
|
+
}
|
|
348
|
+
/** Text that is not JSON, written in place of an array MySQL could not build because it is larger than a packet, so the cast fails. MySQL's error does not show this text: the user sees `Invalid JSON text in argument 1 to function cast_as_json`, which names neither the include nor the packet size. The text counts the rows only so that MySQL evaluates it when it is reached, not while preparing the statement. */
|
|
349
|
+
const OVERSIZED_ARRAY_TEXT = "CONCAT('array larger than max_allowed_packet: ', COUNT(*), ' rows')";
|
|
350
|
+
const ORDER_DIRECTION = {
|
|
351
|
+
asc: "ASC",
|
|
352
|
+
desc: "DESC"
|
|
353
|
+
};
|
|
354
|
+
/** A NULLS FIRST or NULLS LAST placement, which MySQL lacks, as a leading `IS NULL` sort key. */
|
|
355
|
+
const NULLS_KEY_DIRECTION = {
|
|
356
|
+
first: "DESC",
|
|
357
|
+
last: "ASC"
|
|
358
|
+
};
|
|
359
|
+
function renderOrderByItem(item, ctx) {
|
|
360
|
+
return `${item.nulls === void 0 ? "" : `${grouped(item.expr, ctx)} IS NULL ${NULLS_KEY_DIRECTION[item.nulls]}, `}${renderExpr(item.expr, ctx)} ${ORDER_DIRECTION[item.dir]}`;
|
|
361
|
+
}
|
|
362
|
+
function renderOrderByItems(items, ctx) {
|
|
363
|
+
return items.map((item) => renderOrderByItem(item, ctx)).join(", ");
|
|
364
|
+
}
|
|
365
|
+
function renderJoin(join, ctx) {
|
|
366
|
+
if (join.joinType === "full") throw unsupported("full-join", "MySQL has no FULL JOIN");
|
|
367
|
+
if (join.lateral) throw unsupported("lateral-join", "LATERAL joins are not supported on MySQL yet");
|
|
368
|
+
return `${join.joinType.toUpperCase()} JOIN ${renderSource(join.source, ctx)} ON ${renderJoinOn(join.on, ctx)}`;
|
|
369
|
+
}
|
|
370
|
+
function renderJoinOn(on, ctx) {
|
|
371
|
+
return on.kind === "eq-col-join-on" ? `${renderColumn(on.left)} = ${renderColumn(on.right)}` : renderExpr(on, ctx);
|
|
372
|
+
}
|
|
373
|
+
function markerQuery(queryable) {
|
|
374
|
+
return { async query(sql, params) {
|
|
375
|
+
const rows = [];
|
|
376
|
+
for await (const row of queryable.query({
|
|
377
|
+
sql,
|
|
378
|
+
...params ? { params } : {}
|
|
379
|
+
})) rows.push(row);
|
|
380
|
+
return { rows };
|
|
381
|
+
} };
|
|
382
|
+
}
|
|
383
|
+
var MysqlAdapterImpl = class {
|
|
384
|
+
familyId = "sql";
|
|
385
|
+
targetId = "mysql";
|
|
386
|
+
profile;
|
|
387
|
+
#codecs;
|
|
388
|
+
constructor(codecs) {
|
|
389
|
+
this.#codecs = codecs;
|
|
390
|
+
this.profile = Object.freeze({
|
|
391
|
+
id: "mysql/default@1",
|
|
392
|
+
target: "mysql",
|
|
393
|
+
capabilities: mysqlAdapterCapabilities,
|
|
394
|
+
readMarker: (queryable) => readMarkerResult(markerQuery(queryable), APP_SPACE_ID)
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
lower(ast, context) {
|
|
398
|
+
if (isDdlNode(ast)) throw structuredError("RUNTIME.DDL_UNSUPPORTED", "lower() does not lower DDL on the runtime adapter: DDL lowering belongs to the control adapter.", { meta: { surface: "runtime-adapter" } });
|
|
399
|
+
return renderMysqlSql(ast, context.contract, this.#codecs);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
/** The MySQL runtime adapter: it lowers queries with the MySQL renderer and reads the marker 2b's control tables hold. */
|
|
403
|
+
function createMysqlAdapter(codecs) {
|
|
404
|
+
return Object.freeze(new MysqlAdapterImpl(codecs));
|
|
405
|
+
}
|
|
406
|
+
const mysqlRuntimeAdapterDescriptor = {
|
|
407
|
+
...mysqlAdapterDescriptorMeta,
|
|
408
|
+
codecs: () => Array.from(mysqlCodecDescriptorRegistry.values()),
|
|
409
|
+
rawCodecInferer: mysqlRawCodecInferer,
|
|
410
|
+
create(stack) {
|
|
411
|
+
return createMysqlAdapter(assembleMysqlCodecRegistry(stack.target, stack.extensions));
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
//#endregion
|
|
415
|
+
export { mysqlRuntimeAdapterDescriptor as default };
|
|
416
|
+
|
|
417
|
+
//# sourceMappingURL=adapter__runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter__runtime.mjs","names":["#codecs"],"sources":["../../../../3-targets/mysql/2-adapter/dist/runtime.mjs"],"sourcesContent":["import { n as mysqlAdapterCapabilities } from \"./contract-contributions-B9njRJbt.mjs\";\nimport { o as mysqlAdapterDescriptorMeta, r as readMarkerResult } from \"./marker-read-aEaHihYj.mjs\";\nimport { assembleMysqlCodecRegistry, mysqlCodecDescriptorRegistry } from \"@internal/target-mysql/codecs\";\nimport { APP_SPACE_ID } from \"@internal/framework-components/control\";\nimport { collectOrderedParamRefs, isDdlNode } from \"@internal/sql-relational-core/ast\";\nimport { mysqlError, mysqlQueryNotYetSupported } from \"@internal/target-mysql/errors\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { escapeLiteral, quoteIdentifier, tokenizeMysqlSql } from \"@internal/target-mysql/sql-utils\";\nimport { MYSQL_BIGINT_CODEC_ID, MYSQL_INT_CODEC_ID, MYSQL_TEXT_CODEC_ID } from \"@internal/target-mysql/codec-ids\";\nimport { InternalError, assertNever } from \"@internal/utils/internal-error\";\n//#region src/core/raw-codec-inferer.ts\nconst INT_MIN = -(2 ** 31);\nconst INT_MAX = 2 ** 31 - 1;\nfunction refuse(value) {\n\tthrow structuredError(\"RUNTIME.RAW_SQL_UNSUPPORTED_INTERPOLATION\", \"MySQL has no codec for this JS value in raw SQL: wrap it in `param(...)` with an explicit codec\", { meta: { valueType: typeof value } });\n}\n/** The codec of a bare value interpolated into `fns.raw` or the raw lane on a MySQL client: integers, bigints and strings. */\nconst mysqlRawCodecInferer = { inferCodec(value) {\n\tswitch (typeof value) {\n\t\tcase \"number\":\n\t\t\tif (!Number.isSafeInteger(value)) return refuse(value);\n\t\t\treturn value >= INT_MIN && value <= INT_MAX ? MYSQL_INT_CODEC_ID : refuse(value);\n\t\tcase \"bigint\": return MYSQL_BIGINT_CODEC_ID;\n\t\tcase \"string\": return MYSQL_TEXT_CODEC_ID;\n\t\tdefault: return refuse(value);\n\t}\n} };\n//#endregion\n//#region src/core/placeholders.ts\n/** Refuses a lowered statement unless every placeholder is a numbered `?N` naming one of its parameters and every parameter has a placeholder. */\nfunction assertPlaceholdersMatchParams(sql, paramCount) {\n\tconst tokens = tokenizeMysqlSql(sql).filter((token) => token.kind === \"placeholder\");\n\tconst placeholders = tokens.map((token) => token.text);\n\tconst numbers = tokens.map((token) => token.number ?? NaN);\n\tif (numbers.every((number) => number >= 1 && number <= paramCount) && new Set(numbers).size === paramCount) return;\n\tthrow structuredError(\"RUNTIME.PARAM_PLACEHOLDER_MISMATCH\", `The lowered MySQL statement writes placeholders ${JSON.stringify(placeholders)} for ${paramCount} parameter(s); each parameter must be written as its own numbered placeholder, and no other placeholder may appear.`, {\n\t\twhy: \"A placeholder that does not match a parameter binds a value to the wrong place in the statement, or leaves a value unbound.\",\n\t\tfix: \"Pass values into raw SQL through interpolation rather than writing a `?` in the SQL text.\",\n\t\tmeta: {\n\t\t\tplaceholders,\n\t\t\tparams: paramCount\n\t\t}\n\t});\n}\n//#endregion\n//#region src/core/sql-renderer.ts\n/**\n* Raises `group_concat_max_len` for this statement only, past any result a connection can send, so an ordered include does not depend on how the driver set up its session. MySQL takes `SET_VAR` only on the outermost `SELECT`.\n*/\nconst GROUP_CONCAT_HINT = \"/*+ SET_VAR(group_concat_max_len = 4294967295) */\";\n/** MySQL's documented way to write an `OFFSET` with no `LIMIT`: the largest row count it takes. */\nconst NO_LIMIT = \"18446744073709551615\";\nfunction nodeKind(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value ? String(value.kind) : \"unknown\";\n}\nfunction unsupported(feature, message) {\n\treturn mysqlError(\"RUNTIME.AST_UNSUPPORTED\", message, { meta: {\n\t\ttarget: \"mysql\",\n\t\tfeature\n\t} });\n}\n/**\n* Lowers a query AST to MySQL SQL. Each param is written as `?N`, N being its position in `collectOrderedParamRefs`, the order the runtime encodes and middleware edits params in; a param written twice is bound once. The driver fills the placeholders.\n*/\nfunction renderMysqlSql(ast, contract, codecs) {\n\tconst placeholderNumbers = /* @__PURE__ */ new Map();\n\tconst params = collectOrderedParamRefs(ast).map((ref, index) => {\n\t\tplaceholderNumbers.set(ref, index + 1);\n\t\treturn ref.kind === \"prepared-param-ref\" ? {\n\t\t\tkind: \"bind\",\n\t\t\tname: ref.name\n\t\t} : {\n\t\t\tkind: \"literal\",\n\t\t\tvalue: ref.value\n\t\t};\n\t});\n\tconst ctx = {\n\t\tcontract,\n\t\tcodecs,\n\t\tplaceholderNumbers,\n\t\tuses: { groupConcat: false }\n\t};\n\tconst rendered = renderStatement(ast, ctx);\n\tconst sql = ctx.uses.groupConcat ? withGroupConcatHint(ast, rendered) : rendered;\n\tassertPlaceholdersMatchParams(sql, params.length);\n\treturn Object.freeze({\n\t\tsql,\n\t\tparams\n\t});\n}\n/** Puts `GROUP_CONCAT_HINT` on the outermost `SELECT`; a statement without one would leave `GROUP_CONCAT` at the session's limit, which can cut an array after an element and still read as JSON, so it is refused. */\nfunction withGroupConcatHint(ast, rendered) {\n\tif (ast.kind !== \"select\" || !rendered.startsWith(\"SELECT \")) throw unsupported(\"ordered-array-outside-select\", \"MySQL can build an ordered JSON array only in a SELECT statement, whose outermost SELECT carries the hint that raises group_concat_max_len\");\n\treturn `SELECT ${GROUP_CONCAT_HINT} ${rendered.slice(7)}`;\n}\nfunction renderStatement(ast, ctx) {\n\tswitch (ast.kind) {\n\t\tcase \"select\": return renderSelect(ast, ctx);\n\t\tcase \"raw-query\": return renderParts(ast.parts, ctx);\n\t\tcase \"insert\":\n\t\tcase \"update\":\n\t\tcase \"delete\": throw mysqlQueryNotYetSupported(\"Writing rows\");\n\t\tdefault: throw new InternalError(`Unsupported AST node kind: ${nodeKind(ast)}`);\n\t}\n}\nfunction renderLimitOffset(keyword, value, ctx) {\n\tif (value === void 0) return \"\";\n\tif (typeof value === \"number\") return `${keyword} ${value}`;\n\treturn `${keyword} ${value.kind === \"param-ref\" || value.kind === \"prepared-param-ref\" ? placeholder(value, ctx) : renderExpr(value, ctx)}`;\n}\nfunction renderSelect(ast, ctx) {\n\tif (ast.locking !== void 0 && ast.locking.length > 0) throw unsupported(\"locking-clause\", \"Row locks are not supported on MySQL yet, so a select cannot carry a locking clause such as FOR UPDATE\");\n\tif (ast.distinctOn !== void 0 && ast.distinctOn.length > 0) throw unsupported(\"distinct-on\", \"MySQL has no DISTINCT ON\");\n\treturn [\n\t\t`SELECT ${ast.distinct ? \"DISTINCT \" : \"\"}${renderProjection(ast.projection, ctx)}`,\n\t\tast.from === void 0 ? \"\" : `FROM ${renderSource(ast.from, ctx)}`,\n\t\tast.joins?.length ? ast.joins.map((join) => renderJoin(join, ctx)).join(\" \") : \"\",\n\t\tast.where ? `WHERE ${renderExpr(ast.where, ctx)}` : \"\",\n\t\tast.groupBy?.length ? `GROUP BY ${ast.groupBy.map((e) => renderExpr(e, ctx)).join(\", \")}` : \"\",\n\t\tast.having ? `HAVING ${renderExpr(ast.having, ctx)}` : \"\",\n\t\tast.orderBy?.length ? `ORDER BY ${renderOrderByItems(ast.orderBy, ctx)}` : \"\",\n\t\tast.limit === void 0 && ast.offset !== void 0 ? `LIMIT ${NO_LIMIT}` : renderLimitOffset(\"LIMIT\", ast.limit, ctx),\n\t\trenderLimitOffset(\"OFFSET\", ast.offset, ctx)\n\t].filter((part) => part.length > 0).join(\" \");\n}\nfunction renderProjection(projection, ctx) {\n\treturn projection.map((item) => `${renderExpr(item.expr, ctx)} AS ${quoteIdentifier(item.alias)}`).join(\", \");\n}\nfunction qualifyTable(table, ctx) {\n\tif (table.namespaceId === void 0) return quoteIdentifier(table.name);\n\tif (ctx.contract === void 0) throw new InternalError(`Table \"${table.name}\" carries namespace \"${table.namespaceId}\" but no contract was supplied to resolve it`);\n\tconst namespace = ctx.contract.storage.namespaces[table.namespaceId];\n\tif (namespace?.qualifyTable === void 0) throw structuredError(\"RUNTIME.NAMESPACE_UNKNOWN\", `Table \"${table.name}\" references namespace \"${table.namespaceId}\" which the contract does not materialise for SQL rendering`, { meta: {\n\t\ttable: table.name,\n\t\tnamespaceId: table.namespaceId,\n\t\treason: namespace === void 0 ? \"not-present\" : \"not-materialised\"\n\t} });\n\treturn namespace.qualifyTable(table.name);\n}\nfunction renderTableSource(source, ctx) {\n\tconst qualified = qualifyTable(source, ctx);\n\treturn source.alias ? `${qualified} AS ${quoteIdentifier(source.alias)}` : qualified;\n}\nfunction renderSource(source, ctx) {\n\tswitch (source.kind) {\n\t\tcase \"table-source\": return renderTableSource(source, ctx);\n\t\tcase \"derived-table-source\": return `(${renderSelect(source.query, ctx)}) AS ${quoteIdentifier(source.alias)}`;\n\t\tcase \"function-source\": throw unsupported(\"function-source\", `MySQL cannot select from the set-returning function ${source.fn}`);\n\t\tdefault: return assertNever(source, `Unsupported source node kind: ${nodeKind(source)}`);\n\t}\n}\nfunction renderExpr(expr, ctx) {\n\tswitch (expr.kind) {\n\t\tcase \"column-ref\": return renderColumn(expr);\n\t\tcase \"identifier-ref\": return quoteIdentifier(expr.name);\n\t\tcase \"operation\": return renderOperation(expr, ctx);\n\t\tcase \"subquery\": return renderSubquery(expr, ctx);\n\t\tcase \"aggregate\": return renderAggregate(expr, ctx);\n\t\tcase \"window-func\": return renderWindowFunc(expr, ctx);\n\t\tcase \"function-call\": return renderFunctionCall(expr, ctx);\n\t\tcase \"cast\": return renderCast(expr, ctx);\n\t\tcase \"case\": return renderCase(expr, ctx);\n\t\tcase \"json-object\": return renderJsonObject(expr, ctx);\n\t\tcase \"json-array-agg\": return renderJsonArrayAgg(expr, ctx);\n\t\tcase \"binary\": return renderBinary(expr, ctx);\n\t\tcase \"and\": return expr.exprs.length === 0 ? \"TRUE\" : `(${expr.exprs.map((part) => renderExpr(part, ctx)).join(\" AND \")})`;\n\t\tcase \"or\": return expr.exprs.length === 0 ? \"FALSE\" : `(${expr.exprs.map((part) => renderExpr(part, ctx)).join(\" OR \")})`;\n\t\tcase \"exists\": return `${expr.notExists ? \"NOT \" : \"\"}EXISTS (${renderSelect(expr.subquery, ctx)})`;\n\t\tcase \"null-check\": return renderNullCheck(expr, ctx);\n\t\tcase \"not\": return `NOT (${renderExpr(expr.expr, ctx)})`;\n\t\tcase \"param-ref\":\n\t\tcase \"prepared-param-ref\": return renderParam(expr, ctx);\n\t\tcase \"literal\": return renderLiteral(expr);\n\t\tcase \"list\": return renderList(expr, ctx);\n\t\tcase \"raw-expr\": return renderParts(expr.parts, ctx);\n\t\tdefault: return assertNever(expr, `Unsupported expression node kind: ${nodeKind(expr)}`);\n\t}\n}\n/** Refuses raw SQL text that puts a digit right after an interpolated value: the value's `?N` and the digit would read as one larger placeholder, `?1` and `0` as `?10`. */\nfunction assertNoDigitAfterParam(parts) {\n\tparts.forEach((part, index) => {\n\t\tconst next = parts[index + 1];\n\t\tif (typeof part !== \"string\" && (part.kind === \"param-ref\" || part.kind === \"prepared-param-ref\") && typeof next === \"string\" && /^\\d/.test(next)) throw structuredError(\"RUNTIME.PARAM_PLACEHOLDER_MISMATCH\", \"Raw SQL puts a digit right after an interpolated value, which MySQL lowering would read as part of the value's placeholder\", {\n\t\t\twhy: \"Each value is written as a numbered placeholder, ?N, so a digit that follows it in the SQL text makes a different placeholder: ?1 followed by 0 reads as ?10.\",\n\t\t\tfix: \"Put a space or an operator between the interpolated value and the digit.\",\n\t\t\tmeta: {\n\t\t\t\treason: \"digit-after-value\",\n\t\t\t\tpart: index + 1\n\t\t\t}\n\t\t});\n\t});\n}\nfunction renderParts(parts, ctx) {\n\tassertNoDigitAfterParam(parts);\n\treturn parts.map((part) => typeof part === \"string\" ? part : renderExpr(part, ctx)).join(\"\");\n}\nfunction renderColumn(ref) {\n\treturn `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;\n}\n/**\n* A literal the code wrote: a number, a bigint, a boolean or NULL, such as the ORM's `1` and `fns.and(true, …)`. A `LiteralExpr` does not say where its value came from, and no part of Prisma writes a text, date or JSON literal into a MySQL runtime statement, so those are refused: a value of that kind can only be a caller's, which belongs in a param, sent apart from the SQL.\n*/\nfunction renderLiteral(expr) {\n\tconst { value } = expr;\n\tif (value === null || value === void 0) return \"NULL\";\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) throw unsupported(\"non-finite-number\", `MySQL has no literal for ${value}`);\n\t\treturn String(value);\n\t}\n\tif (typeof value === \"boolean\") return value ? \"TRUE\" : \"FALSE\";\n\tif (typeof value === \"bigint\") return String(value);\n\tthrow unsupported(\"value-literal\", `MySQL lowering writes only numbers, booleans and NULL as literals; a ${value instanceof Date ? \"date\" : Array.isArray(value) ? \"array\" : typeof value} value must be a param`);\n}\n/** Renders each `{{self}}` and `{{argN}}` where the template writes it. */\nfunction renderOperation(expr, ctx) {\n\treturn expr.lowering.template.replace(/\\{\\{(self|arg(\\d+))\\}\\}/g, (_match, _name, index) => {\n\t\tif (index === void 0) return renderExpr(expr.self, ctx);\n\t\tconst arg = expr.args[Number(index)];\n\t\treturn arg === void 0 ? \"\" : renderExpr(arg, ctx);\n\t});\n}\nfunction renderSubquery(expr, ctx) {\n\tif (expr.query.projection.length !== 1) throw structuredError(\"RUNTIME.AST_INVALID\", \"Subquery expressions must project exactly one column\", { meta: { node: \"subquery\" } });\n\treturn `(${renderSelect(expr.query, ctx)})`;\n}\n/** Whether an operand must be parenthesised before an operator is written after it. A new expression kind fails to compile here until someone decides. */\nfunction needsGrouping(expr) {\n\tswitch (expr.kind) {\n\t\tcase \"operation\":\n\t\tcase \"subquery\": return true;\n\t\tcase \"column-ref\":\n\t\tcase \"identifier-ref\":\n\t\tcase \"aggregate\":\n\t\tcase \"window-func\":\n\t\tcase \"function-call\":\n\t\tcase \"cast\":\n\t\tcase \"case\":\n\t\tcase \"json-object\":\n\t\tcase \"json-array-agg\":\n\t\tcase \"binary\":\n\t\tcase \"and\":\n\t\tcase \"or\":\n\t\tcase \"exists\":\n\t\tcase \"null-check\":\n\t\tcase \"not\":\n\t\tcase \"param-ref\":\n\t\tcase \"prepared-param-ref\":\n\t\tcase \"literal\":\n\t\tcase \"list\":\n\t\tcase \"raw-expr\": return false;\n\t}\n}\nfunction grouped(expr, ctx) {\n\tconst rendered = renderExpr(expr, ctx);\n\treturn needsGrouping(expr) ? `(${rendered})` : rendered;\n}\nfunction renderNullCheck(expr, ctx) {\n\treturn `${grouped(expr.expr, ctx)} ${expr.isNull ? \"IS NULL\" : \"IS NOT NULL\"}`;\n}\nconst BINARY_OPERATORS = {\n\teq: \"=\",\n\tneq: \"<>\",\n\tisNotDistinctFrom: \"<=>\",\n\tgt: \">\",\n\tlt: \"<\",\n\tgte: \">=\",\n\tlte: \"<=\",\n\tlike: \"LIKE\",\n\tin: \"IN\",\n\tnotIn: \"NOT IN\"\n};\nfunction renderBinary(expr, ctx) {\n\tif (expr.right.kind === \"list\" && expr.right.values.length === 0) {\n\t\tif (expr.op === \"in\") return \"FALSE\";\n\t\tif (expr.op === \"notIn\") return \"TRUE\";\n\t}\n\tconst left = grouped(expr.left, ctx);\n\tconst right = renderExpr(expr.right, ctx);\n\tif (expr.op === \"isDistinctFrom\") return `NOT (${left} <=> ${right})`;\n\treturn `${left} ${BINARY_OPERATORS[expr.op]} ${right}`;\n}\nfunction renderList(expr, ctx) {\n\tif (expr.values.length === 0) return \"(NULL)\";\n\treturn `(${expr.values.map((value) => renderExpr(value, ctx)).join(\", \")})`;\n}\nfunction renderAggregate(expr, ctx) {\n\tconst fn = expr.fn.toUpperCase();\n\treturn expr.expr ? `${fn}(${renderExpr(expr.expr, ctx)})` : `${fn}(*)`;\n}\nfunction renderWindowFunc(expr, ctx) {\n\tconst args = expr.args.map((arg) => renderExpr(arg, ctx)).join(\", \");\n\tconst over = [expr.partitionBy?.length ? `PARTITION BY ${expr.partitionBy.map((e) => renderExpr(e, ctx)).join(\", \")}` : \"\", expr.orderBy?.length ? `ORDER BY ${renderOrderByItems(expr.orderBy, ctx)}` : \"\"].filter((part) => part.length > 0).join(\" \");\n\treturn `${expr.fn.toUpperCase()}(${args}) OVER (${over})`;\n}\nfunction renderFunctionCall(expr, ctx) {\n\treturn `${expr.fn}(${expr.args.map((arg) => renderExpr(arg, ctx)).join(\", \")})`;\n}\nfunction renderCast(expr, ctx) {\n\treturn `CAST(${renderExpr(expr.expr, ctx)} AS ${expr.targetType})`;\n}\nfunction renderCase(expr, ctx) {\n\treturn `CASE ${expr.branches.map((branch) => `WHEN ${renderExpr(branch.condition, ctx)} THEN ${renderExpr(branch.value, ctx)}`).join(\" \")}${expr.elseExpr === void 0 ? \"\" : ` ELSE ${renderExpr(expr.elseExpr, ctx)}`} END`;\n}\nfunction descriptorOf(codec, ctx, use) {\n\tconst descriptor = ctx.codecs.descriptorFor(codec.codecId);\n\tif (descriptor === void 0) throw structuredError(\"RUNTIME.PARAM_REF_MISSING_CODEC\", `MySQL lowering: ${use} carries codecId \"${codec.codecId}\" but the MySQL codec registry has no entry for it. Register the extension pack that contributes this codec.`, { meta: { codecId: codec.codecId } });\n\treturn descriptor;\n}\nfunction placeholder(ref, ctx) {\n\tconst number = ctx.placeholderNumbers.get(ref);\n\tif (number === void 0) throw new InternalError(\"A param was written that the AST does not collect\");\n\treturn `?${number}`;\n}\n/** A param as its numbered placeholder, refusing one whose codec the MySQL registry lacks. */\nfunction renderParam(ref, ctx) {\n\tif (ref.codec !== void 0) descriptorOf(ref.codec, ctx, \"a parameter\");\n\treturn placeholder(ref, ctx);\n}\nfunction projectThroughCodec(value, codec, ctx) {\n\treturn descriptorOf(codec, ctx, \"a JSON projection\").projectJson(value, codec);\n}\nfunction renderJsonValue(projection, ctx) {\n\treturn projection.accept({\n\t\tcodec: ({ value, codec }) => renderExpr(projectThroughCodec(value, codec, ctx), ctx),\n\t\tnative: ({ value }) => renderExpr(value, ctx),\n\t\tdocument: ({ value }) => renderExpr(value, ctx)\n\t});\n}\nfunction renderJsonObject(expr, ctx) {\n\treturn `JSON_OBJECT(${expr.entries.flatMap((entry) => [`'${escapeLiteral(entry.key)}'`, renderJsonValue(entry.value, ctx)]).join(\", \")})`;\n}\n/**\n* The element of an ordered JSON array, as JSON text. A document already is JSON; a scalar goes through `JSON_ARRAY`, so a string arrives quoted and escaped.\n*/\nfunction renderJsonElementText(projection, ctx) {\n\tconst rendered = renderJsonValue(projection, ctx);\n\treturn projection.kind === \"document\" ? rendered : `JSON_EXTRACT(JSON_ARRAY(${rendered}), '$[0]')`;\n}\n/**\n* `JSON_ARRAYAGG` takes no `ORDER BY`, and MySQL drops a derived table's `ORDER BY` when the outer query aggregates, so an ordered array is built as text with `GROUP_CONCAT`, which keeps its own order, and cast to JSON. The statement raises `group_concat_max_len` past any result a connection can send (see `GROUP_CONCAT_HINT`), so `GROUP_CONCAT` never cuts the text short. Text longer than `max_allowed_packet` makes `CONCAT` return NULL with only a warning, which would read as an empty include; so an empty array is written only when there are no rows, and a NULL text with rows is replaced by text that is not JSON, which fails the cast and the statement with MySQL's invalid-JSON error. `JSON_ARRAYAGG` fails on its own when its result exceeds a packet. An empty array is `JSON_ARRAY()`, so the column stays JSON and a nested include stays an array.\n*/\nfunction renderJsonArrayAgg(expr, ctx) {\n\tif (expr.orderBy === void 0) {\n\t\tconst aggregated = `JSON_ARRAYAGG(${renderJsonValue(expr.expr, ctx)})`;\n\t\treturn expr.onEmpty === \"emptyArray\" ? `COALESCE(${aggregated}, JSON_ARRAY())` : aggregated;\n\t}\n\tctx.uses.groupConcat = true;\n\tconst text = `CONCAT('[', GROUP_CONCAT(${renderJsonElementText(expr.expr, ctx)} ORDER BY ${renderOrderByItems(expr.orderBy, ctx)} SEPARATOR ','), ']')`;\n\treturn `CASE WHEN COUNT(*) = 0 THEN ${expr.onEmpty === \"emptyArray\" ? \"JSON_ARRAY()\" : \"NULL\"} ELSE CAST(COALESCE(${text}, ${OVERSIZED_ARRAY_TEXT}) AS JSON) END`;\n}\n/** Text that is not JSON, written in place of an array MySQL could not build because it is larger than a packet, so the cast fails. MySQL's error does not show this text: the user sees `Invalid JSON text in argument 1 to function cast_as_json`, which names neither the include nor the packet size. The text counts the rows only so that MySQL evaluates it when it is reached, not while preparing the statement. */\nconst OVERSIZED_ARRAY_TEXT = \"CONCAT('array larger than max_allowed_packet: ', COUNT(*), ' rows')\";\nconst ORDER_DIRECTION = {\n\tasc: \"ASC\",\n\tdesc: \"DESC\"\n};\n/** A NULLS FIRST or NULLS LAST placement, which MySQL lacks, as a leading `IS NULL` sort key. */\nconst NULLS_KEY_DIRECTION = {\n\tfirst: \"DESC\",\n\tlast: \"ASC\"\n};\nfunction renderOrderByItem(item, ctx) {\n\treturn `${item.nulls === void 0 ? \"\" : `${grouped(item.expr, ctx)} IS NULL ${NULLS_KEY_DIRECTION[item.nulls]}, `}${renderExpr(item.expr, ctx)} ${ORDER_DIRECTION[item.dir]}`;\n}\nfunction renderOrderByItems(items, ctx) {\n\treturn items.map((item) => renderOrderByItem(item, ctx)).join(\", \");\n}\nfunction renderJoin(join, ctx) {\n\tif (join.joinType === \"full\") throw unsupported(\"full-join\", \"MySQL has no FULL JOIN\");\n\tif (join.lateral) throw unsupported(\"lateral-join\", \"LATERAL joins are not supported on MySQL yet\");\n\treturn `${join.joinType.toUpperCase()} JOIN ${renderSource(join.source, ctx)} ON ${renderJoinOn(join.on, ctx)}`;\n}\nfunction renderJoinOn(on, ctx) {\n\treturn on.kind === \"eq-col-join-on\" ? `${renderColumn(on.left)} = ${renderColumn(on.right)}` : renderExpr(on, ctx);\n}\n//#endregion\n//#region src/core/runtime/mysql-adapter.ts\nfunction markerQuery(queryable) {\n\treturn { async query(sql, params) {\n\t\tconst rows = [];\n\t\tfor await (const row of queryable.query({\n\t\t\tsql,\n\t\t\t...params ? { params } : {}\n\t\t})) rows.push(row);\n\t\treturn { rows };\n\t} };\n}\nvar MysqlAdapterImpl = class {\n\tfamilyId = \"sql\";\n\ttargetId = \"mysql\";\n\tprofile;\n\t#codecs;\n\tconstructor(codecs) {\n\t\tthis.#codecs = codecs;\n\t\tthis.profile = Object.freeze({\n\t\t\tid: \"mysql/default@1\",\n\t\t\ttarget: \"mysql\",\n\t\t\tcapabilities: mysqlAdapterCapabilities,\n\t\t\treadMarker: (queryable) => readMarkerResult(markerQuery(queryable), APP_SPACE_ID)\n\t\t});\n\t}\n\tlower(ast, context) {\n\t\tif (isDdlNode(ast)) throw structuredError(\"RUNTIME.DDL_UNSUPPORTED\", \"lower() does not lower DDL on the runtime adapter: DDL lowering belongs to the control adapter.\", { meta: { surface: \"runtime-adapter\" } });\n\t\treturn renderMysqlSql(ast, context.contract, this.#codecs);\n\t}\n};\n/** The MySQL runtime adapter: it lowers queries with the MySQL renderer and reads the marker 2b's control tables hold. */\nfunction createMysqlAdapter(codecs) {\n\treturn Object.freeze(new MysqlAdapterImpl(codecs));\n}\n//#endregion\n//#region src/core/runtime/runtime-adapter.ts\nconst mysqlRuntimeAdapterDescriptor = {\n\t...mysqlAdapterDescriptorMeta,\n\tcodecs: () => Array.from(mysqlCodecDescriptorRegistry.values()),\n\trawCodecInferer: mysqlRawCodecInferer,\n\tcreate(stack) {\n\t\treturn createMysqlAdapter(assembleMysqlCodecRegistry(stack.target, stack.extensions));\n\t}\n};\n//#endregion\nexport { mysqlRuntimeAdap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CAC/B,OAAO,EAAE,MAAM,MAAM,KAAK,QAAQ;EACjC,MAAM,OAAO,CAAC;EACd,WAAW,MAAM,OAAO,UAAU,MAAM;GACvC;GACA,GAAG,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,CAAC,GAAG,KAAK,KAAK,GAAG;EACjB,OAAO,EAAE,KAAK;CACf,EAAE;AACH;AACA,IAAI,mBAAmB,MAAM;CAC5B,WAAW;CACX,WAAW;CACX;CACA;CACA,YAAY,QAAQ;EACnB,KAAKA,UAAU;EACf,KAAK,UAAU,OAAO,OAAO;GAC5B,IAAI;GACJ,QAAQ;GACR,cAAc;GACd,aAAa,cAAc,iBAAiB,YAAY,SAAS,GAAG,YAAY;EACjF,CAAC;CACF;CACA,MAAM,KAAK,SAAS;EACnB,IAAI,UAAU,GAAG,GAAG,MAAM,gBAAgB,2BAA2B,mGAAmG,EAAE,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC;EAChN,OAAO,eAAe,KAAK,QAAQ,UAAU,KAAKA,OAAO;CAC1D;AACD;;AAEA,SAAS,mBAAmB,QAAQ;CACnC,OAAO,OAAO,OAAO,IAAI,iBAAiB,MAAM,CAAC;AAClD;AAGA,MAAM,gCAAgC;CACrC,GAAG;CACH,cAAc,MAAM,KAAK,6BAA6B,OAAO,CAAC;CAC9D,iBAAiB;CACjB,OAAO,OAAO;EACb,OAAO,mBAAmB,2BAA2B,MAAM,QAAQ,MAAM,UAAU,CAAC;CACrF;AACD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AnyCodecDescriptor, AnyCodecDescriptorTemplate, Codec, CodecDescriptor, CodecDescriptorImpl, CodecDescriptorTemplate, CodecInstanceContext, CodecRef, CodecTrait, DataType } from "@prisma/orm-framework/components/codec";
|
|
2
|
+
import { ProjectionExpr } from "@prisma/orm-family-sql/relational-core/ast";
|
|
3
|
+
import { JsonValue } from "@prisma/orm-framework/contract/types";
|
|
4
|
+
//#region ../../../3-targets/mysql/1-target/dist/codec-descriptor-DXyubAS6.d.mts
|
|
5
|
+
//#region src/core/codec-descriptor.d.ts
|
|
6
|
+
declare const MYSQL_CODEC_DESCRIPTOR_KIND: "mysql-codec";
|
|
7
|
+
interface AnyMysqlCodecDescriptor extends AnyCodecDescriptor {
|
|
8
|
+
readonly descriptorKind: typeof MYSQL_CODEC_DESCRIPTOR_KIND;
|
|
9
|
+
projectJson(expression: ProjectionExpr, ref: CodecRef): ProjectionExpr;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A codec descriptor the MySQL target registers. `jsonProjection` writes a column into the JSON an include reads, in the form the codec's `fromWire` reads from a row.
|
|
13
|
+
*/
|
|
14
|
+
declare abstract class MysqlCodecDescriptor<P = void> extends CodecDescriptorImpl<P> implements AnyMysqlCodecDescriptor {
|
|
15
|
+
readonly descriptorKind: "mysql-codec";
|
|
16
|
+
protected abstract jsonProjection(expression: ProjectionExpr, params: P): ProjectionExpr;
|
|
17
|
+
projectJson(expression: ProjectionExpr, ref: CodecRef): ProjectionExpr;
|
|
18
|
+
}
|
|
19
|
+
type DescriptorParams<D extends AnyCodecDescriptorTemplate> = D extends CodecDescriptorTemplate<infer P> ? P : never;
|
|
20
|
+
type DescriptorCodec<D extends AnyCodecDescriptorTemplate> = ReturnType<ReturnType<D['factory']>>;
|
|
21
|
+
interface MysqlCodecOptions<P, C extends Codec<string, readonly CodecTrait[], unknown, unknown> = Codec<string, readonly CodecTrait[], unknown, unknown>> {
|
|
22
|
+
/** The data type the adapted codec represents here. Its parameter schema is the codec's. */
|
|
23
|
+
readonly dataType: DataType;
|
|
24
|
+
/** Renders the literal of the value the codec reads from a stored value of `dataType`. */
|
|
25
|
+
readonly renderValueLiteral?: (value: JsonValue, side: 'output' | 'input') => string | undefined;
|
|
26
|
+
/** Writes a column of this codec into the JSON an include reads. */
|
|
27
|
+
readonly jsonProjection: (expression: ProjectionExpr, params: P) => ProjectionExpr;
|
|
28
|
+
/** Builds the codec of the family template, constructed with `dataType` and the column's parameters. */
|
|
29
|
+
readonly factory: (descriptor: MysqlCodecDescriptor<P>, dataType: DataType, params: P) => (ctx: CodecInstanceContext) => C;
|
|
30
|
+
}
|
|
31
|
+
type AdaptedMysqlCodecDescriptor<D extends AnyCodecDescriptorTemplate> = Pick<D, keyof CodecDescriptorTemplate<DescriptorParams<D>>> & Pick<CodecDescriptor, 'dataType'> & Pick<AnyMysqlCodecDescriptor, 'descriptorKind' | 'projectJson'>;
|
|
32
|
+
/** Adapts a family codec template to MySQL, naming the MySQL data type it represents. */
|
|
33
|
+
declare function mysqlCodec<D extends AnyCodecDescriptorTemplate>(descriptor: D, options: MysqlCodecOptions<DescriptorParams<D>, DescriptorCodec<D>>): AdaptedMysqlCodecDescriptor<D>;
|
|
34
|
+
declare function isMysqlCodecDescriptor(value: unknown): value is AnyMysqlCodecDescriptor;
|
|
35
|
+
interface MysqlCodecDescriptorRegistry {
|
|
36
|
+
descriptorFor(codecId: string): AnyMysqlCodecDescriptor | undefined;
|
|
37
|
+
values(): IterableIterator<AnyMysqlCodecDescriptor>;
|
|
38
|
+
}
|
|
39
|
+
/** Indexes MySQL codec descriptors by codec id, refusing a descriptor that is not a MySQL one and a codec id given twice. */
|
|
40
|
+
declare function buildMysqlCodecDescriptorRegistry(descriptors: ReadonlyArray<unknown>): MysqlCodecDescriptorRegistry;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { MysqlCodecOptions as a, mysqlCodec as c, MysqlCodecDescriptorRegistry as i, AnyMysqlCodecDescriptor as n, buildMysqlCodecDescriptorRegistry as o, MysqlCodecDescriptor as r, isMysqlCodecDescriptor as s, AdaptedMysqlCodecDescriptor as t };
|
|
43
|
+
//# sourceMappingURL=codec-descriptor-DXyubAS6-siA0R8Ow.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-descriptor-DXyubAS6-siA0R8Ow.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/codec-descriptor-DXyubAS6.d.mts"],"mappings":";;;;;cAIc;UACJ,gCAAgC;WAC/B,uBAAuB;EAChC,YAAY,YAAY,gBAAgB,KAAK,WAAW;;;;;uBAKnC,qBAAqB,kBAAkB,oBAAoB,cAAc;WACrF;qBACU,eAAe,YAAY,gBAAgB,QAAQ,IAAI;EAC1E,YAAY,YAAY,gBAAgB,KAAK,WAAW;;KAErD,iBAAiB,UAAU,8BAA8B,UAAU,8BAA8B,KAAK;KACtG,gBAAgB,UAAU,8BAA8B,WAAW,WAAW;UACzE,kBAAkB,GAAG,UAAU,uBAAuB,kCAAkC,uBAAuB;;WAE9G,UAAU;;WAEV,sBAAsB,OAAO,WAAW;;WAExC,iBAAiB,YAAY,gBAAgB,QAAQ,MAAM;;WAE3D,UAAU,YAAY,qBAAqB,IAAI,UAAU,UAAU,QAAQ,OAAO,KAAK,yBAAyB;;KAEtH,4BAA4B,UAAU,8BAA8B,KAAK,SAAS,wBAAwB,iBAAiB,OAAO,KAAK,+BAA+B,KAAK;;iBAE/J,WAAW,UAAU,4BAA4B,YAAY,GAAG,SAAS,kBAAkB,iBAAiB,IAAI,gBAAgB,MAAM,4BAA4B;iBAClK,uBAAuB,iBAAiB,SAAS;UACxD;EACR,cAAc,kBAAkB;EAChC,UAAU,iBAAiB;;;iBAGZ,kCAAkC,aAAa,yBAAyB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CodecDescriptorImpl, validateCodecTypeParams } from "@prisma/orm-framework/components/codec";
|
|
2
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
3
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
4
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
5
|
+
//#region ../../../3-targets/mysql/1-target/dist/codec-descriptor-Du6DSz-3.mjs
|
|
6
|
+
const MYSQL_CODEC_DESCRIPTOR_KIND = "mysql-codec";
|
|
7
|
+
/**
|
|
8
|
+
* A codec descriptor the MySQL target registers. `jsonProjection` writes a column into the JSON an include reads, in the form the codec's `fromWire` reads from a row.
|
|
9
|
+
*/
|
|
10
|
+
var MysqlCodecDescriptor = class extends CodecDescriptorImpl {
|
|
11
|
+
descriptorKind = MYSQL_CODEC_DESCRIPTOR_KIND;
|
|
12
|
+
projectJson(expression, ref) {
|
|
13
|
+
if (ref.many === true) throw structuredError("RUNTIME.CODEC_DESCRIPTOR_ARRAY_UNSUPPORTED", `Codec '${ref.codecId}' uses CodecRef.many, but MySQL has no stored scalar arrays.`, {
|
|
14
|
+
why: "MySQL codec descriptors project scalar values only.",
|
|
15
|
+
fix: "Use a scalar CodecRef.",
|
|
16
|
+
meta: { codecId: ref.codecId }
|
|
17
|
+
});
|
|
18
|
+
return this.jsonProjection(expression, blindCast(validateCodecTypeParams(this, ref)));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var MysqlCodecDescriptorAdapter = class extends MysqlCodecDescriptor {
|
|
22
|
+
options;
|
|
23
|
+
dataType;
|
|
24
|
+
codecId;
|
|
25
|
+
traits;
|
|
26
|
+
paramsSchema;
|
|
27
|
+
renderValueLiteral;
|
|
28
|
+
constructor(descriptor, options) {
|
|
29
|
+
super();
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.dataType = options.dataType.id;
|
|
32
|
+
this.codecId = descriptor.codecId;
|
|
33
|
+
this.traits = descriptor.traits;
|
|
34
|
+
this.paramsSchema = blindCast(options.dataType.params);
|
|
35
|
+
if (descriptor.renderValueLiteral !== void 0) throw new InternalError(`${descriptor.codecId} is a family codec template with its own renderValueLiteral; pass renderValueLiteral in the options instead.`);
|
|
36
|
+
if (options.renderValueLiteral !== void 0) this.renderValueLiteral = options.renderValueLiteral;
|
|
37
|
+
}
|
|
38
|
+
factory = (params) => this.options.factory(this, this.options.dataType, params);
|
|
39
|
+
jsonProjection(expression, params) {
|
|
40
|
+
return this.options.jsonProjection(expression, params);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** Adapts a family codec template to MySQL, naming the MySQL data type it represents. */
|
|
44
|
+
function mysqlCodec(descriptor, options) {
|
|
45
|
+
return blindCast(new MysqlCodecDescriptorAdapter(descriptor, options));
|
|
46
|
+
}
|
|
47
|
+
function isMysqlCodecDescriptor(value) {
|
|
48
|
+
return typeof value === "object" && value !== null && "descriptorKind" in value && value.descriptorKind === MYSQL_CODEC_DESCRIPTOR_KIND && "codecId" in value && typeof value.codecId === "string" && "factory" in value && typeof value.factory === "function" && "projectJson" in value && typeof value.projectJson === "function";
|
|
49
|
+
}
|
|
50
|
+
var MysqlCodecDescriptorRegistryImpl = class {
|
|
51
|
+
#descriptors;
|
|
52
|
+
constructor(descriptors) {
|
|
53
|
+
this.#descriptors = descriptors;
|
|
54
|
+
Object.freeze(this);
|
|
55
|
+
}
|
|
56
|
+
descriptorFor(codecId) {
|
|
57
|
+
return this.#descriptors.get(codecId);
|
|
58
|
+
}
|
|
59
|
+
*values() {
|
|
60
|
+
yield* this.#descriptors.values();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/** Indexes MySQL codec descriptors by codec id, refusing a descriptor that is not a MySQL one and a codec id given twice. */
|
|
64
|
+
function buildMysqlCodecDescriptorRegistry(descriptors) {
|
|
65
|
+
const byId = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const descriptor of descriptors) {
|
|
67
|
+
if (!isMysqlCodecDescriptor(descriptor)) {
|
|
68
|
+
const codecId = candidateCodecId(descriptor);
|
|
69
|
+
throw structuredError("RUNTIME.CODEC_DESCRIPTOR_INVALID", `Codec descriptor '${codecId}' is not a valid MySQL codec descriptor.`, {
|
|
70
|
+
why: "MySQL codec registries require the mysql-codec discriminant and the MySQL descriptor methods.",
|
|
71
|
+
fix: "Extend MysqlCodecDescriptor or adapt a family descriptor with mysqlCodec().",
|
|
72
|
+
meta: { codecId }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (byId.has(descriptor.codecId)) throw structuredError("RUNTIME.DUPLICATE_CODEC", `Duplicate MySQL codec descriptor id '${descriptor.codecId}'.`, {
|
|
76
|
+
why: "Each codecId must resolve to exactly one MySQL descriptor during registry composition.",
|
|
77
|
+
fix: "Remove the duplicate target, adapter, or extension contribution.",
|
|
78
|
+
meta: {
|
|
79
|
+
codecId: descriptor.codecId,
|
|
80
|
+
target: "mysql"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
byId.set(descriptor.codecId, descriptor);
|
|
84
|
+
}
|
|
85
|
+
return new MysqlCodecDescriptorRegistryImpl(byId);
|
|
86
|
+
}
|
|
87
|
+
function candidateCodecId(value) {
|
|
88
|
+
return typeof value === "object" && value !== null && "codecId" in value && typeof value.codecId === "string" ? value.codecId : "<unknown>";
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { mysqlCodec as i, buildMysqlCodecDescriptorRegistry as n, isMysqlCodecDescriptor as r, MysqlCodecDescriptor as t };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=codec-descriptor-Du6DSz-3-ytBCu_mq.mjs.map
|