@prisma/orm-target-mysql 8.0.0-rc.22-dev.10 → 8.0.0-rc.22-dev.11

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/{adapter-_WBomuTw.d.mts → adapter-Dl4Wwz1I.d.mts} +4 -2
  3. package/dist/adapter-Dl4Wwz1I.d.mts.map +1 -0
  4. package/dist/adapter.d.mts +1 -1
  5. package/dist/adapter.mjs +2 -2
  6. package/dist/adapter__adapter.d.mts +1 -1
  7. package/dist/adapter__adapter.mjs +1 -1
  8. package/dist/adapter__control.mjs +1 -1
  9. package/dist/adapter__runtime.mjs +74 -10
  10. package/dist/adapter__runtime.mjs.map +1 -1
  11. package/dist/{contract-contributions-B9njRJbt-ClEtrK2L.mjs → contract-contributions-ChiX6W0F-CAng98bZ.mjs} +5 -4
  12. package/dist/contract-contributions-ChiX6W0F-CAng98bZ.mjs.map +1 -0
  13. package/dist/{control-6wRZXIJ7.mjs → control-CgeXsxCR.mjs} +2 -2
  14. package/dist/{control-6wRZXIJ7.mjs.map → control-CgeXsxCR.mjs.map} +1 -1
  15. package/dist/{control-WTY7Jpxk.mjs → control-H2sjKXXS.mjs} +2 -2
  16. package/dist/{control-WTY7Jpxk.mjs.map → control-H2sjKXXS.mjs.map} +1 -1
  17. package/dist/{descriptor-meta-BurjcSiU-Cbk2L1jf.mjs → descriptor-meta-D7tc0iue-C4W7o0Av.mjs} +3 -3
  18. package/dist/{descriptor-meta-BurjcSiU-Cbk2L1jf.mjs.map → descriptor-meta-D7tc0iue-C4W7o0Av.mjs.map} +1 -1
  19. package/dist/{descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs → descriptor-meta-runtime-Cur6umHo-C_4rsCGC.mjs} +7 -4
  20. package/dist/descriptor-meta-runtime-Cur6umHo-C_4rsCGC.mjs.map +1 -0
  21. package/dist/driver.mjs +1 -1
  22. package/dist/driver__control.mjs +1 -1
  23. package/dist/driver__runtime.mjs +275 -126
  24. package/dist/driver__runtime.mjs.map +1 -1
  25. package/dist/{marker-read-aEaHihYj-Cyg16yn1.mjs → marker-read-Cf80LSbG-BZaJ8Ll6.mjs} +3 -3
  26. package/dist/{marker-read-aEaHihYj-Cyg16yn1.mjs.map → marker-read-Cf80LSbG-BZaJ8Ll6.mjs.map} +1 -1
  27. package/dist/{pack-YVG-iBMQ.d.mts → pack-DXsOvRJn.d.mts} +2 -1
  28. package/dist/{pack-YVG-iBMQ.d.mts.map → pack-DXsOvRJn.d.mts.map} +1 -1
  29. package/dist/{statement-kfMRMKIt-D6cAOKys.mjs → statement-DC62oiSx-DTx1JaP7.mjs} +17 -11
  30. package/dist/statement-DC62oiSx-DTx1JaP7.mjs.map +1 -0
  31. package/dist/target.d.mts +1 -1
  32. package/dist/target__control.mjs +1 -1
  33. package/dist/target__control.mjs.map +1 -1
  34. package/dist/target__pack.d.mts +1 -1
  35. package/dist/target__pack.mjs +1 -1
  36. package/dist/target__runtime.mjs +1 -1
  37. package/dist/target__runtime.mjs.map +1 -1
  38. package/package.json +9 -9
  39. package/dist/adapter-_WBomuTw.d.mts.map +0 -1
  40. package/dist/contract-contributions-B9njRJbt-ClEtrK2L.mjs.map +0 -1
  41. package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs.map +0 -1
  42. package/dist/statement-kfMRMKIt-D6cAOKys.mjs.map +0 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ The concrete MySQL target of Prisma 8: the target descriptor (DDL planning, code
4
4
 
5
5
  Applications receive it as an exact-pinned dependency of `@prisma/orm-mysql`; app developers install that facade. Extension authors targeting MySQL and decomposed installs import this package directly.
6
6
 
7
- MySQL support is early. This package carries the control plane (emitting contracts, planning and applying migrations, `db verify`, `db sign` and introspection) and the runtime that reads: the SQL renderer and the runtime driver, which runs every statement on the `mariadb` package. The package writes each value into the statement with its own escaping, in one round trip, under the session settings the driver sets and checks: no `NO_BACKSLASH_ESCAPES`, and `utf8mb4`. Writing rows through the ORM or the SQL builder is not supported on MySQL yet.
7
+ MySQL support is early. This package carries the control plane (emitting contracts, planning and applying migrations, `db verify`, `db sign` and introspection) and the runtime: the SQL renderer and the runtime driver, which runs every statement on the `mariadb` package. The package writes each value into the statement with its own escaping, in one round trip, under the session settings the driver sets and checks: no `NO_BACKSLASH_ESCAPES`, and `utf8mb4`. The renderer writes inserts, updates, deletes and upserts (`INSERT … AS new ON DUPLICATE KEY UPDATE`), and refuses `RETURNING`, row locks and `LATERAL` joins.
8
8
 
9
9
  ## Entrypoints
10
10
 
@@ -1,12 +1,13 @@
1
1
  //#region ../../../3-targets/mysql/2-adapter/dist/adapter.d.mts
2
2
  //#region src/core/capabilities.d.ts
3
- /** What a MySQL 8.4 server does that the SQL family asks about. `RETURNING`, `LATERAL` and conflict targets are not among them. */
3
+ /** What a MySQL 8.4 server does that the SQL family asks about. `RETURNING`, `LATERAL` and conflict targets are not among them: `ON DUPLICATE KEY UPDATE` fires on any unique key. */
4
4
  declare const mysqlAdapterCapabilities: Readonly<{
5
5
  readonly sql: {
6
6
  readonly orderBy: true;
7
7
  readonly limit: true;
8
8
  readonly foreignKeys: true;
9
9
  readonly enums: true;
10
+ readonly defaultInInsert: true;
10
11
  };
11
12
  }>;
12
13
  //#endregion
@@ -19,9 +20,10 @@ declare const mysqlAdapterContractContributions: {
19
20
  readonly limit: true;
20
21
  readonly foreignKeys: true;
21
22
  readonly enums: true;
23
+ readonly defaultInInsert: true;
22
24
  };
23
25
  }>;
