@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs-
|
|
1
|
+
{"version":3,"file":"codecs-DTfUoamS.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-mysql/1-target/dist/codecs.d.mts"],"mappings":";;;;;;;KAMK,mBAAmB,KAAK;KACxB,qBAAqB,gBAAgB;;iBAEzB,2BAA2B,QAAQ,kBAAkB,YAAY,cAAc,oBAAoB;;iBAEnG,iCAAiC;;;;cAIpC;;cAEA;;cAEA;KACT,sBAAsB,2BAA2B,wBAAwB;;;;iBAI7D,qBAAqB,iCAAiC;;iBAEtD,mBAAmB,SAAS,cAAc;;;;cAI7C,oBAAoB;cACpB,8BAA8B"}
|
|
@@ -1,16 +1,71 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as
|
|
3
|
-
import { c as
|
|
4
|
-
import {
|
|
5
|
-
import { t as requireTemporal } from "./require-temporal-
|
|
6
|
-
import { CodecImpl, dateTimeStoredText, decimalTextBigintLiteral, refuseJsonValue, renderTsLiteral } from "@prisma/orm-framework/components/codec";
|
|
7
|
-
import { CastExpr, SqlCharCodec, SqlRawCodec, SqlVarcharCodec, sqlCharDescriptor, sqlRawDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
|
|
1
|
+
import { _ as MYSQL_TIMESTAMP_DATE_CODEC_ID, a as MYSQL_DATETIME_STRING_CODEC_ID, b as MYSQL_TIME_STRING_CODEC_ID, c as MYSQL_DATE_TEMPORAL_CODEC_ID, d as MYSQL_DURATION_STRING_CODEC_ID, f as MYSQL_ENUM_CODEC_ID, g as MYSQL_TEXT_CODEC_ID, h as MYSQL_LONGBLOB_CODEC_ID, i as MYSQL_DATETIME_CODEC_ID, l as MYSQL_DECIMAL_CODEC_ID, m as MYSQL_JSON_CODEC_ID, n as MYSQL_BIGINT_NUMBER_CODEC_ID, o as MYSQL_DATETIME_TEMPORAL_CODEC_ID, p as MYSQL_INT_CODEC_ID, r as MYSQL_BOOLEAN_CODEC_ID, s as MYSQL_DATE_STRING_CODEC_ID, t as MYSQL_BIGINT_CODEC_ID, u as MYSQL_DOUBLE_CODEC_ID, v as MYSQL_TIMESTAMP_STRING_CODEC_ID, x as MYSQL_TIME_TEMPORAL_CODEC_ID, y as MYSQL_TIMESTAMP_TEMPORAL_CODEC_ID } from "./codec-ids-DuWt4aOn-DiyLf9dW.mjs";
|
|
2
|
+
import { a as errorTemporalNonIsoCalendar, c as errorTemporalWrongType, i as errorDateTimeUnwritable, l as mysqlError, n as errorColumnUnwritable, r as errorDateTimeUnreadable, t as errorColumnUnreadable } from "./errors-CWtFTnst-xBLJ-9Lp.mjs";
|
|
3
|
+
import { A as mysqlLongblob, C as mysqlDuration, D as mysqlEnumParams, E as mysqlEnum, F as mysqlTimeText, I as mysqlTimestamp, L as mysqlTimestampText, M as mysqlText, O as mysqlInt, P as mysqlTime, R as mysqlVarchar, S as mysqlDouble, T as mysqlDurationText, _ as mysqlDecimal, a as decimalTextDigits, b as mysqlDecimalParams, c as mysqlBoolean, f as mysqlDate, g as mysqlDatetimeText, h as mysqlDatetimeParams, i as decimalColumnHolds, k as mysqlJson, l as mysqlChar, m as mysqlDatetime, o as decimalTextInColumn, p as mysqlDateText, r as MYSQL_WIDEST_DECIMAL, s as mysqlBigint, v as mysqlDecimalColumnAsCreated, w as mysqlDurationParams, y as mysqlDecimalColumnOfReference } from "./data-types-CU_43cNv-CQ8eHx3H.mjs";
|
|
4
|
+
import { a as mysqlCodec, n as buildMysqlCodecDescriptorRegistry, r as identityJsonProjection, t as MysqlCodecDescriptor } from "./codec-descriptor-ByN7iIha-48yW7oDN.mjs";
|
|
5
|
+
import { t as requireTemporal } from "./require-temporal-DDdrgVtL-VOKxTqhD.mjs";
|
|
6
|
+
import { CodecImpl, SAFE_INTEGER_BIGINT_RANGE, dateTimeStoredText, decimalTextBigintLiteral, decimalTextNumberLiteral, floatNumberLiteral, readJsonIntegerText, refuseJsonValue, renderTsLiteral } from "@prisma/orm-framework/components/codec";
|
|
8
7
|
import { sqlRawDataType } from "@prisma/orm-family-sql/contract/data-type";
|
|
8
|
+
import { isDecimalText, printedDecimalText } from "@prisma/orm-framework/type-implementations/decimal";
|
|
9
|
+
import { CastExpr, FunctionCallExpr, SqlCharCodec, SqlRawCodec, SqlVarcharCodec, sqlCharDescriptor, sqlRawDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
|
|
10
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
11
|
+
import { booleanFromInteger, integerFromBoolean } from "@prisma/orm-framework/type-implementations/boolean";
|
|
9
12
|
import { hasDigitsBelow, hasDigitsBelowAMillisecond, isValidDate } from "@prisma/orm-framework/type-implementations/date";
|
|
10
13
|
import { describeValue, temporalFromText, temporalToText, withoutUtcDesignator } from "@prisma/orm-framework/type-implementations/temporal-text";
|
|
14
|
+
import { findNonJsonValue } from "@prisma/orm-framework/type-implementations/json";
|
|
11
15
|
import { extractCodecLookup } from "@prisma/orm-framework/components/control";
|
|
12
16
|
import { buildCodecDescriptorRegistry } from "@prisma/orm-family-sql/relational-core/codec-descriptor-registry";
|
|
13
17
|
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/codecs.mjs
|
|
18
|
+
function booleanToWrite(value, ctx) {
|
|
19
|
+
if (typeof value === "boolean") return value;
|
|
20
|
+
throw errorColumnUnwritable({
|
|
21
|
+
codecId: MYSQL_BOOLEAN_CODEC_ID,
|
|
22
|
+
received: JSON.stringify(value) ?? String(value),
|
|
23
|
+
column: ctx.column,
|
|
24
|
+
holds: "true or false, stored as 1 or 0",
|
|
25
|
+
fix: "Write true or false."
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** A row carries the stored integer as decimal text, and an include's JSON as a number. */
|
|
29
|
+
var MysqlBooleanCodec = class extends CodecImpl {
|
|
30
|
+
async toWire(value, ctx) {
|
|
31
|
+
return integerFromBoolean(booleanToWrite(value, ctx));
|
|
32
|
+
}
|
|
33
|
+
async fromWire(wire, ctx) {
|
|
34
|
+
const value = booleanFromInteger(wire);
|
|
35
|
+
if (value !== void 0) return value;
|
|
36
|
+
throw errorColumnUnreadable({
|
|
37
|
+
codecId: MYSQL_BOOLEAN_CODEC_ID,
|
|
38
|
+
received: String(wire),
|
|
39
|
+
column: ctx.column,
|
|
40
|
+
notA: "0 or 1",
|
|
41
|
+
reads: "0 as false and 1 as true",
|
|
42
|
+
fix: "Rewrite the value as 0 or 1. MySQL and MariaDB store any tinyint in the column, but only 1 equals TRUE."
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
fromDataTypeValue(value) {
|
|
46
|
+
return value.value;
|
|
47
|
+
}
|
|
48
|
+
toDataTypeValue(input) {
|
|
49
|
+
return this.dataTypeValueOf(booleanToWrite(input, {}));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var MysqlBooleanDescriptor = class extends MysqlCodecDescriptor {
|
|
53
|
+
dataType = mysqlBoolean.id;
|
|
54
|
+
codecId = MYSQL_BOOLEAN_CODEC_ID;
|
|
55
|
+
traits = ["equality", "boolean"];
|
|
56
|
+
paramsSchema = void 0;
|
|
57
|
+
renderValueLiteral(value) {
|
|
58
|
+
return renderTsLiteral(value);
|
|
59
|
+
}
|
|
60
|
+
/** The stored integer as a JSON number, which the codec checks as it checks a row. */
|
|
61
|
+
jsonProjection(expression) {
|
|
62
|
+
return identityJsonProjection(expression);
|
|
63
|
+
}
|
|
64
|
+
factory() {
|
|
65
|
+
return () => new MysqlBooleanCodec(this, mysqlBoolean);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const mysqlBooleanDescriptor = new MysqlBooleanDescriptor();
|
|
14
69
|
function messageOf(cause) {
|
|
15
70
|
return cause instanceof Error ? cause.message : String(cause);
|
|
16
71
|
}
|
|
@@ -48,7 +103,7 @@ function storedTextFromWire(codecId, wire, stored) {
|
|
|
48
103
|
if (typeof wire !== "string") throw errorDateTimeUnreadable({
|
|
49
104
|
codecId,
|
|
50
105
|
value: String(wire),
|
|
51
|
-
detail: `
|
|
106
|
+
detail: `The database returned ${describeValue(wire)}, not text.`
|
|
52
107
|
});
|
|
53
108
|
try {
|
|
54
109
|
return stored(wire);
|
|
@@ -85,7 +140,7 @@ function storedTextOfTemporal(identity, value, stored) {
|
|
|
85
140
|
if (hasDigitsBelow(encoded.text, 6)) throw errorDateTimeUnwritable({
|
|
86
141
|
codecId: identity.codecId,
|
|
87
142
|
received: `the ${identity.temporalTag} ${encoded.text}`,
|
|
88
|
-
detail: "It has digits below a microsecond, and MySQL
|
|
143
|
+
detail: "It has digits below a microsecond, and MySQL and MariaDB hold microseconds at most. Round it first, as in value.round({ smallestUnit: 'microsecond', roundingMode: 'trunc' })."
|
|
89
144
|
});
|
|
90
145
|
return storedTextForWrite(identity.codecId, encoded.text, stored);
|
|
91
146
|
}
|
|
@@ -95,7 +150,7 @@ const WIRE_DATE_TIME = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2}(?:\.\d+)?)$/;
|
|
|
95
150
|
function dateOfWireText(codecId, wire) {
|
|
96
151
|
const match = WIRE_DATE_TIME.exec(wire);
|
|
97
152
|
const date = match === null ? void 0 : /* @__PURE__ */ new Date(`${match[1]}T${match[2]}Z`);
|
|
98
|
-
if (date === void 0 || !isValidDate(date)) throw mysqlError("RUNTIME.DECODE_FAILED", `${codecId} wire value must be a date and time as MySQL
|
|
153
|
+
if (date === void 0 || !isValidDate(date)) throw mysqlError("RUNTIME.DECODE_FAILED", `${codecId} wire value must be a date and time as MySQL and MariaDB print it`, { meta: {
|
|
99
154
|
codecId,
|
|
100
155
|
received: String(wire)
|
|
101
156
|
} });
|
|
@@ -472,7 +527,243 @@ var MysqlDurationStringDescriptor = class extends MysqlCodecDescriptor {
|
|
|
472
527
|
}
|
|
473
528
|
};
|
|
474
529
|
const mysqlDurationStringDescriptor = new MysqlDurationStringDescriptor();
|
|
530
|
+
/**
|
|
531
|
+
* `mysql/decimal@1`: an exact decimal number read as the text MySQL and MariaDB print for it, padded to the column's scale.
|
|
532
|
+
*
|
|
533
|
+
* Both servers compare a text parameter with a `decimal` column as a decimal only when the column stands alone beside `=`, `<` or `>`; inside `IN`, beside an expression, and in MariaDB's `BETWEEN`, they compare it as a double. So every parameter of this codec is cast to a `DECIMAL(65, s)` that holds every value of its column, which compares exactly in every form. The cast rounds text with more digits after the point than `s` and clamps text with more before it than `65 - s`, so the codec refuses to write such text.
|
|
534
|
+
*/
|
|
535
|
+
/** The digits before and after the point of the `DECIMAL(65, fraction)` a parameter of a column with `params` is cast to: 30 after the point, the most MySQL allows, unless the column needs more than 35 before it. Parameters without a precision are of no column, and are cast to the widest decimal, `DECIMAL(65,30)`. */
|
|
536
|
+
function decimalParameterDigits(params) {
|
|
537
|
+
const { precision: widest, scale: finest } = MYSQL_WIDEST_DECIMAL;
|
|
538
|
+
const column = mysqlDecimalColumnOfReference(params) ?? MYSQL_WIDEST_DECIMAL;
|
|
539
|
+
const fraction = Math.min(finest, widest - (column.precision - column.scale));
|
|
540
|
+
return {
|
|
541
|
+
integer: widest - fraction,
|
|
542
|
+
fraction
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
/** The type a parameter of a column with `params` is cast to. */
|
|
546
|
+
function decimalParameterType(params) {
|
|
547
|
+
return `DECIMAL(${MYSQL_WIDEST_DECIMAL.precision},${decimalParameterDigits(params).fraction})`;
|
|
548
|
+
}
|
|
549
|
+
const EXAMPLE = "decimal text, such as \"12.50\"";
|
|
550
|
+
function describeReceived$1(value) {
|
|
551
|
+
return typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
552
|
+
}
|
|
553
|
+
function digits(count) {
|
|
554
|
+
return `${count} ${count === 1 ? "digit" : "digits"}`;
|
|
555
|
+
}
|
|
556
|
+
/** The refusal of decimal text the parameter's cast would round or clamp: it says what the column holds and, separately, what can be sent for it. A value declared without a precision has no column, so it says what can be sent and how to send more: a prepared parameter declares its column's precision and scale, and raw SQL casts text itself. */
|
|
557
|
+
function errorDecimalUnsendable(received, params, ctx) {
|
|
558
|
+
const { integer, fraction } = decimalParameterDigits(params);
|
|
559
|
+
const sendable = `at most ${integer} digits before the point and ${fraction === 0 ? "none" : fraction} after it`;
|
|
560
|
+
const target = ctx.column === void 0 ? `a ${MYSQL_DECIMAL_CODEC_ID} value` : `column "${ctx.column.table}"."${ctx.column.name}"`;
|
|
561
|
+
const round = fraction === 0 ? `Round the value to a whole number of at most ${digits(integer)}` : `Round the value to at most ${digits(fraction)} after the point and keep at most ${digits(integer)} before it`;
|
|
562
|
+
const meta = {
|
|
563
|
+
codecId: MYSQL_DECIMAL_CODEC_ID,
|
|
564
|
+
...ctx.column === void 0 ? {} : {
|
|
565
|
+
table: ctx.column.table,
|
|
566
|
+
column: ctx.column.name
|
|
567
|
+
},
|
|
568
|
+
received: received.slice(0, 100)
|
|
569
|
+
};
|
|
570
|
+
const column = mysqlDecimalColumnOfReference(params);
|
|
571
|
+
if (column === void 0) return mysqlError("RUNTIME.ENCODE_FAILED", `Cannot write ${received} to ${target} declared without a precision: a value sent for it can have ${sendable}.`, {
|
|
572
|
+
fix: `${round}. In a prepared statement, declare the parameter with the precision and scale of the column it is compared with or written to, as in { codecId: '${MYSQL_DECIMAL_CODEC_ID}', typeParams: { precision: 65, scale: 0 } }. In raw SQL, pass the value as text without param() and cast it in the SQL to the type of the column it is compared with or written to, as in CAST(\${value} AS DECIMAL(65,0)) for a decimal(65,0) column.`,
|
|
573
|
+
meta
|
|
574
|
+
});
|
|
575
|
+
return mysqlError("RUNTIME.ENCODE_FAILED", `Cannot write ${received} to ${target}: a decimal(${column.precision},${column.scale}) column holds ${decimalColumnHolds(column)}, and a value sent for it can have ${sendable}.`, {
|
|
576
|
+
fix: `${round}.`,
|
|
577
|
+
meta
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
/** The text the codec sends for an application value: decimal text without leading zeros or a minus sign on zero, which the parameter's cast holds exactly. */
|
|
581
|
+
function parameterText(value, params, ctx) {
|
|
582
|
+
if (typeof value !== "string" || !isDecimalText(value)) throw errorColumnUnwritable({
|
|
583
|
+
codecId: MYSQL_DECIMAL_CODEC_ID,
|
|
584
|
+
received: describeReceived$1(value),
|
|
585
|
+
column: ctx.column,
|
|
586
|
+
holds: EXAMPLE,
|
|
587
|
+
fix: "Pass the value as decimal text: an optional minus sign, digits, and an optional point and digits after it, with no exponent."
|
|
588
|
+
});
|
|
589
|
+
const printed = printedDecimalText(value);
|
|
590
|
+
const digits = decimalTextDigits(printed);
|
|
591
|
+
const { integer, fraction } = decimalParameterDigits(params);
|
|
592
|
+
if (digits.integer > integer || digits.fraction > fraction) throw errorDecimalUnsendable(describeReceived$1(value), params, ctx);
|
|
593
|
+
return printed;
|
|
594
|
+
}
|
|
595
|
+
var MysqlDecimalCodec = class extends CodecImpl {
|
|
596
|
+
async toWire(value, ctx) {
|
|
597
|
+
return parameterText(value, this.dataTypeParams, ctx);
|
|
598
|
+
}
|
|
599
|
+
async fromWire(wire, ctx) {
|
|
600
|
+
if (typeof wire === "string" && isDecimalText(wire)) return wire;
|
|
601
|
+
throw errorColumnUnreadable({
|
|
602
|
+
codecId: MYSQL_DECIMAL_CODEC_ID,
|
|
603
|
+
received: describeReceived$1(wire),
|
|
604
|
+
column: ctx.column,
|
|
605
|
+
notA: "decimal text",
|
|
606
|
+
reads: EXAMPLE,
|
|
607
|
+
fix: "Read the column with a type that holds its value, or rewrite the row with a decimal number."
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
/** The value, refused unless the column holds it. A default is checked before the target writes the parameters the server gives a column written without them, so parameters without a precision are checked as the `decimal(10,0)` the server makes. */
|
|
611
|
+
fromDataTypeValue(value) {
|
|
612
|
+
return decimalTextInColumn(value.value, mysqlDecimalColumnAsCreated(this.dataTypeParams));
|
|
613
|
+
}
|
|
614
|
+
toDataTypeValue(input) {
|
|
615
|
+
return this.dataTypeValueOf(input);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
var MysqlDecimalDescriptor = class extends MysqlCodecDescriptor {
|
|
619
|
+
dataType = mysqlDecimal.id;
|
|
620
|
+
codecId = MYSQL_DECIMAL_CODEC_ID;
|
|
621
|
+
traits = [
|
|
622
|
+
"equality",
|
|
623
|
+
"order",
|
|
624
|
+
"numeric"
|
|
625
|
+
];
|
|
626
|
+
keepsWrittenForm = true;
|
|
627
|
+
paramsSchema = mysqlDecimalParams;
|
|
628
|
+
wrappedParameter(parameter, params) {
|
|
629
|
+
return CastExpr.as(parameter, decimalParameterType(params ?? {}));
|
|
630
|
+
}
|
|
631
|
+
/** The decimal text: a JSON number would lose every digit past a double's precision when the include is parsed. */
|
|
632
|
+
jsonProjection(expression) {
|
|
633
|
+
return CastExpr.as(expression, "CHAR");
|
|
634
|
+
}
|
|
635
|
+
factory(params) {
|
|
636
|
+
return () => new MysqlDecimalCodec(this, mysqlDecimal, params ?? {});
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
const mysqlDecimalDescriptor = new MysqlDecimalDescriptor();
|
|
640
|
+
function documentToWrite(value, ctx) {
|
|
641
|
+
const found = findNonJsonValue(value);
|
|
642
|
+
if (found === void 0) return value;
|
|
643
|
+
const path = found.path === "" ? "the root" : found.path;
|
|
644
|
+
const target = ctx.column === void 0 ? `a ${MYSQL_JSON_CODEC_ID} value` : `column "${ctx.column.table}"."${ctx.column.name}"`;
|
|
645
|
+
throw mysqlError("RUNTIME.ENCODE_FAILED", `Cannot write ${found.received} at ${path} to ${target}, which holds a JSON document.`, {
|
|
646
|
+
fix: "Pass a plain JSON value: objects, arrays, strings, finite numbers, booleans and null. Write a date as an ISO 8601 string, a bigint as a number or decimal text, and leave out a key whose value is undefined.",
|
|
647
|
+
meta: {
|
|
648
|
+
codecId: MYSQL_JSON_CODEC_ID,
|
|
649
|
+
...ctx.column === void 0 ? {} : {
|
|
650
|
+
table: ctx.column.table,
|
|
651
|
+
column: ctx.column.name
|
|
652
|
+
},
|
|
653
|
+
received: found.received,
|
|
654
|
+
valuePath: found.path
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
function documentOfText(text, ctx) {
|
|
659
|
+
try {
|
|
660
|
+
return blindCast(JSON.parse(text));
|
|
661
|
+
} catch {
|
|
662
|
+
throw errorColumnUnreadable({
|
|
663
|
+
codecId: MYSQL_JSON_CODEC_ID,
|
|
664
|
+
received: JSON.stringify(text),
|
|
665
|
+
column: ctx.column,
|
|
666
|
+
notA: "JSON text",
|
|
667
|
+
reads: "JSON text as the document it holds",
|
|
668
|
+
fix: "Rewrite the value as JSON text, or read the column as String(storage: text)."
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
var MysqlJsonCodec = class extends CodecImpl {
|
|
673
|
+
async toWire(value, ctx) {
|
|
674
|
+
return JSON.stringify(documentToWrite(value, ctx));
|
|
675
|
+
}
|
|
676
|
+
async fromWire(wire, ctx) {
|
|
677
|
+
return documentOfText(wire, ctx);
|
|
678
|
+
}
|
|
679
|
+
fromDataTypeValue(value) {
|
|
680
|
+
return value.value;
|
|
681
|
+
}
|
|
682
|
+
toDataTypeValue(input) {
|
|
683
|
+
return this.dataTypeValueOf(documentToWrite(input, {}));
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
var MysqlJsonDescriptor = class extends MysqlCodecDescriptor {
|
|
687
|
+
dataType = mysqlJson.id;
|
|
688
|
+
codecId = MYSQL_JSON_CODEC_ID;
|
|
689
|
+
traits = [];
|
|
690
|
+
paramsSchema = void 0;
|
|
691
|
+
/** The document's JSON text, which the codec reads as it reads a row. Nested as a document, a JSON string such as `"12"` would reach the codec as the text `12`, which it could not tell from a row's number. */
|
|
692
|
+
jsonProjection(expression) {
|
|
693
|
+
return CastExpr.as(expression, "CHAR");
|
|
694
|
+
}
|
|
695
|
+
factory() {
|
|
696
|
+
return () => new MysqlJsonCodec(this, mysqlJson);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
const mysqlJsonDescriptor = new MysqlJsonDescriptor();
|
|
700
|
+
/**
|
|
701
|
+
* `mysql/longblob@1`: bytes stored as `longblob`, read and written as a `Uint8Array`. A row carries the bytes. MySQL writes a blob into JSON as `"base64:type251:…"` and MariaDB as raw bytes, so an include projects the column as `TO_BASE64(v)`, which both servers write as plain base64 with a line break after every 76 characters, and the codec decodes it.
|
|
702
|
+
*/
|
|
703
|
+
const LINE_BREAKS = /\r?\n/g;
|
|
704
|
+
const BASE64_CHARACTERS = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
705
|
+
function isBase64(text) {
|
|
706
|
+
return text.length % 4 === 0 && BASE64_CHARACTERS.test(text);
|
|
707
|
+
}
|
|
708
|
+
function describeReceived(value) {
|
|
709
|
+
return typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
710
|
+
}
|
|
711
|
+
function bytesToWrite(value, ctx) {
|
|
712
|
+
if (value instanceof Uint8Array) return value;
|
|
713
|
+
throw errorColumnUnwritable({
|
|
714
|
+
codecId: MYSQL_LONGBLOB_CODEC_ID,
|
|
715
|
+
received: describeReceived(value),
|
|
716
|
+
column: ctx.column,
|
|
717
|
+
holds: "bytes, written as a Uint8Array",
|
|
718
|
+
fix: "Pass the bytes as a Uint8Array, such as new TextEncoder().encode(text) for the UTF-8 bytes of text."
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
/** A `Uint8Array` that is not a subclass such as Node's `Buffer`, over the same memory. */
|
|
722
|
+
function plainBytes(bytes) {
|
|
723
|
+
return bytes.constructor === Uint8Array ? bytes : new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
724
|
+
}
|
|
725
|
+
function bytesOfBase64(text, ctx) {
|
|
726
|
+
const base64 = text.replace(LINE_BREAKS, "");
|
|
727
|
+
if (isBase64(base64)) return plainBytes(Buffer.from(base64, "base64"));
|
|
728
|
+
throw errorColumnUnreadable({
|
|
729
|
+
codecId: MYSQL_LONGBLOB_CODEC_ID,
|
|
730
|
+
received: describeReceived(text),
|
|
731
|
+
column: ctx.column,
|
|
732
|
+
notA: "base64 text",
|
|
733
|
+
reads: "a row's bytes, and in an include the base64 text TO_BASE64 writes",
|
|
734
|
+
fix: "Read the column with its own query."
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
var MysqlLongblobCodec = class extends CodecImpl {
|
|
738
|
+
async toWire(value, ctx) {
|
|
739
|
+
return bytesToWrite(value, ctx);
|
|
740
|
+
}
|
|
741
|
+
async fromWire(wire, ctx) {
|
|
742
|
+
return wire instanceof Uint8Array ? plainBytes(wire) : bytesOfBase64(wire, ctx);
|
|
743
|
+
}
|
|
744
|
+
fromDataTypeValue(value) {
|
|
745
|
+
return plainBytes(Buffer.from(value.value, "hex"));
|
|
746
|
+
}
|
|
747
|
+
toDataTypeValue(input) {
|
|
748
|
+
return this.dataTypeValueOf(Buffer.from(bytesToWrite(input, {})).toString("hex").toUpperCase());
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
var MysqlLongblobDescriptor = class extends MysqlCodecDescriptor {
|
|
752
|
+
dataType = mysqlLongblob.id;
|
|
753
|
+
codecId = MYSQL_LONGBLOB_CODEC_ID;
|
|
754
|
+
traits = ["equality", "order"];
|
|
755
|
+
paramsSchema = void 0;
|
|
756
|
+
jsonProjection(expression) {
|
|
757
|
+
return FunctionCallExpr.of("TO_BASE64", [expression]);
|
|
758
|
+
}
|
|
759
|
+
factory() {
|
|
760
|
+
return () => new MysqlLongblobCodec(this, mysqlLongblob);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
const mysqlLongblobDescriptor = new MysqlLongblobDescriptor();
|
|
475
764
|
const DECIMAL_INTEGER = /^-?\d+$/;
|
|
765
|
+
/** A double as MySQL and MariaDB print it: `1.5`, `-2`, `9.007199254740992e15`. */
|
|
766
|
+
const DOUBLE_TEXT = /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;
|
|
476
767
|
const BIGINT_MIN = -(2n ** 63n);
|
|
477
768
|
const BIGINT_MAX = 2n ** 63n - 1n;
|
|
478
769
|
/** Projects a bigint as its decimal text: a JSON number past 2^53 would lose digits when JavaScript parses the include. */
|
|
@@ -504,7 +795,11 @@ const mysqlSqlVarcharDescriptor = mysqlCodec(sqlVarcharDescriptor, {
|
|
|
504
795
|
const mysqlSqlRawDescriptor = mysqlCodec(sqlRawDescriptor, {
|
|
505
796
|
dataType: sqlRawDataType,
|
|
506
797
|
jsonProjection: () => {
|
|
507
|
-
throw
|
|
798
|
+
throw mysqlError("RUNTIME.AST_UNSUPPORTED", "Reading a raw column inside an include is not yet supported on MySQL and MariaDB.", {
|
|
799
|
+
why: "An include reads its rows as JSON, and Prisma cannot yet write a raw column's value into that JSON on MySQL and MariaDB.",
|
|
800
|
+
fix: "Leave the raw column out of the include's select, and read it with its own query.",
|
|
801
|
+
meta: { feature: "Reading a raw column inside an include" }
|
|
802
|
+
});
|
|
508
803
|
},
|
|
509
804
|
factory: (descriptor, dataType, params) => () => new SqlRawCodec(descriptor, dataType, params)
|
|
510
805
|
});
|
|
@@ -619,6 +914,122 @@ var MysqlBigintDescriptor = class extends MysqlCodecDescriptor {
|
|
|
619
914
|
}
|
|
620
915
|
};
|
|
621
916
|
const mysqlBigintDescriptor = new MysqlBigintDescriptor();
|
|
917
|
+
const SAFE_INTEGER_FIX = "Read the column as BigInt, which reads a JavaScript bigint, or keep its values within ±(2^53 − 1).";
|
|
918
|
+
/** A value read without a column is an aggregate's result, an aggregate in an include, a computed projection or a raw query's column; the codec cannot tell which, so the fix names each. */
|
|
919
|
+
const SAFE_INTEGER_RESULT_FIX = "The value does not fit a JavaScript number. Use an aggregate's BigInt form, such as sumBigInt or countBigInt; for a column's value, such as its min or max, declare the field BigInt, or read it as mysql/bigint@1 in a raw query.";
|
|
920
|
+
function safeIntegerToWrite(value, ctx) {
|
|
921
|
+
if (typeof value === "number" && Number.isSafeInteger(value)) return value;
|
|
922
|
+
throw errorColumnUnwritable({
|
|
923
|
+
codecId: MYSQL_BIGINT_NUMBER_CODEC_ID,
|
|
924
|
+
received: String(value),
|
|
925
|
+
column: ctx.column,
|
|
926
|
+
holds: "integers read as JavaScript numbers, within ±(2^53 − 1)",
|
|
927
|
+
fix: SAFE_INTEGER_FIX
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
function unreadableSafeInteger(wire, ctx) {
|
|
931
|
+
throw errorColumnUnreadable({
|
|
932
|
+
codecId: MYSQL_BIGINT_NUMBER_CODEC_ID,
|
|
933
|
+
received: String(wire),
|
|
934
|
+
column: ctx.column,
|
|
935
|
+
notA: "an integer within the safe integer range",
|
|
936
|
+
reads: "a JavaScript number, an integer within ±(2^53 − 1)",
|
|
937
|
+
fix: ctx.column === void 0 ? SAFE_INTEGER_RESULT_FIX : SAFE_INTEGER_FIX
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
/** A MySQL `bigint`, or an integral `DECIMAL` such as a `SUM` of integers, as a JavaScript number. Both directions refuse a value outside ±(2^53 − 1) rather than round it, naming the column where the read knows it. A row and an include's JSON carry it as decimal text, so the range is checked before any digit is lost. */
|
|
941
|
+
var MysqlBigintNumberCodec = class extends CodecImpl {
|
|
942
|
+
async toWire(value, ctx) {
|
|
943
|
+
return safeIntegerToWrite(value, ctx);
|
|
944
|
+
}
|
|
945
|
+
async fromWire(wire, ctx) {
|
|
946
|
+
if (typeof wire === "number") return Number.isSafeInteger(wire) ? wire : unreadableSafeInteger(wire, ctx);
|
|
947
|
+
if (!DECIMAL_INTEGER.test(wire)) return unreadableSafeInteger(wire, ctx);
|
|
948
|
+
const value = BigInt(wire);
|
|
949
|
+
if (value < SAFE_INTEGER_BIGINT_RANGE.min || value > SAFE_INTEGER_BIGINT_RANGE.max) return unreadableSafeInteger(wire, ctx);
|
|
950
|
+
return Number(value);
|
|
951
|
+
}
|
|
952
|
+
fromDataTypeValue(value) {
|
|
953
|
+
return Number(readJsonIntegerText(MYSQL_BIGINT_NUMBER_CODEC_ID, value.value, SAFE_INTEGER_BIGINT_RANGE));
|
|
954
|
+
}
|
|
955
|
+
toDataTypeValue(input) {
|
|
956
|
+
return this.dataTypeValueOf(String(safeIntegerToWrite(input, {})));
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
var MysqlBigintNumberDescriptor = class extends MysqlCodecDescriptor {
|
|
960
|
+
dataType = mysqlBigint.id;
|
|
961
|
+
codecId = MYSQL_BIGINT_NUMBER_CODEC_ID;
|
|
962
|
+
traits = [
|
|
963
|
+
"equality",
|
|
964
|
+
"order",
|
|
965
|
+
"numeric"
|
|
966
|
+
];
|
|
967
|
+
paramsSchema = void 0;
|
|
968
|
+
renderValueLiteral(value) {
|
|
969
|
+
return decimalTextNumberLiteral(value);
|
|
970
|
+
}
|
|
971
|
+
jsonProjection(expression) {
|
|
972
|
+
return textJsonProjection(expression);
|
|
973
|
+
}
|
|
974
|
+
factory() {
|
|
975
|
+
return () => new MysqlBigintNumberCodec(this, mysqlBigint);
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
const mysqlBigintNumberDescriptor = new MysqlBigintNumberDescriptor();
|
|
979
|
+
function finiteDoubleToWrite(value, ctx) {
|
|
980
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
981
|
+
throw errorColumnUnwritable({
|
|
982
|
+
codecId: MYSQL_DOUBLE_CODEC_ID,
|
|
983
|
+
received: String(value),
|
|
984
|
+
column: ctx.column,
|
|
985
|
+
holds: "finite numbers only: MySQL and MariaDB store no NaN or infinity",
|
|
986
|
+
fix: "Write a finite number, or store NaN and infinity in another column, such as a nullable one left NULL."
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
/** A MySQL `double` as a JavaScript number. A row carries it as the text MySQL prints, `1.5` or `9.007199254740992e15`, and an include's JSON as a number. MySQL and MariaDB hold no NaN or infinity, so the codec refuses to write one. */
|
|
990
|
+
var MysqlDoubleCodec = class extends CodecImpl {
|
|
991
|
+
async toWire(value, ctx) {
|
|
992
|
+
return finiteDoubleToWrite(value, ctx);
|
|
993
|
+
}
|
|
994
|
+
async fromWire(wire, ctx) {
|
|
995
|
+
const value = typeof wire === "number" ? wire : DOUBLE_TEXT.test(wire) ? Number(wire) : NaN;
|
|
996
|
+
if (Number.isFinite(value)) return value;
|
|
997
|
+
throw errorColumnUnreadable({
|
|
998
|
+
codecId: MYSQL_DOUBLE_CODEC_ID,
|
|
999
|
+
received: typeof wire === "string" ? JSON.stringify(wire) : String(wire),
|
|
1000
|
+
column: ctx.column,
|
|
1001
|
+
notA: "a finite number",
|
|
1002
|
+
reads: "the text MySQL and MariaDB print for a double, such as 1.5 or 9.007199254740992e15",
|
|
1003
|
+
fix: "Read the column with a type that holds its value."
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
fromDataTypeValue(value) {
|
|
1007
|
+
return value.value;
|
|
1008
|
+
}
|
|
1009
|
+
toDataTypeValue(input) {
|
|
1010
|
+
return this.dataTypeValueOf(finiteDoubleToWrite(input, {}));
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
var MysqlDoubleDescriptor = class extends MysqlCodecDescriptor {
|
|
1014
|
+
dataType = mysqlDouble.id;
|
|
1015
|
+
codecId = MYSQL_DOUBLE_CODEC_ID;
|
|
1016
|
+
traits = [
|
|
1017
|
+
"equality",
|
|
1018
|
+
"order",
|
|
1019
|
+
"numeric"
|
|
1020
|
+
];
|
|
1021
|
+
paramsSchema = void 0;
|
|
1022
|
+
renderValueLiteral(value) {
|
|
1023
|
+
return floatNumberLiteral(value);
|
|
1024
|
+
}
|
|
1025
|
+
jsonProjection(expression) {
|
|
1026
|
+
return identityJsonProjection(expression);
|
|
1027
|
+
}
|
|
1028
|
+
factory() {
|
|
1029
|
+
return () => new MysqlDoubleCodec(this, mysqlDouble);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
const mysqlDoubleDescriptor = new MysqlDoubleDescriptor();
|
|
622
1033
|
/**
|
|
623
1034
|
* Reads the text MySQL sends for a `datetime` as the instant it names in UTC: the codec writes every value in UTC, so the column holds no time zone of its own.
|
|
624
1035
|
*/
|
|
@@ -701,6 +1112,12 @@ const codecDescriptors = [
|
|
|
701
1112
|
mysqlTextDescriptor,
|
|
702
1113
|
mysqlIntDescriptor,
|
|
703
1114
|
mysqlBigintDescriptor,
|
|
1115
|
+
mysqlBigintNumberDescriptor,
|
|
1116
|
+
mysqlDoubleDescriptor,
|
|
1117
|
+
mysqlDecimalDescriptor,
|
|
1118
|
+
mysqlBooleanDescriptor,
|
|
1119
|
+
mysqlLongblobDescriptor,
|
|
1120
|
+
mysqlJsonDescriptor,
|
|
704
1121
|
mysqlDatetimeDescriptor,
|
|
705
1122
|
mysqlDatetimeTemporalDescriptor,
|
|
706
1123
|
mysqlDatetimeStringDescriptor,
|
|
@@ -747,4 +1164,4 @@ function createMysqlBuiltinCodecLookup() {
|
|
|
747
1164
|
//#endregion
|
|
748
1165
|
export { mysqlCodecDescriptorRegistry as a, encodeMysqlDatetime as i, createMysqlBuiltinCodecLookup as n, mysqlCodecRegistry as o, decodeMysqlDatetime as r, assembleMysqlCodecRegistry as t };
|
|
749
1166
|
|
|
750
|
-
//# sourceMappingURL=codecs-
|
|
1167
|
+
//# sourceMappingURL=codecs-DVX-3El1.mjs.map
|