@prisma/orm-target-mysql 8.0.0-rc.24-dev.27 → 8.0.0-rc.24-dev.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-D4QpAe2i.d.mts +374 -0
- package/dist/adapter-D4QpAe2i.d.mts.map +1 -0
- package/dist/adapter.d.mts +8 -6
- package/dist/adapter.mjs +5 -3
- package/dist/adapter__adapter.d.mts +1 -1
- package/dist/adapter__adapter.mjs +1 -1
- package/dist/adapter__codec-types.d.mts +2 -2
- package/dist/adapter__control.d.mts +1 -1
- package/dist/adapter__control.mjs +1 -1
- package/dist/adapter__runtime.d.mts +2 -2
- package/dist/adapter__runtime.mjs +2 -501
- package/dist/adapter__sql-renderer.d.mts +3 -0
- package/dist/adapter__sql-renderer.mjs +2 -0
- package/dist/aggregates-BK8qyA2x.d.mts +164 -0
- package/dist/aggregates-BK8qyA2x.d.mts.map +1 -0
- package/dist/aggregates-Bk6CCgQ-.mjs +145 -0
- package/dist/aggregates-Bk6CCgQ-.mjs.map +1 -0
- package/dist/codec-descriptor-B1fMmxOK-D59zKJws.d.mts +1 -0
- package/dist/{codec-descriptor-3xp1XvVH-DfPKpYeP.mjs → codec-descriptor-ByN7iIha-48yW7oDN.mjs} +23 -16
- package/dist/codec-descriptor-ByN7iIha-48yW7oDN.mjs.map +1 -0
- package/dist/codec-descriptor-CqM_hQjY.d.mts +2 -0
- package/dist/{codec-descriptor-DXyubAS6-XDBj6Yet.d.mts → codec-descriptor-DXsJwUng-D4abEAFs.d.mts} +10 -5
- package/dist/codec-descriptor-DXsJwUng-D4abEAFs.d.mts.map +1 -0
- package/dist/codec-ids-DHeJ2SMJ-Uz1FAFmQ.d.mts +26 -0
- package/dist/codec-ids-DHeJ2SMJ-Uz1FAFmQ.d.mts.map +1 -0
- package/dist/codec-ids-DuWt4aOn-DiyLf9dW.mjs +26 -0
- package/dist/codec-ids-DuWt4aOn-DiyLf9dW.mjs.map +1 -0
- package/dist/codec-types-BQBBUlf_.d.mts +1 -0
- package/dist/{codec-types-Bai_CFkk-DmZ74URd.d.mts → codec-types-C4Q_JJgX-CUPkvPDx.d.mts} +11 -5
- package/dist/codec-types-C4Q_JJgX-CUPkvPDx.d.mts.map +1 -0
- package/dist/codec-types-DxSSgcpB.d.mts +1 -0
- package/dist/{codecs-BMidk26M-B_iWNti6.d.mts → codecs-D35fqdXJ-BZwilYUu.d.mts} +115 -7
- package/dist/codecs-D35fqdXJ-BZwilYUu.d.mts.map +1 -0
- package/dist/{codecs-CIJRyUd3.d.mts → codecs-DTfUoamS.d.mts} +3 -3
- package/dist/{codecs-CIJRyUd3.d.mts.map → codecs-DTfUoamS.d.mts.map} +1 -1
- package/dist/{codecs-wVJlFapM.mjs → codecs-DVX-3El1.mjs} +429 -12
- package/dist/codecs-DVX-3El1.mjs.map +1 -0
- package/dist/{control-Dj8nIA1M.d.mts → control-B7v7zc3l.d.mts} +272 -13
- package/dist/control-B7v7zc3l.d.mts.map +1 -0
- package/dist/{control-D7_IpeiU.d.mts → control-BFe8NrSk.d.mts} +22 -5
- package/dist/control-BFe8NrSk.d.mts.map +1 -0
- package/dist/{control-BiZaCqna.mjs → control-BTolgwH5.mjs} +28 -13
- package/dist/control-BTolgwH5.mjs.map +1 -0
- package/dist/{control-CTfV1Zag.mjs → control-CZSBblPm.mjs} +26 -19
- package/dist/control-CZSBblPm.mjs.map +1 -0
- package/dist/{control-WNuLF2Wh.d.mts → control-DqJJGh-5.d.mts} +3 -3
- package/dist/control-DqJJGh-5.d.mts.map +1 -0
- package/dist/{control-RYDTbndD.mjs → control-DtXS4WsY.mjs} +9 -14
- package/dist/control-DtXS4WsY.mjs.map +1 -0
- package/dist/data-type-entries-DlbQ1Bvl-BFkHeHVz.mjs +108 -0
- package/dist/data-type-entries-DlbQ1Bvl-BFkHeHVz.mjs.map +1 -0
- package/dist/{data-types-65iVc7q1.d.mts → data-types-COQT9bVG.d.mts} +2 -2
- package/dist/data-types-COQT9bVG.d.mts.map +1 -0
- package/dist/data-types-CU_43cNv-CQ8eHx3H.mjs +461 -0
- package/dist/data-types-CU_43cNv-CQ8eHx3H.mjs.map +1 -0
- package/dist/{data-types-D2HAT-Qf-CSdDz1Pk.d.mts → data-types-C_vInIbm-Gt1XINav.d.mts} +58 -4
- package/dist/data-types-C_vInIbm-Gt1XINav.d.mts.map +1 -0
- package/dist/{date-time-now-generators-BKakW3gd-CIFPuRdM.mjs → date-time-now-generators-Cx_aQTSw-ay1tlvw6.mjs} +4 -15
- package/dist/date-time-now-generators-Cx_aQTSw-ay1tlvw6.mjs.map +1 -0
- package/dist/default-normalizer-C9c043DP-DPhwJOC4.mjs +175 -0
- package/dist/default-normalizer-C9c043DP-DPhwJOC4.mjs.map +1 -0
- package/dist/default-normalizer-zXWtDBp_.d.mts +31 -0
- package/dist/default-normalizer-zXWtDBp_.d.mts.map +1 -0
- package/dist/{descriptor-meta-e29H69KN-t-S8_DYh.mjs → descriptor-meta-BFQUMwkh-Bc3o-ZMV.mjs} +19 -12
- package/dist/descriptor-meta-BFQUMwkh-Bc3o-ZMV.mjs.map +1 -0
- package/dist/{descriptor-meta-BF6YvSag-ChHHvlHc.mjs → descriptor-meta-BHSEcFWR-41BcRcOy.mjs} +219 -25
- package/dist/descriptor-meta-BHSEcFWR-41BcRcOy.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-BaIF7fOE-BX9t3rkk.mjs +17 -0
- package/dist/descriptor-meta-runtime-BaIF7fOE-BX9t3rkk.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-DEKunXiL.d.mts +22 -0
- package/dist/descriptor-meta-runtime-DEKunXiL.d.mts.map +1 -0
- package/dist/driver.d.mts +3 -3
- package/dist/driver.mjs +2 -2
- package/dist/driver__control.d.mts +2 -2
- package/dist/driver__control.mjs +1 -1
- package/dist/driver__runtime.d.mts +2 -2
- package/dist/driver__runtime.mjs +1 -1
- package/dist/{errors-DjCkC9IM.d.mts → errors-B81Qeu5_.d.mts} +3 -2
- package/dist/errors-B81Qeu5_.d.mts.map +1 -0
- package/dist/{errors-Cng94tYg-DTH51xWG.mjs → errors-CWtFTnst-xBLJ-9Lp.mjs} +43 -17
- package/dist/errors-CWtFTnst-xBLJ-9Lp.mjs.map +1 -0
- package/dist/{marker-lock-Bwew7cAs-ElLxlCQp.mjs → marker-lock-B7CyXf2F-CakjZnQP.mjs} +3 -3
- package/dist/{marker-lock-Bwew7cAs-ElLxlCQp.mjs.map → marker-lock-B7CyXf2F-CakjZnQP.mjs.map} +1 -1
- package/dist/{marker-read-D1hp62hF-3-4fEgDD.mjs → marker-read-D1hp62hF-BSXs2TVo.mjs} +3 -3
- package/dist/{marker-read-D1hp62hF-3-4fEgDD.mjs.map → marker-read-D1hp62hF-BSXs2TVo.mjs.map} +1 -1
- package/dist/{migration-DILkj7kB.d.mts → migration-O-3NHVlW.d.mts} +2 -5
- package/dist/migration-O-3NHVlW.d.mts.map +1 -0
- package/dist/{mysql-contract-serializer-BnTKRSsN-BnV7fdYd.mjs → mysql-contract-serializer-D7NjmI2L-gTs-kAW1.mjs} +4 -4
- package/dist/{mysql-contract-serializer-BnTKRSsN-BnV7fdYd.mjs.map → mysql-contract-serializer-D7NjmI2L-gTs-kAW1.mjs.map} +1 -1
- package/dist/{mysql-database-CHl9-oSL-B1arvq6Q.mjs → mysql-database-ByniOtau-BKBIGgSm.mjs} +45 -17
- package/dist/mysql-database-ByniOtau-BKBIGgSm.mjs.map +1 -0
- package/dist/{now-expression-DVD18CUc-DJqdZY96.mjs → now-expression-DDHpZL6o-Ixs-vg-B.mjs} +3 -3
- package/dist/{now-expression-DVD18CUc-DJqdZY96.mjs.map → now-expression-DDHpZL6o-Ixs-vg-B.mjs.map} +1 -1
- package/dist/{pack-CqULIal0.d.mts → pack-C5_g-3YX.d.mts} +272 -11
- package/dist/{pack-CqULIal0.d.mts.map → pack-C5_g-3YX.d.mts.map} +1 -1
- package/dist/{require-temporal-DeDQhbTn-CdpjEWCB.mjs → require-temporal-DDdrgVtL-VOKxTqhD.mjs} +3 -3
- package/dist/{require-temporal-DeDQhbTn-CdpjEWCB.mjs.map → require-temporal-DDdrgVtL-VOKxTqhD.mjs.map} +1 -1
- package/dist/{runner-DEKKxDyw-Cdo1Ysod.mjs → runner-IjNtlp_v-DLCqpSh5.mjs} +68 -72
- package/dist/runner-IjNtlp_v-DLCqpSh5.mjs.map +1 -0
- package/dist/runtime-Bw6vKz9t.mjs +96 -0
- package/dist/runtime-Bw6vKz9t.mjs.map +1 -0
- package/dist/{runtime-DB0w8R7i.mjs → runtime-CHWztV6c.mjs} +66 -46
- package/dist/runtime-CHWztV6c.mjs.map +1 -0
- package/dist/{runtime-DN20lWEg.d.mts → runtime-CQ1V-8Yh.d.mts} +11 -4
- package/dist/runtime-CQ1V-8Yh.d.mts.map +1 -0
- package/dist/{runtime-CbqytTbM.d.mts → runtime-Ci3hPz1j.d.mts} +16 -5
- package/dist/runtime-Ci3hPz1j.d.mts.map +1 -0
- package/dist/{runtime-DUDdsFyy.mjs → runtime-_c_DZuYR.mjs} +18 -13
- package/dist/runtime-_c_DZuYR.mjs.map +1 -0
- package/dist/runtime-dn4-kzZV.d.mts +43 -0
- package/dist/runtime-dn4-kzZV.d.mts.map +1 -0
- package/dist/sql-renderer-CrnJ8cCo.d.mts +1 -0
- package/dist/sql-renderer-DfPaqPkD-DFaweHvr.mjs +501 -0
- package/dist/sql-renderer-DfPaqPkD-DFaweHvr.mjs.map +1 -0
- package/dist/sql-renderer-fnDhRUHs-CcsyIaZ4.d.mts +95 -0
- package/dist/sql-renderer-fnDhRUHs-CcsyIaZ4.d.mts.map +1 -0
- package/dist/{sql-utils-Cmv_TVa8-CNW3UmfQ.mjs → sql-utils-CveZhawQ-B2QmUlY0.mjs} +3 -3
- package/dist/{sql-utils-Cmv_TVa8-CNW3UmfQ.mjs.map → sql-utils-CveZhawQ-B2QmUlY0.mjs.map} +1 -1
- package/dist/{sql-utils-BE8tDXHs.mjs → sql-utils-DVH8boEI.mjs} +3 -6
- package/dist/sql-utils-DVH8boEI.mjs.map +1 -0
- package/dist/{statement-CT5tB4uX-CHqHFM3z.mjs → statement-a2Eekpu6-BDJa255m.mjs} +73 -67
- package/dist/statement-a2Eekpu6-BDJa255m.mjs.map +1 -0
- package/dist/target.d.mts +18 -16
- package/dist/target.mjs +21 -19
- package/dist/target__aggregates.d.mts +2 -0
- package/dist/target__aggregates.mjs +2 -0
- package/dist/target__codec-descriptor.d.mts +2 -2
- package/dist/target__codec-descriptor.mjs +1 -1
- package/dist/target__codec-ids.d.mts +2 -2
- package/dist/target__codec-ids.mjs +2 -2
- package/dist/target__codec-types.d.mts +2 -2
- package/dist/target__codecs.d.mts +2 -2
- package/dist/target__codecs.mjs +2 -2
- package/dist/target__control.d.mts +1 -1
- package/dist/target__control.mjs +2 -2
- package/dist/target__data-types.d.mts +3 -3
- package/dist/target__data-types.mjs +3 -3
- package/dist/target__default-normalizer.d.mts +2 -2
- package/dist/target__default-normalizer.mjs +2 -2
- package/dist/target__descriptor-meta-runtime.d.mts +2 -0
- package/dist/target__descriptor-meta-runtime.mjs +2 -0
- package/dist/target__errors.d.mts +1 -1
- package/dist/target__errors.mjs +1 -1
- package/dist/target__marker-lock.mjs +1 -1
- package/dist/target__migration.d.mts +1 -1
- package/dist/target__migration.mjs +1 -1
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__runtime.d.mts +2 -2
- package/dist/target__runtime.mjs +4 -4
- package/dist/target__sql-utils.mjs +2 -2
- package/dist/target__types.mjs +1 -1
- package/package.json +13 -10
- package/dist/adapter-1Kd67Gfa.d.mts +0 -66
- package/dist/adapter-1Kd67Gfa.d.mts.map +0 -1
- package/dist/adapter__runtime.mjs.map +0 -1
- package/dist/codec-descriptor-3xp1XvVH-DfPKpYeP.mjs.map +0 -1
- package/dist/codec-descriptor-BRcKIX3h.d.mts +0 -2
- package/dist/codec-descriptor-DXyubAS6-XDBj6Yet.d.mts.map +0 -1
- package/dist/codec-descriptor-J3TP08l8-BmdgkIU6.d.mts +0 -1
- package/dist/codec-ids-CrR9Xi7r-CjbGCS3o.mjs +0 -20
- package/dist/codec-ids-CrR9Xi7r-CjbGCS3o.mjs.map +0 -1
- package/dist/codec-ids-Dgh5IpML-DGXIq6j8.d.mts +0 -20
- package/dist/codec-ids-Dgh5IpML-DGXIq6j8.d.mts.map +0 -1
- package/dist/codec-types-BS-lWfda.d.mts +0 -1
- package/dist/codec-types-Bai_CFkk-DmZ74URd.d.mts.map +0 -1
- package/dist/codec-types-Dk2h5dBB.d.mts +0 -1
- package/dist/codecs-BMidk26M-B_iWNti6.d.mts.map +0 -1
- package/dist/codecs-wVJlFapM.mjs.map +0 -1
- package/dist/control-BiZaCqna.mjs.map +0 -1
- package/dist/control-CTfV1Zag.mjs.map +0 -1
- package/dist/control-D7_IpeiU.d.mts.map +0 -1
- package/dist/control-Dj8nIA1M.d.mts.map +0 -1
- package/dist/control-RYDTbndD.mjs.map +0 -1
- package/dist/control-WNuLF2Wh.d.mts.map +0 -1
- package/dist/data-type-entries-C7VH2IHc-DM6TbTaz.mjs +0 -59
- package/dist/data-type-entries-C7VH2IHc-DM6TbTaz.mjs.map +0 -1
- package/dist/data-types-65iVc7q1.d.mts.map +0 -1
- package/dist/data-types-D2HAT-Qf-CSdDz1Pk.d.mts.map +0 -1
- package/dist/data-types-DOaaPS93-lycGybNk.mjs +0 -289
- package/dist/data-types-DOaaPS93-lycGybNk.mjs.map +0 -1
- package/dist/date-time-now-generators-BKakW3gd-CIFPuRdM.mjs.map +0 -1
- package/dist/default-normalizer-C8pc7SbL-BXd70q02.mjs +0 -100
- package/dist/default-normalizer-C8pc7SbL-BXd70q02.mjs.map +0 -1
- package/dist/default-normalizer-D-8Ii0df.d.mts +0 -27
- package/dist/default-normalizer-D-8Ii0df.d.mts.map +0 -1
- package/dist/descriptor-meta-BF6YvSag-ChHHvlHc.mjs.map +0 -1
- package/dist/descriptor-meta-e29H69KN-t-S8_DYh.mjs.map +0 -1
- package/dist/errors-Cng94tYg-DTH51xWG.mjs.map +0 -1
- package/dist/errors-DjCkC9IM.d.mts.map +0 -1
- package/dist/migration-DILkj7kB.d.mts.map +0 -1
- package/dist/mysql-database-CHl9-oSL-B1arvq6Q.mjs.map +0 -1
- package/dist/runner-DEKKxDyw-Cdo1Ysod.mjs.map +0 -1
- package/dist/runtime-CbqytTbM.d.mts.map +0 -1
- package/dist/runtime-Cm-T3hbP.d.mts +0 -29
- package/dist/runtime-Cm-T3hbP.d.mts.map +0 -1
- package/dist/runtime-DB0w8R7i.mjs.map +0 -1
- package/dist/runtime-DN20lWEg.d.mts.map +0 -1
- package/dist/runtime-DUDdsFyy.mjs.map +0 -1
- package/dist/sql-utils-BE8tDXHs.mjs.map +0 -1
- package/dist/statement-CT5tB4uX-CHqHFM3z.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-renderer-DfPaqPkD-DFaweHvr.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/2-adapter/dist/sql-renderer-DfPaqPkD.mjs"],"sourcesContent":["import { collectOrderedParamRefs } 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 { InternalError, assertNever } from \"@internal/utils/internal-error\";\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 SQL has placeholders ${JSON.stringify(placeholders)} for ${paramCount} value(s); each value needs its own numbered placeholder, and the SQL may contain no other placeholder.`, {\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\nconst ARTICLED_STATEMENT = {\n\tinsert: \"an insert\",\n\tupdate: \"an update\",\n\tdelete: \"a delete\"\n};\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 = quoteIdentifier(\"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\";\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};\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 nodeKind(value) {\n\treturn typeof value === \"object\" && value !== null && \"kind\" in value ? String(value.kind) : \"unknown\";\n}\nfunction invalid(node, message) {\n\treturn mysqlError(\"RUNTIME.AST_INVALID\", message, { meta: { node } });\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}\n/** Refuses the expression a codec wrapped a parameter in unless it holds that parameter exactly once: a parameter dropped or repeated would leave the statement's placeholders out of step with its values. */\nfunction assertWrapsParameterOnce(wrapped, parameter, codec) {\n\tconst parameters = wrapped.collectParamRefs();\n\tif (parameters.length === 1 && parameters[0] === parameter) return;\n\tthrow structuredError(\"RUNTIME.CODEC_DESCRIPTOR_INVALID\", `Codec \"${codec.codecId}\" wraps a value of this query in an expression that does not hold that value exactly once.`, {\n\t\twhy: \"A codec descriptor wraps a parameter in an expression, such as a cast, that holds the parameter exactly once, so each value of the statement keeps its placeholder.\",\n\t\tfix: `Return the parameter itself, or one expression around it, from the wrapParameter method of codec \"${codec.codecId}\", or from wrappedParameter where its descriptor extends MysqlCodecDescriptor.`,\n\t\tmeta: {\n\t\t\tcodecId: codec.codecId,\n\t\t\tparameters: parameters.length\n\t\t}\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. It is built with the target it renders for, whose id its errors carry and whose display name its messages show. A target that extends MySQL subclasses it and overrides the protected methods where its SQL or its messages differ.\n*/\nvar MysqlSqlRenderer = class {\n\tcodecs;\n\ttarget;\n\tconstructor(codecs, target) {\n\t\tthis.codecs = codecs;\n\t\tthis.target = target;\n\t}\n\trender(ast, contract) {\n\t\tconst placeholderNumbers = /* @__PURE__ */ new Map();\n\t\tconst params = collectOrderedParamRefs(ast).map((ref, index) => {\n\t\t\tplaceholderNumbers.set(ref, index + 1);\n\t\t\treturn ref.kind === \"prepared-param-ref\" ? {\n\t\t\t\tkind: \"bind\",\n\t\t\t\tname: ref.name\n\t\t\t} : {\n\t\t\t\tkind: \"literal\",\n\t\t\t\tvalue: ref.value\n\t\t\t};\n\t\t});\n\t\tconst ctx = {\n\t\t\tcontract,\n\t\t\tcodecs: this.codecs,\n\t\t\tplaceholderNumbers,\n\t\t\tuses: { groupConcat: false }\n\t\t};\n\t\tconst rendered = this.renderStatement(ast, ctx);\n\t\tconst sql = ctx.uses.groupConcat ? this.withGroupConcatHint(ast, rendered) : rendered;\n\t\tassertPlaceholdersMatchParams(sql, params.length);\n\t\treturn Object.freeze({\n\t\t\tsql,\n\t\t\tparams\n\t\t});\n\t}\n\t/** How an upsert names the row it proposes: MySQL declares it `AS new` and reads `new`.`column`. */\n\tproposedRow() {\n\t\treturn {\n\t\t\talias: PROPOSED_ROW,\n\t\t\tcolumn: (quotedColumn) => `${PROPOSED_ROW}.${quotedColumn}`\n\t\t};\n\t}\n\t/** Why `RETURNING` on `statement` is refused: MySQL has none, so the SQL family's ORM reads written rows back with a select when the contract does not report `returning`. */\n\treturningRefusal(statement) {\n\t\treturn `${this.target.displayName} cannot return the rows ${ARTICLED_STATEMENT[statement]} writes; it has no RETURNING`;\n\t}\n\t/** Why an ordered JSON array is refused, or `undefined` where the renderer builds it, as MySQL's does. */\n\torderedJsonArrayRefusal() {}\n\t/** Why an update or delete whose `SET` or `WHERE` reads `table`, the table it writes, is refused, or `undefined` where the database runs it. MySQL refuses it with error 1093. The only form MySQL accepts reads the table through a derived table, which copies the table and locks every row it copies, so concurrent writes can deadlock; the renderer does not write it. */\n\twrittenTableReadRefusal(table) {\n\t\treturn `${this.target.displayName} cannot run an UPDATE or DELETE whose filter or values read the table being written, ${table}`;\n\t}\n\t/** 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. */\n\twithGroupConcatHint(ast, rendered) {\n\t\tif (ast.kind !== \"select\" || !rendered.startsWith(\"SELECT \")) throw this.unsupported(\"ordered-array-outside-select\", `${this.target.displayName} can build an ordered JSON array only in a SELECT statement, whose outermost SELECT carries the hint that raises group_concat_max_len`);\n\t\treturn `SELECT ${GROUP_CONCAT_HINT} ${rendered.slice(7)}`;\n\t}\n\trenderStatement(ast, ctx) {\n\t\tswitch (ast.kind) {\n\t\t\tcase \"select\": return this.renderSelect(ast, ctx);\n\t\t\tcase \"raw-query\": return this.renderParts(ast.parts, ctx);\n\t\t\tcase \"insert\": return this.renderInsert(ast, ctx);\n\t\t\tcase \"update\": return this.renderUpdate(ast, ctx);\n\t\t\tcase \"delete\": return this.renderDelete(ast, ctx);\n\t\t\tdefault: throw new InternalError(`Unsupported AST node kind: ${nodeKind(ast)}`);\n\t\t}\n\t}\n\tunsupported(feature, message, guidance) {\n\t\treturn mysqlError(\"RUNTIME.AST_UNSUPPORTED\", message, {\n\t\t\t...guidance,\n\t\t\tmeta: {\n\t\t\t\ttarget: this.target.targetId,\n\t\t\t\tfeature\n\t\t\t}\n\t\t});\n\t}\n\trefuseReturning(returning, statement) {\n\t\tif (returning !== void 0 && returning.length > 0) throw this.unsupported(\"returning\", this.returningRefusal(statement));\n\t}\n\trenderInsertValue(value, ctx) {\n\t\tif (value === void 0 || value.kind === \"default-value\") return \"DEFAULT\";\n\t\treturn this.renderExpr(value, ctx);\n\t}\n\t/**\n\t* 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\t*/\n\trenderInsert(ast, ctx) {\n\t\tthis.refuseReturning(ast.returning, \"insert\");\n\t\tif (ast.rows.length === 0) throw invalid(\"insert\", \"INSERT requires at least one row\");\n\t\tconst table = this.qualifyTable(ast.table, ctx);\n\t\tconst insertCtx = {\n\t\t\t...ctx,\n\t\t\tinsertInto: {\n\t\t\t\talias: ast.table.alias ?? ast.table.name,\n\t\t\t\tname: table\n\t\t\t}\n\t\t};\n\t\tconst columns = [...new Set(ast.rows.flatMap((row) => Object.keys(row)))];\n\t\tconst values = ast.rows.map((row) => `(${columns.map((column) => this.renderInsertValue(row[column], insertCtx)).join(\", \")})`).join(\", \");\n\t\tconst insert = `INSERT INTO ${table} (${columns.map(quoteIdentifier).join(\", \")}) VALUES ${values}`;\n\t\tconst conflict = ast.onConflict;\n\t\tif (conflict === void 0) return insert;\n\t\tconst action = conflict.action;\n\t\tswitch (action.kind) {\n\t\t\tcase \"do-nothing\": throw this.unsupported(\"insert-on-conflict-skip\", `${this.target.displayName} cannot skip a conflicting row without also hiding other errors: INSERT IGNORE turns foreign-key and NOT NULL errors into warnings`);\n\t\t\tcase \"do-update-set\": {\n\t\t\t\tif (conflict.columns.length > 0) throw this.unsupported(\"insert-on-conflict-target\", `${this.target.displayName} cannot limit ON DUPLICATE KEY UPDATE to named conflict columns: it fires on any unique key`);\n\t\t\t\tconst assignments = Object.entries(action.set);\n\t\t\t\tif (assignments.length === 0) throw invalid(\"insert-on-conflict\", \"An upsert requires at least one column to update\");\n\t\t\t\tconst set = assignments.map(([column, value]) => `${quoteIdentifier(column)} = ${this.renderExpr(value, insertCtx)}`).join(\", \");\n\t\t\t\tconst { alias } = this.proposedRow();\n\t\t\t\treturn `${insert}${alias === void 0 ? \"\" : ` AS ${alias}`} ON DUPLICATE KEY UPDATE ${set}`;\n\t\t\t}\n\t\t\tdefault: return assertNever(action, `Unsupported conflict action: ${nodeKind(action)}`);\n\t\t}\n\t}\n\trenderUpdate(ast, ctx) {\n\t\tthis.refuseReturning(ast.returning, \"update\");\n\t\tconst assignments = Object.entries(ast.set);\n\t\tif (assignments.length === 0) throw invalid(\"update\", \"UPDATE requires at least one column to set\");\n\t\tconst target = this.renderTableSource(ast.table, ctx);\n\t\tconst writeCtx = this.writing(ast.table, ctx);\n\t\treturn `UPDATE ${target} SET ${assignments.map(([column, value]) => `${quoteIdentifier(column)} = ${this.renderExpr(value, writeCtx)}`).join(\", \")}${ast.where ? ` WHERE ${this.renderExpr(ast.where, writeCtx)}` : \"\"}`;\n\t}\n\trenderDelete(ast, ctx) {\n\t\tthis.refuseReturning(ast.returning, \"delete\");\n\t\treturn `DELETE FROM ${this.renderTableSource(ast.table, ctx)}${ast.where ? ` WHERE ${this.renderExpr(ast.where, this.writing(ast.table, ctx))}` : \"\"}`;\n\t}\n\twriting(table, ctx) {\n\t\treturn {\n\t\t\t...ctx,\n\t\t\twrittenTable: this.qualifyTable(table, ctx)\n\t\t};\n\t}\n\trenderLimitOffset(keyword, value, ctx) {\n\t\tif (value === void 0) return \"\";\n\t\tif (typeof value === \"number\") return `${keyword} ${value}`;\n\t\treturn `${keyword} ${value.kind === \"param-ref\" || value.kind === \"prepared-param-ref\" ? this.placeholder(value, ctx) : this.renderExpr(value, ctx)}`;\n\t}\n\trenderSelect(ast, ctx) {\n\t\tif (ast.locking !== void 0 && ast.locking.length > 0) throw this.unsupported(\"locking-clause\", `Row locks are not supported on ${this.target.displayName} yet, so a select cannot carry a locking clause such as FOR UPDATE`);\n\t\tif (ast.distinctOn !== void 0 && ast.distinctOn.length > 0) throw this.unsupported(\"distinct-on\", `${this.target.displayName} has no DISTINCT ON`);\n\t\treturn [\n\t\t\t`SELECT ${ast.distinct ? \"DISTINCT \" : \"\"}${this.renderProjection(ast.projection, ctx)}`,\n\t\t\tast.from === void 0 ? \"\" : `FROM ${this.renderSource(ast.from, ctx)}`,\n\t\t\tast.joins?.length ? ast.joins.map((join) => this.renderJoin(join, ctx)).join(\" \") : \"\",\n\t\t\tast.where ? `WHERE ${this.renderExpr(ast.where, ctx)}` : \"\",\n\t\t\tast.groupBy?.length ? `GROUP BY ${ast.groupBy.map((e) => this.renderExpr(e, ctx)).join(\", \")}` : \"\",\n\t\t\tast.having ? `HAVING ${this.renderExpr(ast.having, ctx)}` : \"\",\n\t\t\tast.orderBy?.length ? `ORDER BY ${this.renderOrderByItems(ast.orderBy, ctx)}` : \"\",\n\t\t\tast.limit === void 0 && ast.offset !== void 0 ? `LIMIT ${NO_LIMIT}` : this.renderLimitOffset(\"LIMIT\", ast.limit, ctx),\n\t\t\tthis.renderLimitOffset(\"OFFSET\", ast.offset, ctx)\n\t\t].filter((part) => part.length > 0).join(\" \");\n\t}\n\trenderProjection(projection, ctx) {\n\t\treturn projection.map((item) => `${this.renderExpr(item.expr, ctx)} AS ${quoteIdentifier(item.alias)}`).join(\", \");\n\t}\n\tqualifyTable(table, ctx) {\n\t\tif (table.namespaceId === void 0) return quoteIdentifier(table.name);\n\t\tif (ctx.contract === void 0) throw new InternalError(`Table \"${table.name}\" carries namespace \"${table.namespaceId}\" but no contract was supplied to resolve it`);\n\t\tconst namespace = ctx.contract.storage.namespaces[table.namespaceId];\n\t\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\t\ttable: table.name,\n\t\t\tnamespaceId: table.namespaceId,\n\t\t\treason: namespace === void 0 ? \"not-present\" : \"not-materialised\"\n\t\t} });\n\t\treturn namespace.qualifyTable(table.name);\n\t}\n\trenderTableSource(source, ctx) {\n\t\tconst qualified = this.qualifyTable(source, ctx);\n\t\treturn source.alias ? `${qualified} AS ${quoteIdentifier(source.alias)}` : qualified;\n\t}\n\trenderSource(source, ctx) {\n\t\tswitch (source.kind) {\n\t\t\tcase \"table-source\": {\n\t\t\t\tconst qualified = this.qualifyTable(source, ctx);\n\t\t\t\tconst refusal = qualified === ctx.writtenTable ? this.writtenTableReadRefusal(qualified) : void 0;\n\t\t\t\tif (refusal !== void 0) throw this.unsupported(\"write-reads-written-table\", refusal, {\n\t\t\t\t\twhy: `${this.target.displayName} refuses such a statement with its error 1093.`,\n\t\t\t\t\tfix: \"Read the keys of the rows, and any values the write takes from this table, with a query first. Then update or delete those rows by key, writing those values; for a variant, one row at a time with update or delete. The filter is not checked again when the rows are written.\"\n\t\t\t\t});\n\t\t\t\treturn this.renderTableSource(source, ctx);\n\t\t\t}\n\t\t\tcase \"derived-table-source\": return `(${this.renderSelect(source.query, ctx)}) AS ${quoteIdentifier(source.alias)}`;\n\t\t\tcase \"function-source\": throw this.unsupported(\"function-source\", `${this.target.displayName} cannot select from the set-returning function ${source.fn}`);\n\t\t\tdefault: return assertNever(source, `Unsupported source node kind: ${nodeKind(source)}`);\n\t\t}\n\t}\n\trenderExpr(expr, ctx) {\n\t\tswitch (expr.kind) {\n\t\t\tcase \"column-ref\": return this.renderColumn(expr, ctx);\n\t\t\tcase \"identifier-ref\": return quoteIdentifier(expr.name);\n\t\t\tcase \"operation\": return this.renderOperation(expr, ctx);\n\t\t\tcase \"subquery\": return this.renderSubquery(expr, ctx);\n\t\t\tcase \"aggregate\": return this.renderAggregate(expr, ctx);\n\t\t\tcase \"window-func\": return this.renderWindowFunc(expr, ctx);\n\t\t\tcase \"function-call\": return this.renderFunctionCall(expr, ctx);\n\t\t\tcase \"cast\": return this.renderCast(expr, ctx);\n\t\t\tcase \"case\": return this.renderCase(expr, ctx);\n\t\t\tcase \"json-object\": return this.renderJsonObject(expr, ctx);\n\t\t\tcase \"json-array-agg\": return this.renderJsonArrayAgg(expr, ctx);\n\t\t\tcase \"binary\": return this.renderBinary(expr, ctx);\n\t\t\tcase \"and\": return expr.exprs.length === 0 ? \"TRUE\" : `(${expr.exprs.map((part) => this.renderExpr(part, ctx)).join(\" AND \")})`;\n\t\t\tcase \"or\": return expr.exprs.length === 0 ? \"FALSE\" : `(${expr.exprs.map((part) => this.renderExpr(part, ctx)).join(\" OR \")})`;\n\t\t\tcase \"exists\": return `${expr.notExists ? \"NOT \" : \"\"}EXISTS (${this.renderSelect(expr.subquery, ctx)})`;\n\t\t\tcase \"null-check\": return this.renderNullCheck(expr, ctx);\n\t\t\tcase \"not\": return `NOT (${this.renderExpr(expr.expr, ctx)})`;\n\t\t\tcase \"param-ref\":\n\t\t\tcase \"prepared-param-ref\": return this.renderParam(expr, ctx);\n\t\t\tcase \"literal\": return this.renderLiteral(expr);\n\t\t\tcase \"list\": return this.renderList(expr, ctx);\n\t\t\tcase \"raw-expr\": return this.renderParts(expr.parts, ctx);\n\t\t\tdefault: return assertNever(expr, `Unsupported expression node kind: ${nodeKind(expr)}`);\n\t\t}\n\t}\n\t/** 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`. */\n\tassertNoDigitAfterParam(parts) {\n\t\tparts.forEach((part, index) => {\n\t\t\tconst next = parts[index + 1];\n\t\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 would become part of the value's placeholder\", {\n\t\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\t\tfix: \"Put a space or an operator between the interpolated value and the digit.\",\n\t\t\t\tmeta: {\n\t\t\t\t\treason: \"digit-after-value\",\n\t\t\t\t\tpart: index + 1\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\trenderParts(parts, ctx) {\n\t\tthis.assertNoDigitAfterParam(parts);\n\t\treturn parts.map((part) => {\n\t\t\tif (typeof part === \"string\") return part;\n\t\t\tswitch (part.kind) {\n\t\t\t\tcase \"select\": return this.renderSelect(part, ctx);\n\t\t\t\tcase \"insert\": return this.renderInsert(part, ctx);\n\t\t\t\tcase \"update\": return this.renderUpdate(part, ctx);\n\t\t\t\tcase \"delete\": return this.renderDelete(part, ctx);\n\t\t\t\tdefault: return this.renderExpr(part, ctx);\n\t\t\t}\n\t\t}).join(\"\");\n\t}\n\trenderColumn(ref, ctx) {\n\t\tconst column = quoteIdentifier(ref.column);\n\t\tconst { insertInto } = ctx;\n\t\tif (insertInto !== void 0) {\n\t\t\tif (ref.table === \"excluded\") return this.proposedRow().column(column);\n\t\t\tif (ref.table === insertInto.alias) return `${insertInto.name}.${column}`;\n\t\t}\n\t\treturn `${quoteIdentifier(ref.table)}.${column}`;\n\t}\n\t/**\n\t* 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\t*/\n\trenderLiteral(expr) {\n\t\tconst { value } = expr;\n\t\tif (value === null || value === void 0) return \"NULL\";\n\t\tif (typeof value === \"number\") {\n\t\t\tif (!Number.isFinite(value)) throw this.unsupported(\"non-finite-number\", `${this.target.displayName} has no literal for ${value}`);\n\t\t\treturn String(value);\n\t\t}\n\t\tif (typeof value === \"boolean\") return value ? \"TRUE\" : \"FALSE\";\n\t\tif (typeof value === \"bigint\") return String(value);\n\t\tconst kind = value instanceof Date ? \"date\" : Array.isArray(value) ? \"array\" : typeof value;\n\t\tthrow this.unsupported(\"value-literal\", `Prisma writes only numbers, booleans and NULL into ${this.target.displayName} SQL as literals, and this query has ${/^[aeiou]/.test(kind) ? \"an\" : \"a\"} ${kind} literal; pass the value as a parameter instead`);\n\t}\n\t/** Renders each `{{self}}` and `{{argN}}` where the template writes it. */\n\trenderOperation(expr, ctx) {\n\t\treturn expr.lowering.template.replace(/\\{\\{(self|arg(\\d+))\\}\\}/g, (_match, _name, index) => {\n\t\t\tif (index === void 0) return this.renderExpr(expr.self, ctx);\n\t\t\tconst arg = expr.args[Number(index)];\n\t\t\treturn arg === void 0 ? \"\" : this.renderExpr(arg, ctx);\n\t\t});\n\t}\n\trenderSubquery(expr, ctx, columns = 1) {\n\t\tif (expr.query.projection.length !== columns) throw structuredError(\"RUNTIME.AST_INVALID\", columns === 1 ? \"Subquery expressions must project exactly one column\" : `A subquery compared with a row value of ${columns} columns must project ${columns} columns`, { meta: { node: \"subquery\" } });\n\t\treturn `(${this.renderSelect(expr.query, ctx)})`;\n\t}\n\tgrouped(expr, ctx) {\n\t\tconst rendered = this.renderExpr(expr, ctx);\n\t\treturn needsGrouping(expr) ? `(${rendered})` : rendered;\n\t}\n\trenderNullCheck(expr, ctx) {\n\t\treturn `${this.grouped(expr.expr, ctx)} ${expr.isNull ? \"IS NULL\" : \"IS NOT NULL\"}`;\n\t}\n\trenderBinary(expr, ctx) {\n\t\tif (expr.right.kind === \"list\" && expr.right.values.length === 0) {\n\t\t\tif (expr.op === \"in\") return \"FALSE\";\n\t\t\tif (expr.op === \"notIn\") return \"TRUE\";\n\t\t}\n\t\tconst left = this.grouped(expr.left, ctx);\n\t\tconst right = expr.right.kind === \"subquery\" && expr.left.kind === \"list\" ? this.renderSubquery(expr.right, ctx, expr.left.values.length) : this.renderExpr(expr.right, ctx);\n\t\tif (expr.op === \"isDistinctFrom\") return `NOT (${left} <=> ${right})`;\n\t\treturn `${left} ${BINARY_OPERATORS[expr.op]} ${right}`;\n\t}\n\trenderList(expr, ctx) {\n\t\tif (expr.values.length === 0) return \"(NULL)\";\n\t\treturn `(${expr.values.map((value) => this.renderExpr(value, ctx)).join(\", \")})`;\n\t}\n\trenderAggregate(expr, ctx) {\n\t\tconst fn = expr.fn.toUpperCase();\n\t\treturn expr.expr ? `${fn}(${this.renderExpr(expr.expr, ctx)})` : `${fn}(*)`;\n\t}\n\trenderWindowFunc(expr, ctx) {\n\t\tconst args = expr.args.map((arg) => this.renderExpr(arg, ctx)).join(\", \");\n\t\tconst over = [expr.partitionBy?.length ? `PARTITION BY ${expr.partitionBy.map((e) => this.renderExpr(e, ctx)).join(\", \")}` : \"\", expr.orderBy?.length ? `ORDER BY ${this.renderOrderByItems(expr.orderBy, ctx)}` : \"\"].filter((part) => part.length > 0).join(\" \");\n\t\treturn `${expr.fn.toUpperCase()}(${args}) OVER (${over})`;\n\t}\n\trenderFunctionCall(expr, ctx) {\n\t\treturn `${expr.fn}(${expr.args.map((arg) => this.renderExpr(arg, ctx)).join(\", \")})`;\n\t}\n\trenderCast(expr, ctx) {\n\t\treturn `CAST(${this.renderExpr(expr.expr, ctx)} AS ${expr.targetType})`;\n\t}\n\trenderCase(expr, ctx) {\n\t\treturn `CASE ${expr.branches.map((branch) => `WHEN ${this.renderExpr(branch.condition, ctx)} THEN ${this.renderExpr(branch.value, ctx)}`).join(\" \")}${expr.elseExpr === void 0 ? \"\" : ` ELSE ${this.renderExpr(expr.elseExpr, ctx)}`} END`;\n\t}\n\tdescriptorOf(codec, ctx, use) {\n\t\tconst descriptor = ctx.codecs.descriptorFor(codec.codecId);\n\t\tif (descriptor === void 0) throw structuredError(\"RUNTIME.PARAM_REF_MISSING_CODEC\", `${use} uses codec \"${codec.codecId}\", which no extension given to the client provides.`, {\n\t\t\tfix: `Add the extension that provides codec \"${codec.codecId}\" to the client's \\`extensions\\`.`,\n\t\t\tmeta: { codecId: codec.codecId }\n\t\t});\n\t\treturn descriptor;\n\t}\n\tplaceholder(ref, ctx) {\n\t\tconst number = ctx.placeholderNumbers.get(ref);\n\t\tif (number === void 0) throw new InternalError(\"A param was written that the AST does not collect\");\n\t\treturn `?${number}`;\n\t}\n\t/** A param as its numbered placeholder, in the expression its codec wraps it in, refusing one whose codec the MySQL registry lacks. */\n\trenderParam(ref, ctx) {\n\t\tconst placeholder = this.placeholder(ref, ctx);\n\t\tif (ref.codec === void 0 || ctx.wrappedParameter === ref) return placeholder;\n\t\tconst wrapped = this.descriptorOf(ref.codec, ctx, \"A value in this query\").wrapParameter(ref, ref.codec);\n\t\tif (wrapped === ref) return placeholder;\n\t\tassertWrapsParameterOnce(wrapped, ref, ref.codec);\n\t\tconst rendered = this.renderExpr(wrapped, {\n\t\t\t...ctx,\n\t\t\twrappedParameter: ref\n\t\t});\n\t\treturn wrapped.kind === \"function-call\" || wrapped.kind === \"cast\" ? rendered : `(${rendered})`;\n\t}\n\tprojectThroughCodec(value, codec, ctx) {\n\t\treturn this.descriptorOf(codec, ctx, \"A column this query reads in an include\").projectJson(value, codec);\n\t}\n\trenderJsonValue(projection, ctx) {\n\t\treturn projection.accept({\n\t\t\tcodec: ({ value, codec }) => this.renderExpr(this.projectThroughCodec(value, codec, ctx), ctx),\n\t\t\tnative: ({ value }) => this.renderExpr(value, ctx),\n\t\t\tdocument: ({ value }) => this.renderExpr(value, ctx)\n\t\t});\n\t}\n\trenderJsonObject(expr, ctx) {\n\t\treturn `JSON_OBJECT(${expr.entries.flatMap((entry) => [`'${escapeLiteral(entry.key)}'`, this.renderJsonValue(entry.value, ctx)]).join(\", \")})`;\n\t}\n\t/**\n\t* 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\t*/\n\trenderJsonElementText(projection, ctx) {\n\t\tconst rendered = this.renderJsonValue(projection, ctx);\n\t\treturn projection.kind === \"document\" ? rendered : `JSON_EXTRACT(JSON_ARRAY(${rendered}), '$[0]')`;\n\t}\n\t/**\n\t* `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\t*/\n\trenderJsonArrayAgg(expr, ctx) {\n\t\tif (expr.orderBy === void 0) {\n\t\t\tconst aggregated = `JSON_ARRAYAGG(${this.renderJsonValue(expr.expr, ctx)})`;\n\t\t\treturn expr.onEmpty === \"emptyArray\" ? `COALESCE(${aggregated}, JSON_ARRAY())` : aggregated;\n\t\t}\n\t\tconst refusal = this.orderedJsonArrayRefusal();\n\t\tif (refusal !== void 0) throw this.unsupported(\"ordered-json-array\", refusal);\n\t\tctx.uses.groupConcat = true;\n\t\tconst text = `CONCAT('[', GROUP_CONCAT(${this.renderJsonElementText(expr.expr, ctx)} ORDER BY ${this.renderOrderByItems(expr.orderBy, ctx)} SEPARATOR ','), ']')`;\n\t\treturn `CASE WHEN COUNT(*) = 0 THEN ${expr.onEmpty === \"emptyArray\" ? \"JSON_ARRAY()\" : \"NULL\"} ELSE CAST(COALESCE(${text}, ${OVERSIZED_ARRAY_TEXT}) AS JSON) END`;\n\t}\n\trenderOrderByItem(item, ctx) {\n\t\treturn `${item.nulls === void 0 ? \"\" : `${this.grouped(item.expr, ctx)} IS NULL ${NULLS_KEY_DIRECTION[item.nulls]}, `}${this.renderExpr(item.expr, ctx)} ${ORDER_DIRECTION[item.dir]}`;\n\t}\n\trenderOrderByItems(items, ctx) {\n\t\treturn items.map((item) => this.renderOrderByItem(item, ctx)).join(\", \");\n\t}\n\trenderJoin(join, ctx) {\n\t\tif (join.joinType === \"full\") throw this.unsupported(\"full-join\", `${this.target.displayName} has no FULL JOIN`);\n\t\tif (join.lateral) throw this.unsupported(\"lateral-join\", `LATERAL joins are not supported on ${this.target.displayName} yet`);\n\t\treturn `${join.joinType.toUpperCase()} JOIN ${this.renderSource(join.source, ctx)} ON ${this.renderJoinOn(join.on, ctx)}`;\n\t}\n\trenderJoinOn(on, ctx) {\n\t\treturn on.kind === \"eq-col-join-on\" ? `${this.renderColumn(on.left, ctx)} = ${this.renderColumn(on.right, ctx)}` : this.renderExpr(on, ctx);\n\t}\n};\n//#endregion\nexport { MysqlSqlRenderer as t };\n\n//# sourceMappingURL=sql-renderer-DfPaqPkD.mjs.map"],"mappings":";;;;;;;;AAOA,SAAS,8BAA8B,KAAK,YAAY;CACvD,MAAM,SAAS,iBAAiB,GAAG,CAAC,CAAC,QAAQ,UAAU,MAAM,SAAS,aAAa;CACnF,MAAM,eAAe,OAAO,KAAK,UAAU,MAAM,IAAI;CACrD,MAAM,UAAU,OAAO,KAAK,UAAU,MAAM,UAAU,GAAG;CACzD,IAAI,QAAQ,OAAO,WAAW,UAAU,KAAK,UAAU,UAAU,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,SAAS,YAAY;CAC5G,MAAM,gBAAgB,sCAAsC,4BAA4B,KAAK,UAAU,YAAY,EAAE,OAAO,WAAW,0GAA0G;EAChP,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA,QAAQ;EACT;CACD,CAAC;AACF;AAGA,MAAM,qBAAqB;CAC1B,QAAQ;CACR,QAAQ;CACR,QAAQ;AACT;;AAEA,MAAM,eAAe,gBAAgB,KAAK;;;;AAI1C,MAAM,oBAAoB;;AAE1B,MAAM,WAAW;AACjB,MAAM,mBAAmB;CACxB,IAAI;CACJ,KAAK;CACL,mBAAmB;CACnB,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,KAAK;CACL,MAAM;CACN,IAAI;CACJ,OAAO;AACR;;AAEA,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O,GAAG,KAAK,SAAS,YAAY,EAAE,QAAQ,KAAK,aAAa,KAAK,QAAQ,GAAG,EAAE,MAAM,KAAK,aAAa,KAAK,IAAI,GAAG;CACvH;CACA,aAAa,IAAI,KAAK;EACrB,OAAO,GAAG,SAAS,mBAAmB,GAAG,KAAK,aAAa,GAAG,MAAM,GAAG,EAAE,KAAK,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,KAAK,WAAW,IAAI,GAAG;CAC3I;AACD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { i as MysqlCodecDescriptorRegistry } from "./codec-descriptor-DXsJwUng-D4abEAFs.mjs";
|
|
2
|
+
import { a as MysqlRuntimeTargetMeta } from "./runtime-Ci3hPz1j.mjs";
|
|
3
|
+
import "./codec-descriptor-CqM_hQjY.mjs";
|
|
4
|
+
import { AnyQueryAst, LoweredStatement } from "@prisma/orm-family-sql/relational-core/ast";
|
|
5
|
+
import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
6
|
+
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
7
|
+
//#region ../../../3-targets/mysql/1-mysql/2-adapter/dist/sql-renderer-fnDhRUHs.d.mts
|
|
8
|
+
//#region src/core/sql-renderer.d.ts
|
|
9
|
+
type MysqlContract = Contract<SqlStorage>;
|
|
10
|
+
/** A statement that can carry `RETURNING`. */
|
|
11
|
+
type ReturningStatement = 'insert' | 'update' | 'delete';
|
|
12
|
+
/** How an upsert names the row it proposes: the alias it declares after the inserted rows, if any, and how its assignments read a column of that row, given the column's quoted name. */
|
|
13
|
+
interface ProposedRow {
|
|
14
|
+
readonly alias: string | undefined;
|
|
15
|
+
readonly column: (quotedColumn: string) => string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 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. It is built with the target it renders for, whose id its errors carry and whose display name its messages show. A target that extends MySQL subclasses it and overrides the protected methods where its SQL or its messages differ.
|
|
19
|
+
*/
|
|
20
|
+
declare class MysqlSqlRenderer {
|
|
21
|
+
private readonly codecs;
|
|
22
|
+
protected readonly target: Pick<MysqlRuntimeTargetMeta<string>, 'targetId' | 'displayName'>;
|
|
23
|
+
constructor(codecs: MysqlCodecDescriptorRegistry, target: Pick<MysqlRuntimeTargetMeta<string>, 'targetId' | 'displayName'>);
|
|
24
|
+
render(ast: AnyQueryAst, contract: MysqlContract | undefined): LoweredStatement;
|
|
25
|
+
/** How an upsert names the row it proposes: MySQL declares it `AS new` and reads `new`.`column`. */
|
|
26
|
+
protected proposedRow(): ProposedRow;
|
|
27
|
+
/** Why `RETURNING` on `statement` is refused: MySQL has none, so the SQL family's ORM reads written rows back with a select when the contract does not report `returning`. */
|
|
28
|
+
protected returningRefusal(statement: ReturningStatement): string;
|
|
29
|
+
/** Why an ordered JSON array is refused, or `undefined` where the renderer builds it, as MySQL's does. */
|
|
30
|
+
protected orderedJsonArrayRefusal(): string | undefined;
|
|
31
|
+
/** Why an update or delete whose `SET` or `WHERE` reads `table`, the table it writes, is refused, or `undefined` where the database runs it. MySQL refuses it with error 1093. The only form MySQL accepts reads the table through a derived table, which copies the table and locks every row it copies, so concurrent writes can deadlock; the renderer does not write it. */
|
|
32
|
+
protected writtenTableReadRefusal(table: string): string | undefined;
|
|
33
|
+
/** 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. */
|
|
34
|
+
private withGroupConcatHint;
|
|
35
|
+
private renderStatement;
|
|
36
|
+
private unsupported;
|
|
37
|
+
private refuseReturning;
|
|
38
|
+
private renderInsertValue;
|
|
39
|
+
/**
|
|
40
|
+
* 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.
|
|
41
|
+
*/
|
|
42
|
+
private renderInsert;
|
|
43
|
+
private renderUpdate;
|
|
44
|
+
private renderDelete;
|
|
45
|
+
private writing;
|
|
46
|
+
private renderLimitOffset;
|
|
47
|
+
private renderSelect;
|
|
48
|
+
private renderProjection;
|
|
49
|
+
private qualifyTable;
|
|
50
|
+
private renderTableSource;
|
|
51
|
+
private renderSource;
|
|
52
|
+
private renderExpr;
|
|
53
|
+
/** 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`. */
|
|
54
|
+
private assertNoDigitAfterParam;
|
|
55
|
+
private renderParts;
|
|
56
|
+
private renderColumn;
|
|
57
|
+
/**
|
|
58
|
+
* 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.
|
|
59
|
+
*/
|
|
60
|
+
private renderLiteral;
|
|
61
|
+
/** Renders each `{{self}}` and `{{argN}}` where the template writes it. */
|
|
62
|
+
private renderOperation;
|
|
63
|
+
private renderSubquery;
|
|
64
|
+
private grouped;
|
|
65
|
+
private renderNullCheck;
|
|
66
|
+
private renderBinary;
|
|
67
|
+
private renderList;
|
|
68
|
+
private renderAggregate;
|
|
69
|
+
private renderWindowFunc;
|
|
70
|
+
private renderFunctionCall;
|
|
71
|
+
private renderCast;
|
|
72
|
+
private renderCase;
|
|
73
|
+
private descriptorOf;
|
|
74
|
+
private placeholder;
|
|
75
|
+
/** A param as its numbered placeholder, in the expression its codec wraps it in, refusing one whose codec the MySQL registry lacks. */
|
|
76
|
+
private renderParam;
|
|
77
|
+
private projectThroughCodec;
|
|
78
|
+
private renderJsonValue;
|
|
79
|
+
private renderJsonObject;
|
|
80
|
+
/**
|
|
81
|
+
* 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.
|
|
82
|
+
*/
|
|
83
|
+
private renderJsonElementText;
|
|
84
|
+
/**
|
|
85
|
+
* `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.
|
|
86
|
+
*/
|
|
87
|
+
private renderJsonArrayAgg;
|
|
88
|
+
private renderOrderByItem;
|
|
89
|
+
private renderOrderByItems;
|
|
90
|
+
private renderJoin;
|
|
91
|
+
private renderJoinOn;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { ReturningStatement as i, MysqlSqlRenderer as n, ProposedRow as r, MysqlContract as t };
|
|
95
|
+
//# sourceMappingURL=sql-renderer-fnDhRUHs-CcsyIaZ4.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-renderer-fnDhRUHs-CcsyIaZ4.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-mysql/2-adapter/dist/sql-renderer-fnDhRUHs.d.mts"],"mappings":";;;;;;;;KAMK,gBAAgB,SAAS;;KAEzB;;UAEK;WACC;WACA,SAAS;;;;;cAKN;mBACK;qBACE,QAAQ,KAAK;EAChC,YAAY,QAAQ,8BAA8B,QAAQ,KAAK;EAC/D,OAAO,KAAK,aAAa,UAAU,4BAA4B;;YAErD,eAAe;;YAEf,iBAAiB,WAAW;;YAE5B;;YAEA,wBAAwB;;UAE1B;UACA;UACA;UACA;UACA;;;;UAIA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;UACA;;;;UAIA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;UACA;UACA;;;;UAIA;;;;UAIA;UACA;UACA;UACA;UACA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/sql-utils-
|
|
1
|
+
import { l as mysqlError } from "./errors-CWtFTnst-xBLJ-9Lp.mjs";
|
|
2
|
+
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/sql-utils-CveZhawQ.mjs
|
|
3
3
|
/** A MySQL identifier in backticks, with each backtick doubled. */
|
|
4
4
|
function quoteIdentifier(identifier) {
|
|
5
5
|
if (identifier.length === 0) throw mysqlError("CONTRACT.IDENTIFIER_INVALID", "Identifier cannot be empty", { meta: {
|
|
@@ -27,4 +27,4 @@ function quoteLiteral(value) {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { quoteIdentifier as n, quoteLiteral as r, escapeLiteral as t };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=sql-utils-
|
|
30
|
+
//# sourceMappingURL=sql-utils-CveZhawQ-B2QmUlY0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-utils-
|
|
1
|
+
{"version":3,"file":"sql-utils-CveZhawQ-B2QmUlY0.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/1-target/dist/sql-utils-CveZhawQ.mjs"],"sourcesContent":["import { l as mysqlError } from \"./errors-CWtFTnst.mjs\";\n//#region src/core/sql-utils.ts\n/** A MySQL identifier in backticks, with each backtick doubled. */\nfunction quoteIdentifier(identifier) {\n\tif (identifier.length === 0) throw mysqlError(\"CONTRACT.IDENTIFIER_INVALID\", \"Identifier cannot be empty\", { meta: {\n\t\tvalue: identifier,\n\t\tcontext: \"identifier\"\n\t} });\n\tif (identifier.includes(\"\\0\")) throw mysqlError(\"CONTRACT.IDENTIFIER_INVALID\", \"Identifier cannot contain null bytes\", { meta: {\n\t\tvalue: identifier.replace(/\\0/g, \"\\\\0\"),\n\t\tcontext: \"identifier\"\n\t} });\n\treturn `\\`${identifier.replace(/`/g, \"``\")}\\``;\n}\n/** The body of a MySQL string literal: quotes doubled and backslashes escaped, as MySQL reads them under its default SQL mode. */\nfunction escapeLiteral(value) {\n\tif (value.includes(\"\\0\")) throw mysqlError(\"CONTRACT.IDENTIFIER_INVALID\", \"Literal value cannot contain null bytes\", { meta: {\n\t\tvalue: value.replace(/\\0/g, \"\\\\0\"),\n\t\tcontext: \"literal\"\n\t} });\n\treturn value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"''\");\n}\n/** A MySQL string literal. */\nfunction quoteLiteral(value) {\n\treturn `'${escapeLiteral(value)}'`;\n}\n//#endregion\nexport { quoteIdentifier as n, quoteLiteral as r, escapeLiteral as t };\n\n//# sourceMappingURL=sql-utils-CveZhawQ.mjs.map"],"mappings":";;;AAGA,SAAS,gBAAgB,YAAY;CACpC,IAAI,WAAW,WAAW,GAAG,MAAM,WAAW,+BAA+B,8BAA8B,EAAE,MAAM;EAClH,OAAO;EACP,SAAS;CACV,EAAE,CAAC;CACH,IAAI,WAAW,SAAS,IAAI,GAAG,MAAM,WAAW,+BAA+B,wCAAwC,EAAE,MAAM;EAC9H,OAAO,WAAW,QAAQ,OAAO,KAAK;EACtC,SAAS;CACV,EAAE,CAAC;CACH,OAAO,KAAK,WAAW,QAAQ,MAAM,IAAI,EAAE;AAC5C;;AAEA,SAAS,cAAc,OAAO;CAC7B,IAAI,MAAM,SAAS,IAAI,GAAG,MAAM,WAAW,+BAA+B,2CAA2C,EAAE,MAAM;EAC5H,OAAO,MAAM,QAAQ,OAAO,KAAK;EACjC,SAAS;CACV,EAAE,CAAC;CACH,OAAO,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,IAAI;AACvD;;AAEA,SAAS,aAAa,OAAO;CAC5B,OAAO,IAAI,cAAc,KAAK,EAAE;AACjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as mysqlError } from "./errors-CWtFTnst-xBLJ-9Lp.mjs";
|
|
2
2
|
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/sql-utils.mjs
|
|
3
3
|
const NUMBERED_PLACEHOLDER = /^\?([1-9]\d*)$/;
|
|
4
4
|
function placeholderToken(text) {
|
|
@@ -63,10 +63,7 @@ function tokenizeMysqlSql(sql) {
|
|
|
63
63
|
kind = "quoted";
|
|
64
64
|
end = endOfQuoted(sql, index, char);
|
|
65
65
|
} else if (char === "#" || opensDashComment(sql, index) || sql.startsWith("/*", index)) {
|
|
66
|
-
if (sql.startsWith("/*!", index)) throw mysqlError("RUNTIME.AST_INVALID", "A
|
|
67
|
-
target: "mysql",
|
|
68
|
-
position: index
|
|
69
|
-
} });
|
|
66
|
+
if (sql.startsWith("/*!", index) || sql.startsWith("/*M!", index)) throw mysqlError("RUNTIME.AST_INVALID", "A statement may not contain an executable comment, /*! or /*M!, whose content MySQL or MariaDB runs as SQL", { meta: { position: index } });
|
|
70
67
|
kind = "comment";
|
|
71
68
|
end = sql.startsWith("/*", index) ? endOf(sql, index + 2, "*/") : endOf(sql, index, "\n");
|
|
72
69
|
} else if (char === "?") {
|
|
@@ -91,4 +88,4 @@ function tokenizeMysqlSql(sql) {
|
|
|
91
88
|
//#endregion
|
|
92
89
|
export { tokenizeMysqlSql as t };
|
|
93
90
|
|
|
94
|
-
//# sourceMappingURL=sql-utils-
|
|
91
|
+
//# sourceMappingURL=sql-utils-DVH8boEI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-utils-DVH8boEI.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/1-target/dist/sql-utils.mjs"],"sourcesContent":["import { l as mysqlError } from \"./errors-CWtFTnst.mjs\";\nimport { n as quoteIdentifier, r as quoteLiteral, t as escapeLiteral } from \"./sql-utils-CveZhawQ.mjs\";\n//#region src/core/sql-lexer.ts\nconst NUMBERED_PLACEHOLDER = /^\\?([1-9]\\d*)$/;\nfunction placeholderToken(text) {\n\tconst digits = NUMBERED_PLACEHOLDER.exec(text)?.[1];\n\treturn {\n\t\tkind: \"placeholder\",\n\t\ttext,\n\t\tnumber: digits === void 0 ? void 0 : Number(digits)\n\t};\n}\n/** The index just past the quoted text that opens at `start`, where a doubled quote stays inside and, outside a backtick identifier, a backslash escapes the next character. The session clears `NO_BACKSLASH_ESCAPES` and `ANSI_QUOTES`, so MySQL reads quotes the same way. */\nfunction endOfQuoted(sql, start, quote) {\n\tlet index = start + 1;\n\twhile (index < sql.length) {\n\t\tconst char = sql[index];\n\t\tif (char === \"\\\\\" && quote !== \"`\") index += 2;\n\t\telse if (char === quote) {\n\t\t\tif (sql[index + 1] !== quote) return index + 1;\n\t\t\tindex += 2;\n\t\t} else index += 1;\n\t}\n\treturn sql.length;\n}\nfunction endOf(sql, start, terminator) {\n\tconst end = sql.indexOf(terminator, start);\n\treturn end === -1 ? sql.length : end + terminator.length;\n}\n/** MySQL opens a `--` comment when the next character is whitespace or a control character, or the text ends: `my_isspace` or `my_iscntrl` in its lexer. */\nfunction opensDashComment(sql, index) {\n\tif (!sql.startsWith(\"--\", index)) return false;\n\tconst next = sql.charCodeAt(index + 2);\n\treturn Number.isNaN(next) || next <= 32 || next === 127;\n}\nfunction isDigit(char) {\n\treturn char !== void 0 && char >= \"0\" && char <= \"9\";\n}\n/** A character of an unquoted identifier, keyword or number, as MySQL reads one: a letter, a digit, `$`, `_`, or any character past ASCII. */\nfunction isWordChar(char) {\n\tif (char === void 0) return false;\n\tconst lower = char.toLowerCase();\n\treturn isDigit(char) || lower >= \"a\" && lower <= \"z\" || char === \"$\" || char === \"_\" || char >= \"\";\n}\nfunction isWhitespace(char) {\n\treturn char === \" \" || char === \"\t\" || char === \"\\n\" || char === \"\\r\" || char === \"\\f\" || char === \"\\v\";\n}\nfunction endOfRun(sql, start, belongs) {\n\tlet end = start;\n\twhile (end < sql.length && belongs(sql[end])) end += 1;\n\treturn end;\n}\n/**\n* Splits MySQL SQL into tokens as MySQL's lexer reads it: a `?` inside a quoted string, a backtick identifier or a `#`, `--` or block comment is not a placeholder, and a keyword inside one is not a word. Joining the tokens' text gives the SQL back. Refuses an executable `/*!` comment, whose content MySQL runs as SQL and whose strings the comment's closing marker does not end.\n*/\nfunction tokenizeMysqlSql(sql) {\n\tconst tokens = [];\n\tlet index = 0;\n\twhile (index < sql.length) {\n\t\tconst char = sql[index];\n\t\tlet kind = \"symbol\";\n\t\tlet end = index + 1;\n\t\tif (char === \"'\" || char === \"\\\"\" || char === \"`\") {\n\t\t\tkind = \"quoted\";\n\t\t\tend = endOfQuoted(sql, index, char);\n\t\t} else if (char === \"#\" || opensDashComment(sql, index) || sql.startsWith(\"/*\", index)) {\n\t\t\tif (sql.startsWith(\"/*!\", index) || sql.startsWith(\"/*M!\", index)) throw mysqlError(\"RUNTIME.AST_INVALID\", \"A statement may not contain an executable comment, /*! or /*M!, whose content MySQL or MariaDB runs as SQL\", { meta: { position: index } });\n\t\t\tkind = \"comment\";\n\t\t\tend = sql.startsWith(\"/*\", index) ? endOf(sql, index + 2, \"*/\") : endOf(sql, index, \"\\n\");\n\t\t} else if (char === \"?\") {\n\t\t\tkind = \"placeholder\";\n\t\t\tend = endOfRun(sql, end, isDigit);\n\t\t} else if (isWhitespace(char)) {\n\t\t\tkind = \"whitespace\";\n\t\t\tend = endOfRun(sql, index, isWhitespace);\n\t\t} else if (isWordChar(char)) {\n\t\t\tkind = \"word\";\n\t\t\tend = endOfRun(sql, index, isWordChar);\n\t\t}\n\t\tconst text = sql.slice(index, end);\n\t\ttokens.push(kind === \"placeholder\" ? placeholderToken(text) : {\n\t\t\tkind,\n\t\t\ttext\n\t\t});\n\t\tindex = end;\n\t}\n\treturn tokens;\n}\n//#endregion\nexport { escapeLiteral, quoteIdentifier, quoteLiteral, tokenizeMysqlSql };\n\n//# sourceMappingURL=sql-utils.mjs.map"],"mappings":";;AAGA,MAAM,uBAAuB;AAC7B,SAAS,iBAAiB,MAAM;CAC/B,MAAM,SAAS,qBAAqB,KAAK,IAAI,CAAC,GAAG;CACjD,OAAO;EACN,MAAM;EACN;EACA,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM;CACnD;AACD;;AAEA,SAAS,YAAY,KAAK,OAAO,OAAO;CACvC,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,QAAQ;EAC1B,MAAM,OAAO,IAAI;EACjB,IAAI,SAAS,QAAQ,UAAU,KAAK,SAAS;OACxC,IAAI,SAAS,OAAO;GACxB,IAAI,IAAI,QAAQ,OAAO,OAAO,OAAO,QAAQ;GAC7C,SAAS;EACV,OAAO,SAAS;CACjB;CACA,OAAO,IAAI;AACZ;AACA,SAAS,MAAM,KAAK,OAAO,YAAY;CACtC,MAAM,MAAM,IAAI,QAAQ,YAAY,KAAK;CACzC,OAAO,QAAQ,KAAK,IAAI,SAAS,MAAM,WAAW;AACnD;;AAEA,SAAS,iBAAiB,KAAK,OAAO;CACrC,IAAI,CAAC,IAAI,WAAW,MAAM,KAAK,GAAG,OAAO;CACzC,MAAM,OAAO,IAAI,WAAW,QAAQ,CAAC;CACrC,OAAO,OAAO,MAAM,IAAI,KAAK,QAAQ,MAAM,SAAS;AACrD;AACA,SAAS,QAAQ,MAAM;CACtB,OAAO,SAAS,KAAK,KAAK,QAAQ,OAAO,QAAQ;AAClD;;AAEA,SAAS,WAAW,MAAM;CACzB,IAAI,SAAS,KAAK,GAAG,OAAO;CAC5B,MAAM,QAAQ,KAAK,YAAY;CAC/B,OAAO,QAAQ,IAAI,KAAK,SAAS,OAAO,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