24
26
  };
25
27
  //#endregion
26
28
  export { mysqlAdapterContractContributions as n, mysqlAdapterCapabilities as t };
27
- //# sourceMappingURL=adapter-_WBomuTw.d.mts.map
29
+ //# sourceMappingURL=adapter-Dl4Wwz1I.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-Dl4Wwz1I.d.mts","names":[],"sources":["../../../../3-targets/mysql/2-adapter/dist/adapter.d.mts"],"mappings":";;;cAEc,0BAA0B;WAC7B;aACE;aACA;aACA;aACA;aACA;;;;;;cAMC;WACH,cAAc;aACZ;eACE;eACA;eACA;eACA;eACA"}
@@ -1,4 +1,4 @@
1
- import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./adapter-_WBomuTw.mjs";
1
+ import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./adapter-Dl4Wwz1I.mjs";
2
2
  import { t as CodecTypes } from "./codec-types-Bd7DL1Mr-CZWNfnp9.mjs";
3
3
  import "./codec-types-Bo3Jfilx.mjs";
4
4
  import { n as MysqlControlAdapter, r as buildMysqlSchemaIR, t as MysqlCatalogRows } from "./control-Ez_PtlFI.mjs";
package/dist/adapter.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./contract-contributions-B9njRJbt-ClEtrK2L.mjs";
2
- import { n as buildMysqlSchemaIR, t as MysqlControlAdapter } from "./control-WTY7Jpxk.mjs";
1
+ import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./contract-contributions-ChiX6W0F-CAng98bZ.mjs";
2
+ import { n as buildMysqlSchemaIR, t as MysqlControlAdapter } from "./control-H2sjKXXS.mjs";
3
3
  export { MysqlControlAdapter, buildMysqlSchemaIR, mysqlAdapterCapabilities, mysqlAdapterContractContributions };
@@ -1,2 +1,2 @@
1
- import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./adapter-_WBomuTw.mjs";
1
+ import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./adapter-Dl4Wwz1I.mjs";
2
2
  export { mysqlAdapterCapabilities, mysqlAdapterContractContributions };
@@ -1,2 +1,2 @@
1
- import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./contract-contributions-B9njRJbt-ClEtrK2L.mjs";
1
+ import { n as mysqlAdapterContractContributions, t as mysqlAdapterCapabilities } from "./contract-contributions-ChiX6W0F-CAng98bZ.mjs";
2
2
  export { mysqlAdapterCapabilities, mysqlAdapterContractContributions };
@@ -1,2 +1,2 @@
1
- import { n as buildMysqlSchemaIR, r as mysqlAdapterDescriptor, t as MysqlControlAdapter } from "./control-WTY7Jpxk.mjs";
1
+ import { n as buildMysqlSchemaIR, r as mysqlAdapterDescriptor, t as MysqlControlAdapter } from "./control-H2sjKXXS.mjs";
2
2
  export { MysqlControlAdapter, buildMysqlSchemaIR, mysqlAdapterDescriptor as default };
@@ -1,10 +1,10 @@
1
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";
2
+ import { t as mysqlError } from "./errors-rvH_F2Yj-BQrO_--u.mjs";
3
3
  import { n as quoteIdentifier, t as escapeLiteral } from "./sql-utils-Db0IQO_B-PaULnfrE.mjs";
4
4
  import { a as mysqlCodecDescriptorRegistry, t as assembleMysqlCodecRegistry } from "./codecs-C00kjHgh.mjs";
5
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";
6
+ import { t as mysqlAdapterCapabilities } from "./contract-contributions-ChiX6W0F-CAng98bZ.mjs";
7
+ import { i as readMarkerResult, n as mysqlAdapterDescriptorMeta } from "./marker-read-Cf80LSbG-BZaJ8Ll6.mjs";
8
8
  import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
9
9
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
10
10
  import { collectOrderedParamRefs, isDdlNode } from "@prisma/orm-family-sql/relational-core/ast";
@@ -41,6 +41,8 @@ function assertPlaceholdersMatchParams(sql, paramCount) {
41
41
  }
42
42
  });
43
43
  }
44
+ /** The name an upsert gives the row it proposes, which its update reads as `new`.`column`; the ORM writes that row as `excluded`, as Postgres names it. */
45
+ const PROPOSED_ROW = "new";
44
46
  /**
45
47
  * 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
48
  */
@@ -94,12 +96,68 @@ function renderStatement(ast, ctx) {
94
96
  switch (ast.kind) {
95
97
  case "select": return renderSelect(ast, ctx);
96
98
  case "raw-query": return renderParts(ast.parts, ctx);
97
- case "insert":
98
- case "update":
99
- case "delete": throw mysqlQueryNotYetSupported("Writing rows");
99
+ case "insert": return renderInsert(ast, ctx);
100
+ case "update": return renderUpdate(ast, ctx);
101
+ case "delete": return renderDelete(ast, ctx);
100
102
  default: throw new InternalError(`Unsupported AST node kind: ${nodeKind(ast)}`);
101
103
  }
102
104
  }
105
+ function invalid(node, message) {
106
+ return mysqlError("RUNTIME.AST_INVALID", message, { meta: { node } });
107
+ }
108
+ /** MySQL has no `RETURNING`: the SQL family's ORM reads written rows back with a select when the contract does not report `returning`. */
109
+ function refuseReturning(returning, what) {
110
+ if (returning !== void 0 && returning.length > 0) throw unsupported("returning", `MySQL cannot return the rows ${what} writes; it has no RETURNING`);
111
+ }
112
+ function renderInsertValue(value, ctx) {
113
+ if (value === void 0 || value.kind === "default-value") return "DEFAULT";
114
+ return renderExpr(value, ctx);
115
+ }
116
+ /**
117
+ * An insert, with the bare table name: MySQL's `INSERT` takes no alias, so a column of the table is qualified by its name. A row without a value for a column gets `DEFAULT`. An upsert names its proposed row `new` and updates the existing row on any duplicate key. MySQL cannot limit `ON DUPLICATE KEY UPDATE` to named conflict columns, so the adapter does not report `insertOnConflictTarget` and an upsert that names them is refused. Skipping a conflicting row is refused: `INSERT IGNORE` also hides foreign-key and `NOT NULL` errors.
118
+ */
119
+ function renderInsert(ast, ctx) {
120
+ refuseReturning(ast.returning, "an insert");
121
+ if (ast.rows.length === 0) throw invalid("insert", "INSERT requires at least one row");
122
+ const table = qualifyTable(ast.table, ctx);
123
+ const insertCtx = {
124
+ ...ctx,
125
+ insertInto: {
126
+ alias: ast.table.alias ?? ast.table.name,
127
+ name: table
128
+ }
129
+ };
130
+ const columns = [...new Set(ast.rows.flatMap((row) => Object.keys(row)))];
131
+ const values = ast.rows.map((row) => `(${columns.map((column) => renderInsertValue(row[column], insertCtx)).join(", ")})`).join(", ");
132
+ const insert = `INSERT INTO ${table} (${columns.map(quoteIdentifier).join(", ")}) VALUES ${values}`;
133
+ const conflict = ast.onConflict;
134
+ if (conflict === void 0) return insert;
135
+ const action = conflict.action;
136
+ switch (action.kind) {
137
+ case "do-nothing": throw unsupported("insert-on-conflict-skip", "MySQL cannot skip a conflicting row without also hiding other errors: INSERT IGNORE turns foreign-key and NOT NULL errors into warnings");
138
+ case "do-update-set": {
139
+ if (conflict.columns.length > 0) throw unsupported("insert-on-conflict-target", "MySQL cannot limit ON DUPLICATE KEY UPDATE to named conflict columns: it fires on any unique key");
140
+ const assignments = Object.entries(action.set);
141
+ if (assignments.length === 0) throw invalid("insert-on-conflict", "An upsert requires at least one column to update");
142
+ const set = assignments.map(([column, value]) => `${quoteIdentifier(column)} = ${renderExpr(value, insertCtx)}`).join(", ");
143
+ return `${insert} AS ${quoteIdentifier(PROPOSED_ROW)} ON DUPLICATE KEY UPDATE ${set}`;
144
+ }
145
+ default: return assertNever(action, `Unsupported conflict action: ${nodeKind(action)}`);
146
+ }
147
+ }
148
+ function renderUpdate(ast, ctx) {
149
+ refuseReturning(ast.returning, "an update");
150
+ const assignments = Object.entries(ast.set);
151
+ if (assignments.length === 0) throw invalid("update", "UPDATE requires at least one column to set");
152
+ const set = assignments.map(([column, value]) => `${quoteIdentifier(column)} = ${renderExpr(value, ctx)}`).join(", ");
153
+ const where = ast.where ? ` WHERE ${renderExpr(ast.where, ctx)}` : "";
154
+ return `UPDATE ${renderTableSource(ast.table, ctx)} SET ${set}${where}`;
155
+ }
156
+ function renderDelete(ast, ctx) {
157
+ refuseReturning(ast.returning, "a delete");
158
+ const where = ast.where ? ` WHERE ${renderExpr(ast.where, ctx)}` : "";
159
+ return `DELETE FROM ${renderTableSource(ast.table, ctx)}${where}`;
160
+ }
103
161
  function renderLimitOffset(keyword, value, ctx) {
104
162
  if (value === void 0) return "";
105
163
  if (typeof value === "number") return `${keyword} ${value}`;
@@ -148,7 +206,7 @@ function renderSource(source, ctx) {
148
206
  }
149
207
  function renderExpr(expr, ctx) {
150
208
  switch (expr.kind) {
151
- case "column-ref": return renderColumn(expr);
209
+ case "column-ref": return renderColumn(expr, ctx);
152
210
  case "identifier-ref": return quoteIdentifier(expr.name);
153
211
  case "operation": return renderOperation(expr, ctx);
154
212
  case "subquery": return renderSubquery(expr, ctx);
@@ -191,8 +249,14 @@ function renderParts(parts, ctx) {
191
249
  assertNoDigitAfterParam(parts);
192
250
  return parts.map((part) => typeof part === "string" ? part : renderExpr(part, ctx)).join("");
193
251
  }
194
- function renderColumn(ref) {
195
- return `${quoteIdentifier(ref.table)}.${quoteIdentifier(ref.column)}`;
252
+ function renderColumn(ref, ctx) {
253
+ const column = quoteIdentifier(ref.column);
254
+ const { insertInto } = ctx;
255
+ if (insertInto !== void 0) {
256
+ if (ref.table === "excluded") return `${quoteIdentifier(PROPOSED_ROW)}.${column}`;
257
+ if (ref.table === insertInto.alias) return `${insertInto.name}.${column}`;
258
+ }
259
+ return `${quoteIdentifier(ref.table)}.${column}`;
196
260
  }
197
261
  /**
198
262
  * 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.
@@ -368,7 +432,7 @@ function renderJoin(join, ctx) {
368
432
  return `${join.joinType.toUpperCase()} JOIN ${renderSource(join.source, ctx)} ON ${renderJoinOn(join.on, ctx)}`;
369
433
  }
370
434
  function renderJoinOn(on, ctx) {
371
- return on.kind === "eq-col-join-on" ? `${renderColumn(on.left)} = ${renderColumn(on.right)}` : renderExpr(on, ctx);
435
+ return on.kind === "eq-col-join-on" ? `${renderColumn(on.left, ctx)} = ${renderColumn(on.right, ctx)}` : renderExpr(on, ctx);
372
436
  }
373
437
  function markerQuery(queryable) {
374
438
  return { async query(sql, params) {
@@ -1 +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 { mysqlRuntimeAdapterDescriptor as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;AAWA,MAAM,UAAU,EAAE,KAAK;AACvB,MAAM,UAAU,KAAK,KAAK;AAC1B,SAAS,OAAO,OAAO;CACtB,MAAM,gBAAgB,6CAA6C,mGAAmG,EAAE,MAAM,EAAE,WAAW,OAAO,MAAM,EAAE,CAAC;AAC5M;;AAEA,MAAM,uBAAuB,EAAE,WAAW,OAAO;CAChD,QAAQ,OAAO,OAAf;EACC,KAAK;GACJ,IAAI,CAAC,OAAO,cAA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O,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"}
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-ChiX6W0F.mjs\";\nimport { o as mysqlAdapterDescriptorMeta, r as readMarkerResult } from \"./marker-read-Cf80LSbG.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 } 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/** The name an upsert gives the row it proposes, which its update reads as `new`.`column`; the ORM writes that row as `excluded`, as Postgres names it. */\nconst PROPOSED_ROW = \"new\";\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\": return renderInsert(ast, ctx);\n\t\tcase \"update\": return renderUpdate(ast, ctx);\n\t\tcase \"delete\": return renderDelete(ast, ctx);\n\t\tdefault: throw new InternalError(`Unsupported AST node kind: ${nodeKind(ast)}`);\n\t}\n}\nfunction invalid(node, message) {\n\treturn mysqlError(\"RUNTIME.AST_INVALID\", message, { meta: { node } });\n}\n/** MySQL has no `RETURNING`: the SQL family's ORM reads written rows back with a select when the contract does not report `returning`. */\nfunction refuseReturning(returning, what) {\n\tif (returning !== void 0 && returning.length > 0) throw unsupported(\"returning\", `MySQL cannot return the rows ${what} writes; it has no RETURNING`);\n}\nfunction renderInsertValue(value, ctx) {\n\tif (value === void 0 || value.kind === \"default-value\") return \"DEFAULT\";\n\treturn renderExpr(value, ctx);\n}\n/**\n* An insert, with the bare table name: MySQL's `INSERT` takes no alias, so a column of the table is qualified by its name. A row without a value for a column gets `DEFAULT`. An upsert names its proposed row `new` and updates the existing row on any duplicate key. MySQL cannot limit `ON DUPLICATE KEY UPDATE` to named conflict columns, so the adapter does not report `insertOnConflictTarget` and an upsert that names them is refused. Skipping a conflicting row is refused: `INSERT IGNORE` also hides foreign-key and `NOT NULL` errors.\n*/\nfunction renderInsert(ast, ctx) {\n\trefuseReturning(ast.returning, \"an insert\");\n\tif (ast.rows.length === 0) throw invalid(\"insert\", \"INSERT requires at least one row\");\n\tconst table = qualifyTable(ast.table, ctx);\n\tconst insertCtx = {\n\t\t...ctx,\n\t\tinsertInto: {\n\t\t\talias: ast.table.alias ?? ast.table.name,\n\t\t\tname: table\n\t\t}\n\t};\n\tconst columns = [...new Set(ast.rows.flatMap((row) => Object.keys(row)))];\n\tconst values = ast.rows.map((row) => `(${columns.map((column) => renderInsertValue(row[column], insertCtx)).join(\", \")})`).join(\", \");\n\tconst insert = `INSERT INTO ${table} (${columns.map(quoteIdentifier).join(\", \")}) VALUES ${values}`;\n\tconst conflict = ast.onConflict;\n\tif (conflict === void 0) return insert;\n\tconst action = conflict.action;\n\tswitch (action.kind) {\n\t\tcase \"do-nothing\": throw unsupported(\"insert-on-conflict-skip\", \"MySQL cannot skip a conflicting row without also hiding other errors: INSERT IGNORE turns foreign-key and NOT NULL errors into warnings\");\n\t\tcase \"do-update-set\": {\n\t\t\tif (conflict.columns.length > 0) throw unsupported(\"insert-on-conflict-target\", \"MySQL cannot limit ON DUPLICATE KEY UPDATE to named conflict columns: it fires on any unique key\");\n\t\t\tconst assignments = Object.entries(action.set);\n\t\t\tif (assignments.length === 0) throw invalid(\"insert-on-conflict\", \"An upsert requires at least one column to update\");\n\t\t\tconst set = assignments.map(([column, value]) => `${quoteIdentifier(column)} = ${renderExpr(value, insertCtx)}`).join(\", \");\n\t\t\treturn `${insert} AS ${quoteIdentifier(PROPOSED_ROW)} ON DUPLICATE KEY UPDATE ${set}`;\n\t\t}\n\t\tdefault: return assertNever(action, `Unsupported conflict action: ${nodeKind(action)}`);\n\t}\n}\nfunction renderUpdate(ast, ctx) {\n\trefuseReturning(ast.returning, \"an update\");\n\tconst assignments = Object.entries(ast.set);\n\tif (assignments.length === 0) throw invalid(\"update\", \"UPDATE requires at least one column to set\");\n\tconst set = assignments.map(([column, value]) => `${quoteIdentifier(column)} = ${renderExpr(value, ctx)}`).join(\", \");\n\tconst where = ast.where ? ` WHERE ${renderExpr(ast.where, ctx)}` : \"\";\n\treturn `UPDATE ${renderTableSource(ast.table, ctx)} SET ${set}${where}`;\n}\nfunction renderDelete(ast, ctx) {\n\trefuseReturning(ast.returning, \"a delete\");\n\tconst where = ast.where ? ` WHERE ${renderExpr(ast.where, ctx)}` : \"\";\n\treturn `DELETE FROM ${renderTableSource(ast.table, ctx)}${where}`;\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, ctx);\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, ctx) {\n\tconst column = quoteIdentifier(ref.column);\n\tconst { insertInto } = ctx;\n\tif (insertInto !== void 0) {\n\t\tif (ref.table === \"excluded\") return `${quoteIdentifier(PROPOSED_ROW)}.${column}`;\n\t\tif (ref.table === insertInto.alias) return `${insertInto.name}.${column}`;\n\t}\n\treturn `${quoteIdentifier(ref.table)}.${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, ctx)} = ${renderColumn(on.right, ctx)}` : 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 { mysqlRuntimeAdapterDescriptor as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;AAWA,MAAM,UAAU,EAAE,KAAK;AACvB,MAAM,UA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AE,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"}
@@ -1,14 +1,15 @@
1
- //#region ../../../3-targets/mysql/2-adapter/dist/contract-contributions-B9njRJbt.mjs
2
- /** What a MySQL 8.4 server does that the SQL family asks about. `RETURNING`, `LATERAL` and conflict targets are not among them. */
1
+ //#region ../../../3-targets/mysql/2-adapter/dist/contract-contributions-ChiX6W0F.mjs
2
+ /** What a MySQL 8.4 server does that the SQL family asks about. `RETURNING`, `LATERAL` and conflict targets are not among them: `ON DUPLICATE KEY UPDATE` fires on any unique key. */
3
3
  const mysqlAdapterCapabilities = Object.freeze({ sql: {
4
4
  orderBy: true,
5
5
  limit: true,
6
6
  foreignKeys: true,
7
- enums: true
7
+ enums: true,
8
+ defaultInInsert: true
8
9
  } });
9
10
  /** What this adapter adds to every contract it runs: its capabilities. `prisma contract emit` reads them through the adapter's descriptor, and the TypeScript `defineContract` passes them to the contract build. */
10
11
  const mysqlAdapterContractContributions = { capabilities: mysqlAdapterCapabilities };
11
12
  //#endregion
12
13
  export { mysqlAdapterContractContributions as n, mysqlAdapterCapabilities as t };
13
14
 
14
- //# sourceMappingURL=contract-contributions-B9njRJbt-ClEtrK2L.mjs.map
15
+ //# sourceMappingURL=contract-contributions-ChiX6W0F-CAng98bZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-contributions-ChiX6W0F-CAng98bZ.mjs","names":[],"sources":["../../../../3-targets/mysql/2-adapter/dist/contract-contributions-ChiX6W0F.mjs"],"sourcesContent":["//#region src/core/capabilities.ts\n/** What a MySQL 8.4 server does that the SQL family asks about. `RETURNING`, `LATERAL` and conflict targets are not among them: `ON DUPLICATE KEY UPDATE` fires on any unique key. */\nconst mysqlAdapterCapabilities = Object.freeze({ sql: {\n\torderBy: true,\n\tlimit: true,\n\tforeignKeys: true,\n\tenums: true,\n\tdefaultInInsert: true\n} });\n//#endregion\n//#region src/core/contract-contributions.ts\n/** What this adapter adds to every contract it runs: its capabilities. `prisma contract emit` reads them through the adapter's descriptor, and the TypeScript `defineContract` passes them to the contract build. */\nconst mysqlAdapterContractContributions = { capabilities: mysqlAdapterCapabilities };\n//#endregion\nexport { mysqlAdapterCapabilities as n, mysqlAdapterContractContributions as t };\n\n//# sourceMappingURL=contract-contributions-ChiX6W0F.mjs.map"],"mappings":";;AAEA,MAAM,2BAA2B,OAAO,OAAO,EAAE,KAAK;CACrD,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;CACP,iBAAiB;AAClB,EAAE,CAAC;;AAIH,MAAM,oCAAoC,EAAE,cAAc,yBAAyB"}
@@ -1,4 +1,4 @@
1
- import { c as isFatal, f as normalizeMysqlError, i as applySessionSettings, l as mysqlConnectionOptions, m as statementFor, o as connectionFix, p as sessionSettingsStatement, r as acquireClientQueryLock, s as connectionLost, u as mysqlDriverDescriptorMeta } from "./statement-kfMRMKIt-D6cAOKys.mjs";
1
+ import { a as connectionFix, c as mysqlConnectionOptions, f as normalizeMysqlError, l as mysqlDriverDescriptorMeta, m as statementFor, n as acquireClientQueryLock, o as connectionLost, p as sessionSettingsStatement, r as applySessionSettings, s as isFatal } from "./statement-DC62oiSx-DTx1JaP7.mjs";
2
2
  import { blindCast } from "@prisma/orm-framework/utils/casts";
3
3
  import { errorRuntime } from "@prisma/orm-framework/errors/execution";
4
4
  import { redactDatabaseUrl } from "@prisma/orm-framework/utils/redact-db-url";
@@ -71,4 +71,4 @@ const mysqlDriverDescriptor = {
71
71
  //#endregion
72
72
  export { mysqlDriverDescriptor as n, MysqlControlDriver as t };
73
73
 
74
- //# sourceMappingURL=control-6wRZXIJ7.mjs.map
74
+ //# sourceMappingURL=control-CgeXsxCR.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-6wRZXIJ7.mjs","names":["#lost"],"sources":["../../../../3-targets/mysql/3-driver/dist/control.mjs"],"sourcesContent":["import { c as isFatal, f as mysqlConnectionOptions, i as sessionSettingsStatement, l as normalizeMysqlError, m as acquireClientQueryLock, o as connectionFix, r as applySessionSettings, s as connectionLost, t as statementFor, u as mysqlDriverDescriptorMeta } from \"./statement-kfMRMKIt.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\nimport { createConnection } from \"mariadb\";\n//#region src/core/migrations/control-driver.ts\n/**\n* A MySQL connection for the control plane. It runs every statement as the runtime driver does, a user's `rawSql` migration step included: in one round trip over the text protocol, the package writing its values into it, one at a time in the order sent, under the runtime driver's per-client lock.\n*/\nvar MysqlControlDriver = class {\n\tconnection;\n\tfamilyId = \"sql\";\n\ttargetId = \"mysql\";\n\t#lost;\n\tconstructor(connection) {\n\t\tthis.connection = connection;\n\t\tconnection.on(\"error\", (error) => {\n\t\t\tthis.#lost = error;\n\t\t});\n\t}\n\t/** Runs `sql` and returns its rows, every column as text and a binary column as bytes. */\n\tasync query(sql, params) {\n\t\tconst releaseLock = await acquireClientQueryLock(this.connection);\n\t\ttry {\n\t\t\tif (this.#lost !== void 0) throw connectionLost(this.#lost);\n\t\t\tconst statement = statementFor(this.connection, sql, params ?? []);\n\t\t\tconst result = await this.connection.query(statement.sql, statement.values);\n\t\t\treturn { rows: Array.isArray(result) ? blindCast([...result]) : [] };\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && isFatal(error)) {\n\t\t\t\tthis.#lost = error;\n\t\t\t\tthrow connectionLost(error);\n\t\t\t}\n\t\t\tthrow normalizeMysqlError(error);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t}\n\tasync databaseName() {\n\t\tconst { rows } = await this.query(\"SELECT DATABASE() AS name\");\n\t\tconst name = rows[0]?.name;\n\t\treturn typeof name === \"string\" && name.length > 0 ? name : void 0;\n\t}\n\tasync close() {\n\t\tawait this.connection.end().catch(() => {});\n\t}\n};\nconst mysqlDriverDescriptor = {\n\t...mysqlDriverDescriptorMeta,\n\tasync create(url, options) {\n\t\tconst connectionOptions = mysqlConnectionOptions(url, { connectTimeoutMs: options?.connectTimeoutMs });\n\t\tconst settings = sessionSettingsStatement(options?.sessionSettings ?? {});\n\t\ttry {\n\t\t\tconst connection = await createConnection(connectionOptions);\n\t\t\tif (settings !== void 0) await applySessionSettings(connection, settings).catch(async (error) => {\n\t\t\t\tawait connection.end().catch(() => {});\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t\treturn new MysqlControlDriver(connection);\n\t\t} catch (error) {\n\t\t\tconst normalized = normalizeMysqlError(error);\n\t\t\tthrow errorRuntime(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\t\t\twhy: normalized instanceof Error ? normalized.message : String(normalized),\n\t\t\t\tfix: connectionFix(error) ?? \"Verify the database URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\t\t\tmeta: { ...redactDatabaseUrl(url) },\n\t\t\t\tcause: error\n\t\t\t});\n\t\t}\n\t}\n};\n//#endregion\nexport { MysqlControlDriver, mysqlDriverDescriptor as default };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;AASA,IAAI,qBAAqB,MAAM;CAC9B;CACA,WAAW;CACX,WAAW;CACX;CACA,YAAY,YAAY;EACvB,KAAK,aAAa;EAClB,WAAW,GAAG,UAAU,UAAU;GACjC,KAAKA,QAAQ;EACd,CAAC;CACF;;CAEA,MAAM,MAAM,KAAK,QAAQ;EACxB,MAAM,cAAc,MAAM,uBAAuB,KAAK,UAAU;EAChE,IAAI;GACH,IAAI,KAAKA,UAAU,KAAK,GAAG,MAAM,eAAe,KAAKA,KAAK;GAC1D,MAAM,YAAY,aAAa,KAAK,YAAY,KAAK,UAAU,CAAC,CAAC;GACjE,MAAM,SAAS,MAAM,KAAK,WAAW,MAAM,UAAU,KAAK,UAAU,MAAM;GAC1E,OAAO,EAAE,MAAM,MAAM,QAAQ,MAAM,IAAI,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;EACpE,SAAS,OAAO;GACf,IAAI,iBAAiB,SAAS,QAAQ,KAAK,GAAG;IAC7C,KAAKA,QAAQ;IACb,MAAM,eAAe,KAAK;GAC3B;GACA,MAAM,oBAAoB,KAAK;EAChC,UAAU;GACT,YAAY;EACb;CACD;CACA,MAAM,eAAe;EACpB,MAAM,EAAE,SAAS,MAAM,KAAK,MAAM,2BAA2B;EAC7D,MAAM,OAAO,KAAK,EAAE,EAAE;EACtB,OAAO,OAAO,SAAS,YAAY,KAAK,SAAS,IAAI,OAAO,KAAK;CAClE;CACA,MAAM,QAAQ;EACb,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;CAC3C;AACD;AACA,MAAM,wBAAwB;CAC7B,GAAG;CACH,MAAM,OAAO,KAAK,SAAS;EAC1B,MAAM,oBAAoB,uBAAuB,KAAK,EAAE,kBAAkB,SAAS,iBAAiB,CAAC;EACrG,MAAM,WAAW,yBAAyB,SAAS,mBAAmB,CAAC,CAAC;EACxE,IAAI;GACH,MAAM,aAAa,MAAM,iBAAiB,iBAAiB;GAC3D,IAAI,aAAa,KAAK,GAAG,MAAM,qBAAqB,YAAY,QAAQ,CAAC,CAAC,MAAM,OAAO,UAAU;IAChG,MAAM,WAAW,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IACrC,MAAM;GACP,CAAC;GACD,OAAO,IAAI,mBAAmB,UAAU;EACzC,SAAS,OAAO;GACf,MAAM,aAAa,oBAAoB,KAAK;GAC5C,MAAM,aAAa,4BAA4B,8BAA8B;IAC5E,KAAK,sBAAsB,QAAQ,WAAW,UAAU,OAAO,UAAU;IACzE,KAAK,cAAc,KAAK,KAAK;IAC7B,MAAM,EAAE,GAAG,kBAAkB,GAAG,EAAE;IAClC,OAAO;GACR,CAAC;EACF;CACD;AACD"}
1
+ {"version":3,"file":"control-CgeXsxCR.mjs","names":["#lost"],"sources":["../../../../3-targets/mysql/3-driver/dist/control.mjs"],"sourcesContent":["import { c as isFatal, d as mysqlConnectionOptions, i as sessionSettingsStatement, l as normalizeMysqlError, m as acquireClientQueryLock, o as connectionFix, r as applySessionSettings, s as connectionLost, t as statementFor, u as mysqlDriverDescriptorMeta } from \"./statement-DC62oiSx.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\nimport { createConnection } from \"mariadb\";\n//#region src/core/migrations/control-driver.ts\n/**\n* A MySQL connection for the control plane. It runs every statement as the runtime driver does, a user's `rawSql` migration step included: in one round trip over the text protocol, the package writing its values into it, one at a time in the order sent, under the runtime driver's per-client lock.\n*/\nvar MysqlControlDriver = class {\n\tconnection;\n\tfamilyId = \"sql\";\n\ttargetId = \"mysql\";\n\t#lost;\n\tconstructor(connection) {\n\t\tthis.connection = connection;\n\t\tconnection.on(\"error\", (error) => {\n\t\t\tthis.#lost = error;\n\t\t});\n\t}\n\t/** Runs `sql` and returns its rows, every column as text and a binary column as bytes. */\n\tasync query(sql, params) {\n\t\tconst releaseLock = await acquireClientQueryLock(this.connection);\n\t\ttry {\n\t\t\tif (this.#lost !== void 0) throw connectionLost(this.#lost);\n\t\t\tconst statement = statementFor(this.connection, sql, params ?? []);\n\t\t\tconst result = await this.connection.query(statement.sql, statement.values);\n\t\t\treturn { rows: Array.isArray(result) ? blindCast([...result]) : [] };\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && isFatal(error)) {\n\t\t\t\tthis.#lost = error;\n\t\t\t\tthrow connectionLost(error);\n\t\t\t}\n\t\t\tthrow normalizeMysqlError(error);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t}\n\tasync databaseName() {\n\t\tconst { rows } = await this.query(\"SELECT DATABASE() AS name\");\n\t\tconst name = rows[0]?.name;\n\t\treturn typeof name === \"string\" && name.length > 0 ? name : void 0;\n\t}\n\tasync close() {\n\t\tawait this.connection.end().catch(() => {});\n\t}\n};\nconst mysqlDriverDescriptor = {\n\t...mysqlDriverDescriptorMeta,\n\tasync create(url, options) {\n\t\tconst connectionOptions = mysqlConnectionOptions(url, { connectTimeoutMs: options?.connectTimeoutMs });\n\t\tconst settings = sessionSettingsStatement(options?.sessionSettings ?? {});\n\t\ttry {\n\t\t\tconst connection = await createConnection(connectionOptions);\n\t\t\tif (settings !== void 0) await applySessionSettings(connection, settings).catch(async (error) => {\n\t\t\t\tawait connection.end().catch(() => {});\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t\treturn new MysqlControlDriver(connection);\n\t\t} catch (error) {\n\t\t\tconst normalized = normalizeMysqlError(error);\n\t\t\tthrow errorRuntime(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\t\t\twhy: normalized instanceof Error ? normalized.message : String(normalized),\n\t\t\t\tfix: connectionFix(error) ?? \"Verify the database URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\t\t\tmeta: { ...redactDatabaseUrl(url) },\n\t\t\t\tcause: error\n\t\t\t});\n\t\t}\n\t}\n};\n//#endregion\nexport { MysqlControlDriver, mysqlDriverDescriptor as default };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;AASA,IAAI,qBAAqB,MAAM;CAC9B;CACA,WAAW;CACX,WAAW;CACX;CACA,YAAY,YAAY;EACvB,KAAK,aAAa;EAClB,WAAW,GAAG,UAAU,UAAU;GACjC,KAAKA,QAAQ;EACd,CAAC;CACF;;CAEA,MAAM,MAAM,KAAK,QAAQ;EACxB,MAAM,cAAc,MAAM,uBAAuB,KAAK,UAAU;EAChE,IAAI;GACH,IAAI,KAAKA,UAAU,KAAK,GAAG,MAAM,eAAe,KAAKA,KAAK;GAC1D,MAAM,YAAY,aAAa,KAAK,YAAY,KAAK,UAAU,CAAC,CAAC;GACjE,MAAM,SAAS,MAAM,KAAK,WAAW,MAAM,UAAU,KAAK,UAAU,MAAM;GAC1E,OAAO,EAAE,MAAM,MAAM,QAAQ,MAAM,IAAI,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;EACpE,SAAS,OAAO;GACf,IAAI,iBAAiB,SAAS,QAAQ,KAAK,GAAG;IAC7C,KAAKA,QAAQ;IACb,MAAM,eAAe,KAAK;GAC3B;GACA,MAAM,oBAAoB,KAAK;EAChC,UAAU;GACT,YAAY;EACb;CACD;CACA,MAAM,eAAe;EACpB,MAAM,EAAE,SAAS,MAAM,KAAK,MAAM,2BAA2B;EAC7D,MAAM,OAAO,KAAK,EAAE,EAAE;EACtB,OAAO,OAAO,SAAS,YAAY,KAAK,SAAS,IAAI,OAAO,KAAK;CAClE;CACA,MAAM,QAAQ;EACb,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;CAC3C;AACD;AACA,MAAM,wBAAwB;CAC7B,GAAG;CACH,MAAM,OAAO,KAAK,SAAS;EAC1B,MAAM,oBAAoB,uBAAuB,KAAK,EAAE,kBAAkB,SAAS,iBAAiB,CAAC;EACrG,MAAM,WAAW,yBAAyB,SAAS,mBAAmB,CAAC,CAAC;EACxE,IAAI;GACH,MAAM,aAAa,MAAM,iBAAiB,iBAAiB;GAC3D,IAAI,aAAa,KAAK,GAAG,MAAM,qBAAqB,YAAY,QAAQ,CAAC,CAAC,MAAM,OAAO,UAAU;IAChG,MAAM,WAAW,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IACrC,MAAM;GACP,CAAC;GACD,OAAO,IAAI,mBAAmB,UAAU;EACzC,SAAS,OAAO;GACf,MAAM,aAAa,oBAAoB,KAAK;GAC5C,MAAM,aAAa,4BAA4B,8BAA8B;IAC5E,KAAK,sBAAsB,QAAQ,WAAW,UAAU,OAAO,UAAU;IACzE,KAAK,cAAc,KAAK,KAAK;IAC7B,MAAM,EAAE,GAAG,kBAAkB,GAAG,EAAE;IAClC,OAAO;GACR,CAAC;EACF;CACD;AACD"}
@@ -5,7 +5,7 @@ import { n as LEDGER_TABLE_NAME, r as MARKER_TABLE_NAME, t as CONTROL_TABLE_NAME
5
5
  import { n as buildSignMarkerBootstrapQueries, t as buildControlTableBootstrapQueries } from "./contract-free-BvCdx_Ee.mjs";
6
6
  import { n as readMysqlDefault } from "./default-normalizer-BDUgHXUn-Xk7HQJuI.mjs";
7
7
  import { i as withMarkerLock } from "./marker-lock-CmGvN4hw-Com29AtQ.mjs";
8
- import { a as readMarkerRows, i as readMarkerResult, n as mysqlAdapterDescriptorMeta, o as tableExists, r as parseJsonColumn, t as decodeMysqlMarkerRow } from "./marker-read-aEaHihYj-Cyg16yn1.mjs";
8
+ import { a as readMarkerRows, i as readMarkerResult, n as mysqlAdapterDescriptorMeta, o as tableExists, r as parseJsonColumn, t as decodeMysqlMarkerRow } from "./marker-read-Cf80LSbG-BZaJ8Ll6.mjs";
9
9
  import { codecForRef } from "@prisma/orm-framework/components/codec";
10
10
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
11
11
  import { encodeLiteralDefault, isDdlNode, renderOpaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
@@ -574,4 +574,4 @@ const mysqlAdapterDescriptor = {
574
574
  //#endregion
575
575
  export { buildMysqlSchemaIR as n, mysqlAdapterDescriptor as r, MysqlControlAdapter as t };
576
576
 
577
- //# sourceMappingURL=control-WTY7Jpxk.mjs.map
577
+ //# sourceMappingURL=control-H2sjKXXS.mjs.map