@prisma/orm-target-mysql 8.0.0-rc.24-dev.28 → 8.0.0-rc.24-dev.30
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-CTfV1Zag.mjs → control-CZSBblPm.mjs} +26 -19
- package/dist/control-CZSBblPm.mjs.map +1 -0
- package/dist/{control-BiZaCqna.mjs → control-DDYbRiZF.mjs} +28 -13
- package/dist/control-DDYbRiZF.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-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-DB0w8R7i.mjs → runtime-GFrdQjfS.mjs} +66 -46
- package/dist/runtime-GFrdQjfS.mjs.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-TYj15jxs-CVLylCdl.mjs} +78 -72
- package/dist/statement-TYj15jxs-CVLylCdl.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 +16 -13
- 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,461 @@
|
|
|
1
|
+
import { l as mysqlError } from "./errors-CWtFTnst-xBLJ-9Lp.mjs";
|
|
2
|
+
import { r as quoteLiteral } from "./sql-utils-CveZhawQ-B2QmUlY0.mjs";
|
|
3
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
4
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
5
|
+
import { INT32_RANGE, INT64_RANGE, asFloat, asNumeralText, castUnchanged, dateTimeStoredText, decimalTextEqualityKey, readJsonBoolean, readJsonInteger, readJsonIntegerText, readJsonMatching, readJsonString, refuseJsonValue, refuseWrongShape } from "@prisma/orm-framework/components/codec";
|
|
6
|
+
import { sqlDataType, sqlRawDataType } from "@prisma/orm-family-sql/contract/data-type";
|
|
7
|
+
import { isDecimalText, printedDecimalText } from "@prisma/orm-framework/type-implementations/decimal";
|
|
8
|
+
import { ISO_DURATION_AS_WRITTEN } from "@prisma/orm-framework/type-implementations/duration";
|
|
9
|
+
import { type } from "arktype";
|
|
10
|
+
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/data-types-CU_43cNv.mjs
|
|
11
|
+
function integerParam(params, name) {
|
|
12
|
+
const value = params[name];
|
|
13
|
+
return typeof value === "number" ? value : void 0;
|
|
14
|
+
}
|
|
15
|
+
/** Text of at most `length` characters, counted as code points, as MySQL counts characters. */
|
|
16
|
+
function readTextOfLength(owner, json, length) {
|
|
17
|
+
const text = readJsonString(owner, json);
|
|
18
|
+
if (length !== void 0 && [...text].length > length) return refuseJsonValue(owner, `a string of at most ${length} ${length === 1 ? "character" : "characters"}`, json);
|
|
19
|
+
return json;
|
|
20
|
+
}
|
|
21
|
+
const mysqlText = sqlDataType("mysql/text", {
|
|
22
|
+
texts: [{
|
|
23
|
+
text: "text",
|
|
24
|
+
written: true,
|
|
25
|
+
catalog: true
|
|
26
|
+
}],
|
|
27
|
+
read: (json) => readJsonString("mysql/text", json),
|
|
28
|
+
casts: {}
|
|
29
|
+
});
|
|
30
|
+
const fromText = { [mysqlText.id]: castUnchanged };
|
|
31
|
+
/** A signed 32-bit integer, stored as a JSON number. */
|
|
32
|
+
const mysqlInt = sqlDataType("mysql/int", {
|
|
33
|
+
texts: [{
|
|
34
|
+
text: "int",
|
|
35
|
+
written: true,
|
|
36
|
+
catalog: true
|
|
37
|
+
}, { text: "integer" }],
|
|
38
|
+
read: (json) => readJsonInteger("mysql/int", json, INT32_RANGE),
|
|
39
|
+
casts: {}
|
|
40
|
+
});
|
|
41
|
+
/** A signed 64-bit integer, stored as digit text so that no digit is lost. */
|
|
42
|
+
const mysqlBigint = sqlDataType("mysql/bigint", {
|
|
43
|
+
texts: [{
|
|
44
|
+
text: "bigint",
|
|
45
|
+
written: true,
|
|
46
|
+
catalog: true
|
|
47
|
+
}],
|
|
48
|
+
read: (json) => {
|
|
49
|
+
readJsonIntegerText("mysql/bigint", json, INT64_RANGE);
|
|
50
|
+
return json;
|
|
51
|
+
},
|
|
52
|
+
casts: { [mysqlInt.id]: asNumeralText }
|
|
53
|
+
});
|
|
54
|
+
/** The widest `decimal` both servers hold: 65 digits, 30 of them after the point. MariaDB allows 38 after the point; MySQL allows 30. */
|
|
55
|
+
const MYSQL_WIDEST_DECIMAL = {
|
|
56
|
+
precision: 65,
|
|
57
|
+
scale: 30
|
|
58
|
+
};
|
|
59
|
+
/** The `decimal(10,0)` both servers make of a `decimal` written without a precision. */
|
|
60
|
+
const BARE_DECIMAL = {
|
|
61
|
+
precision: 10,
|
|
62
|
+
scale: 0
|
|
63
|
+
};
|
|
64
|
+
/** The precision and scale of `decimal`: at most 65 digits, at most 30 of them after the point. */
|
|
65
|
+
const mysqlDecimalParams = type({
|
|
66
|
+
"precision?": "number.integer >= 1 & number.integer <= 65",
|
|
67
|
+
"scale?": "number.integer >= 0 & number.integer <= 30"
|
|
68
|
+
}).narrow((params, ctx) => {
|
|
69
|
+
if (params.scale === void 0) return true;
|
|
70
|
+
if (params.precision === void 0) return ctx.reject({
|
|
71
|
+
path: ["scale"],
|
|
72
|
+
message: "scale requires a precision"
|
|
73
|
+
});
|
|
74
|
+
if (params.scale <= params.precision) return true;
|
|
75
|
+
const unwrittenScale = params.scale === MYSQL_WIDEST_DECIMAL.scale ? ` A scale left unwritten can default to ${MYSQL_WIDEST_DECIMAL.scale}.` : "";
|
|
76
|
+
return ctx.reject({
|
|
77
|
+
path: ["scale"],
|
|
78
|
+
message: `scale must be at most the precision: a scale of ${params.scale} is more than a precision of ${params.precision}. Write a scale of at most ${params.precision}, such as ${Math.min(2, params.precision)}, or a precision of at least ${params.scale}.${unwrittenScale}`
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
/** The digits before and after the point of decimal text, without leading zeros or trailing zeros after the point. */
|
|
82
|
+
function decimalTextDigits(text) {
|
|
83
|
+
const [whole = "", fraction = ""] = text.replace(/^-/, "").split(".");
|
|
84
|
+
return {
|
|
85
|
+
integer: whole.replace(/^0+/, "").length,
|
|
86
|
+
fraction: fraction.replace(/0+$/, "").length
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** The precision and scale of a column written with `params`, as the server makes it when the contract is built: a `decimal` without a precision is `decimal(10,0)`, and a precision written alone has a scale of 0. Code that reads a codec reference uses `mysqlDecimalColumnOfReference`. */
|
|
90
|
+
function mysqlDecimalColumnAsCreated(params) {
|
|
91
|
+
const precision = integerParam(params, "precision");
|
|
92
|
+
if (precision === void 0) return BARE_DECIMAL;
|
|
93
|
+
return {
|
|
94
|
+
precision,
|
|
95
|
+
scale: integerParam(params, "scale") ?? 0
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** The precision and scale of the column a decimal codec reference's `params` name, or `undefined` when they have no precision: a reference without a precision, such as a raw or prepared parameter's, belongs to no column. */
|
|
99
|
+
function mysqlDecimalColumnOfReference(params) {
|
|
100
|
+
return params["precision"] === void 0 ? void 0 : mysqlDecimalColumnAsCreated(params);
|
|
101
|
+
}
|
|
102
|
+
function counted(count, noun) {
|
|
103
|
+
return `${count} ${count === 1 ? noun : `${noun}s`}`;
|
|
104
|
+
}
|
|
105
|
+
/** What a `decimal(precision, scale)` column holds, in digits before and after the point. */
|
|
106
|
+
function decimalColumnHolds(column) {
|
|
107
|
+
const integer = column.precision - column.scale;
|
|
108
|
+
if (column.scale === 0) return `a whole number of at most ${counted(integer, "digit")}`;
|
|
109
|
+
return `${integer === 0 ? "no digits" : `at most ${counted(integer, "digit")}`} before the point and ${column.scale} after it`;
|
|
110
|
+
}
|
|
111
|
+
/** `text`, which is decimal text, when a `decimal(precision, scale)` column holds it without rounding; otherwise refuses it, saying what the column holds and what to change. */
|
|
112
|
+
function decimalTextInColumn(text, column) {
|
|
113
|
+
const digits = decimalTextDigits(text);
|
|
114
|
+
const integer = column.precision - column.scale;
|
|
115
|
+
if (digits.integer <= integer && digits.fraction <= column.scale) return text;
|
|
116
|
+
const change = digits.fraction > column.scale ? `${text} has ${counted(digits.fraction, "digit")} after the point: round it to ${column.scale === 0 ? "a whole number" : `at most ${counted(column.scale, "digit")} after the point`}` : `${text} has ${counted(digits.integer, "digit")} before the point: keep it ${integer === 0 ? "between -1 and 1" : `to at most ${counted(integer, "digit")} before the point`}, or widen the column`;
|
|
117
|
+
return refuseJsonValue("mysql/decimal", `a number a decimal(${column.precision},${column.scale}) column holds without rounding: ${decimalColumnHolds(column)}. ${change}.`, text);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Reads decimal text under a column's `precision` and `scale`. Parameters without a precision are those of no column, so they hold any decimal: a written value is read first under no parameters, and then again under its column's. A column written without a precision is given the `decimal(10,0)` the server makes when the contract is built; until then its codec checks a default against that column.
|
|
121
|
+
*/
|
|
122
|
+
const readDecimal = (json, params) => {
|
|
123
|
+
if (typeof json !== "string" || !isDecimalText(json)) return refuseJsonValue("mysql/decimal", "decimal text, as in \"12.50\"", json);
|
|
124
|
+
const column = mysqlDecimalColumnOfReference(params);
|
|
125
|
+
return column === void 0 ? json : decimalTextInColumn(json, column);
|
|
126
|
+
};
|
|
127
|
+
/** A value of `decimal(precision, scale)` is written as MySQL and MariaDB print it: no leading zeros, no minus sign on zero, and exactly `scale` digits after the point. */
|
|
128
|
+
const spellDecimal = (json, params) => {
|
|
129
|
+
if (typeof json !== "string") return json;
|
|
130
|
+
const printed = printedDecimalText(json);
|
|
131
|
+
const column = mysqlDecimalColumnOfReference(params);
|
|
132
|
+
if (column === void 0) return printed;
|
|
133
|
+
const [whole = "", fraction = ""] = printed.split(".");
|
|
134
|
+
return printedDecimalText(column.scale === 0 ? whole : `${whole}.${fraction.slice(0, column.scale).padEnd(column.scale, "0")}`);
|
|
135
|
+
};
|
|
136
|
+
/** Decimal text as `mysql/decimal` stores it. Throws `CONTRACT.CAST_REFUSED` for text that is not a decimal. */
|
|
137
|
+
function mysqlDecimalText(text) {
|
|
138
|
+
if (isDecimalText(text)) return printedDecimalText(text);
|
|
139
|
+
throw structuredError("CONTRACT.CAST_REFUSED", `"${text}" is not a decimal number. Write decimal text, as in "12.50".`, {
|
|
140
|
+
why: "A Decimal field holds an exact decimal number, written as an optional minus sign, digits, and an optional point and digits after it.",
|
|
141
|
+
fix: "Write the value as decimal text, as in \"12.50\" or \"-3\"."
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* An exact decimal number, stored as its decimal text so that no digit is lost. A column holds at most `precision` digits, `scale` of them after the point; MySQL and MariaDB print every value with `scale` digits after the point, so `1.5` in a `decimal(10,2)` reads `1.50`, and the two are one value.
|
|
146
|
+
*/
|
|
147
|
+
const mysqlDecimal = sqlDataType("mysql/decimal", {
|
|
148
|
+
params: mysqlDecimalParams,
|
|
149
|
+
texts: [
|
|
150
|
+
{
|
|
151
|
+
text: "decimal",
|
|
152
|
+
written: true
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
text: "decimal({precision})",
|
|
156
|
+
written: true
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
text: "decimal({precision},{scale})",
|
|
160
|
+
written: true,
|
|
161
|
+
catalog: true
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
read: readDecimal,
|
|
165
|
+
spell: spellDecimal,
|
|
166
|
+
equalityKey: decimalTextEqualityKey,
|
|
167
|
+
normalize: (params) => mysqlDecimalColumnAsCreated(params),
|
|
168
|
+
casts: {
|
|
169
|
+
[mysqlText.id]: (value) => typeof value === "string" ? mysqlDecimalText(value) : refuseWrongShape(value, "text"),
|
|
170
|
+
[mysqlInt.id]: asNumeralText,
|
|
171
|
+
[mysqlBigint.id]: castUnchanged
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
/** A finite IEEE 754 double, stored as a JSON number: MySQL and MariaDB hold no NaN or infinity. */
|
|
175
|
+
const mysqlDouble = sqlDataType("mysql/double", {
|
|
176
|
+
texts: [{
|
|
177
|
+
text: "double",
|
|
178
|
+
written: true,
|
|
179
|
+
catalog: true
|
|
180
|
+
}],
|
|
181
|
+
read: (json) => typeof json === "number" && Number.isFinite(json) ? json : refuseJsonValue("mysql/double", "a finite number", json),
|
|
182
|
+
casts: {
|
|
183
|
+
[mysqlInt.id]: asFloat,
|
|
184
|
+
[mysqlBigint.id]: asFloat,
|
|
185
|
+
[mysqlDecimal.id]: asFloat
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
/** A boolean, stored as `tinyint(1)` holding 0 or 1, which is what MySQL's own `BOOL`, `TRUE` and `FALSE` are. It claims `tinyint(1)` only, so other `tinyint` widths stay free for an integer type. */
|
|
189
|
+
const mysqlBoolean = sqlDataType("mysql/boolean", {
|
|
190
|
+
texts: [{
|
|
191
|
+
text: "tinyint(1)",
|
|
192
|
+
written: true,
|
|
193
|
+
catalog: true
|
|
194
|
+
}],
|
|
195
|
+
read: (json) => readJsonBoolean("mysql/boolean", json),
|
|
196
|
+
casts: {}
|
|
197
|
+
});
|
|
198
|
+
const UPPERCASE_HEX = /^(?:[0-9A-F]{2})*$/;
|
|
199
|
+
const HEX_TEXT = /^(?:[0-9A-Fa-f]{2})*$/;
|
|
200
|
+
/** Bytes, stored as their upper-case hexadecimal text. */
|
|
201
|
+
const mysqlLongblob = sqlDataType("mysql/longblob", {
|
|
202
|
+
texts: [{
|
|
203
|
+
text: "longblob",
|
|
204
|
+
written: true,
|
|
205
|
+
catalog: true
|
|
206
|
+
}],
|
|
207
|
+
read: (json) => readJsonMatching("mysql/longblob", json, UPPERCASE_HEX, "upper-case hexadecimal text"),
|
|
208
|
+
casts: {}
|
|
209
|
+
});
|
|
210
|
+
/** The upper-case hex `mysql/longblob` stores for the hex text a `longblob` tag holds, `68656c6c6f`. Throws `CONTRACT.CAST_REFUSED` for text that is not hex. */
|
|
211
|
+
function mysqlLongblobFromHexText(text) {
|
|
212
|
+
if (HEX_TEXT.test(text)) return text.toUpperCase();
|
|
213
|
+
throw structuredError("CONTRACT.CAST_REFUSED", `"${text}" is not hex text: write two hexadecimal digits for each byte, as in longblob\`68656c6c6f\`.`, {
|
|
214
|
+
why: "A Bytes value is written as hex text, two hexadecimal digits for each byte.",
|
|
215
|
+
fix: "Write the bytes as hex text, as in longblob`68656c6c6f`."
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/** A JSON document, stored as the document itself. MariaDB names the column `longtext` with a `json_valid` check; its catalog reader reports that column as `json`. */
|
|
219
|
+
const mysqlJson = sqlDataType("mysql/json", {
|
|
220
|
+
texts: [{
|
|
221
|
+
text: "json",
|
|
222
|
+
written: true,
|
|
223
|
+
catalog: true
|
|
224
|
+
}],
|
|
225
|
+
read: (json) => json,
|
|
226
|
+
casts: {}
|
|
227
|
+
});
|
|
228
|
+
/** The length of `varchar`, which MySQL requires, up to the largest it accepts. */
|
|
229
|
+
const mysqlVarcharParams = type({ length: "number.integer >= 1 & number.integer <= 65535" });
|
|
230
|
+
const mysqlVarchar = sqlDataType("mysql/varchar", {
|
|
231
|
+
params: mysqlVarcharParams,
|
|
232
|
+
texts: [{
|
|
233
|
+
text: "varchar({length})",
|
|
234
|
+
written: true,
|
|
235
|
+
catalog: true
|
|
236
|
+
}],
|
|
237
|
+
read: (json, params) => readTextOfLength("mysql/varchar", json, integerParam(params, "length")),
|
|
238
|
+
casts: fromText
|
|
239
|
+
});
|
|
240
|
+
/** The length of `char`, at most 255; a bare `char` is `char(1)`. */
|
|
241
|
+
const mysqlCharParams = type({ "length?": "number.integer >= 1 & number.integer <= 255" });
|
|
242
|
+
const mysqlChar = sqlDataType("mysql/char", {
|
|
243
|
+
params: mysqlCharParams,
|
|
244
|
+
texts: [{
|
|
245
|
+
text: "char",
|
|
246
|
+
written: true
|
|
247
|
+
}, {
|
|
248
|
+
text: "char({length})",
|
|
249
|
+
written: true,
|
|
250
|
+
catalog: true
|
|
251
|
+
}],
|
|
252
|
+
read: (json, params) => readTextOfLength("mysql/char", json, integerParam(params, "length") ?? 1),
|
|
253
|
+
normalize: (params) => params.length === void 0 ? {
|
|
254
|
+
...params,
|
|
255
|
+
length: 1
|
|
256
|
+
} : params,
|
|
257
|
+
casts: fromText
|
|
258
|
+
});
|
|
259
|
+
/** The fractional-second precision of `datetime`, `timestamp` and `time`, 0 to 6; MySQL prints a precision of 0 as the bare type. */
|
|
260
|
+
const mysqlDatetimeParams = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
|
|
261
|
+
/** The years MySQL holds in a `datetime` and a `date`. */
|
|
262
|
+
const MYSQL_DATETIME_RANGE = {
|
|
263
|
+
earliest: "1000-01-01T00:00:00",
|
|
264
|
+
latest: "9999-12-31T23:59:59.999999"
|
|
265
|
+
};
|
|
266
|
+
/** The instants MySQL holds in a `timestamp`, in UTC. */
|
|
267
|
+
const MYSQL_TIMESTAMP_RANGE = {
|
|
268
|
+
earliest: "1970-01-01T00:00:01",
|
|
269
|
+
latest: "2038-01-19T03:14:07.999999"
|
|
270
|
+
};
|
|
271
|
+
const MYSQL_DATE_RANGE = {
|
|
272
|
+
earliest: "1000-01-01",
|
|
273
|
+
latest: "9999-12-31"
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* The value of `mysql/datetime`: a date and time without a time zone, ISO 8601 text with a `T` and no trailing zeros in the fraction, within MySQL's range. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.
|
|
277
|
+
*/
|
|
278
|
+
function mysqlDatetimeText(text) {
|
|
279
|
+
return dateTimeStoredText(text, {
|
|
280
|
+
shape: "dateTime",
|
|
281
|
+
ownerId: "mysql/datetime",
|
|
282
|
+
range: MYSQL_DATETIME_RANGE
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The value of `mysql/timestamp`: the UTC date and time of an instant from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999, in the form `mysql/datetime` stores. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.
|
|
287
|
+
*/
|
|
288
|
+
function mysqlTimestampText(text) {
|
|
289
|
+
return dateTimeStoredText(text, {
|
|
290
|
+
shape: "dateTime",
|
|
291
|
+
ownerId: "mysql/timestamp",
|
|
292
|
+
range: MYSQL_TIMESTAMP_RANGE
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/** The value of `mysql/date`: a calendar date as ISO 8601 text, `2024-02-29`, in the years 1000 to 9999. Throws `CONTRACT.CAST_REFUSED` for other text. */
|
|
296
|
+
function mysqlDateText(text) {
|
|
297
|
+
return dateTimeStoredText(text, {
|
|
298
|
+
shape: "date",
|
|
299
|
+
ownerId: "mysql/date",
|
|
300
|
+
range: MYSQL_DATE_RANGE
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The value of `mysql/time`: a time of day from 00:00:00 to 23:59:59.999999, ISO 8601 text with no trailing zeros in the fraction. MySQL's `time` also holds a negative time and hours past 23, which name no time of day, so they are refused. Throws `CONTRACT.CAST_REFUSED` for other text.
|
|
305
|
+
*/
|
|
306
|
+
function mysqlTimeText(text) {
|
|
307
|
+
return dateTimeStoredText(text, {
|
|
308
|
+
shape: "time",
|
|
309
|
+
ownerId: "mysql/time"
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/** The value of `mysql/duration`: an ISO 8601 duration, stored as written. Throws `CONTRACT.CAST_REFUSED` for other text. */
|
|
313
|
+
function mysqlDurationText(text) {
|
|
314
|
+
if (ISO_DURATION_AS_WRITTEN.test(text)) return text;
|
|
315
|
+
throw structuredError("CONTRACT.CAST_REFUSED", `mysql/duration cannot read "${text}". Write an ISO 8601 duration, as in "PT1H30M".`, {
|
|
316
|
+
why: "mysql/duration holds an ISO 8601 duration as Temporal.Duration writes it: an optional sign, P, then years, months, weeks and days, then T and hours, minutes and seconds. A sign on each component instead is read too.",
|
|
317
|
+
fix: "Write the duration in ISO 8601, as in \"P1Y2M3DT4H5M6.5S\"."
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/** What `stored` writes for `text`, or `undefined` when `stored` refuses it. */
|
|
321
|
+
function storedOrUndefined(stored, text) {
|
|
322
|
+
try {
|
|
323
|
+
return stored(text);
|
|
324
|
+
} catch {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function readStored(id, stored, expected) {
|
|
329
|
+
return (json) => typeof json === "string" && storedOrUndefined(stored, json) !== void 0 ? json : refuseJsonValue(id, expected, json);
|
|
330
|
+
}
|
|
331
|
+
function spellStored(stored) {
|
|
332
|
+
return (json) => typeof json === "string" ? storedOrUndefined(stored, json) ?? json : json;
|
|
333
|
+
}
|
|
334
|
+
const withoutZeroPrecision = ({ precision, ...rest }) => precision === 0 ? rest : {
|
|
335
|
+
...rest,
|
|
336
|
+
...ifDefined("precision", precision)
|
|
337
|
+
};
|
|
338
|
+
const mysqlDatetime = sqlDataType("mysql/datetime", {
|
|
339
|
+
params: mysqlDatetimeParams,
|
|
340
|
+
texts: [{
|
|
341
|
+
text: "datetime",
|
|
342
|
+
written: true,
|
|
343
|
+
catalog: true
|
|
344
|
+
}, {
|
|
345
|
+
text: "datetime({precision})",
|
|
346
|
+
written: true,
|
|
347
|
+
catalog: true
|
|
348
|
+
}],
|
|
349
|
+
read: readStored("mysql/datetime", mysqlDatetimeText, "ISO 8601 date and time text without a UTC offset, as in \"2024-01-01T00:00:00\""),
|
|
350
|
+
spell: spellStored(mysqlDatetimeText),
|
|
351
|
+
normalize: withoutZeroPrecision,
|
|
352
|
+
casts: {}
|
|
353
|
+
});
|
|
354
|
+
/** An instant from 1970 to 2038, which MySQL converts between the session's time zone and UTC; every session runs in UTC. */
|
|
355
|
+
const mysqlTimestamp = sqlDataType("mysql/timestamp", {
|
|
356
|
+
params: mysqlDatetimeParams,
|
|
357
|
+
texts: [{
|
|
358
|
+
text: "timestamp",
|
|
359
|
+
written: true,
|
|
360
|
+
catalog: true
|
|
361
|
+
}, {
|
|
362
|
+
text: "timestamp({precision})",
|
|
363
|
+
written: true,
|
|
364
|
+
catalog: true
|
|
365
|
+
}],
|
|
366
|
+
read: readStored("mysql/timestamp", mysqlTimestampText, "ISO 8601 date and time text in UTC without a UTC offset, from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999"),
|
|
367
|
+
spell: spellStored(mysqlTimestampText),
|
|
368
|
+
normalize: withoutZeroPrecision,
|
|
369
|
+
casts: {}
|
|
370
|
+
});
|
|
371
|
+
const mysqlDate = sqlDataType("mysql/date", {
|
|
372
|
+
texts: [{
|
|
373
|
+
text: "date",
|
|
374
|
+
written: true,
|
|
375
|
+
catalog: true
|
|
376
|
+
}],
|
|
377
|
+
read: readStored("mysql/date", mysqlDateText, "ISO 8601 date text, as in \"2024-02-29\""),
|
|
378
|
+
spell: spellStored(mysqlDateText),
|
|
379
|
+
casts: {}
|
|
380
|
+
});
|
|
381
|
+
const mysqlTime = sqlDataType("mysql/time", {
|
|
382
|
+
params: mysqlDatetimeParams,
|
|
383
|
+
texts: [{
|
|
384
|
+
text: "time",
|
|
385
|
+
written: true,
|
|
386
|
+
catalog: true
|
|
387
|
+
}, {
|
|
388
|
+
text: "time({precision})",
|
|
389
|
+
written: true,
|
|
390
|
+
catalog: true
|
|
391
|
+
}],
|
|
392
|
+
read: readStored("mysql/time", mysqlTimeText, "ISO 8601 time of day text from 00:00:00 to 23:59:59.999999, as in \"09:30:00\""),
|
|
393
|
+
spell: spellStored(mysqlTimeText),
|
|
394
|
+
normalize: withoutZeroPrecision,
|
|
395
|
+
casts: {}
|
|
396
|
+
});
|
|
397
|
+
/** The length of the `varchar` a duration column is stored in. A codec reference with none, as a raw parameter writes, reads and writes the same values. */
|
|
398
|
+
const mysqlDurationParams = type({ "length?": "number.integer >= 1 & number.integer <= 65535" });
|
|
399
|
+
/** A length of time, stored in a `varchar` column as the ISO 8601 duration it was written as, `PT1H30M`, so that MySQL can index it. MySQL has no interval type, and equal durations can be written differently, `P1D` and `PT24H`, so a duration keeps its spelling. ADR 315. */
|
|
400
|
+
const mysqlDuration = sqlDataType("mysql/duration", {
|
|
401
|
+
storedAs: mysqlVarchar.id,
|
|
402
|
+
read: readStored("mysql/duration", mysqlDurationText, "an ISO 8601 duration, as in \"PT1H30M\""),
|
|
403
|
+
casts: {}
|
|
404
|
+
});
|
|
405
|
+
/** The members of a native enum column, in the order they are declared. */
|
|
406
|
+
const mysqlEnumParams = type({ "values?": "string[]" });
|
|
407
|
+
/** `enum('A','B')`, the text MySQL's catalog prints for the column type, with each member a quoted literal. */
|
|
408
|
+
function renderMysqlEnumType(values) {
|
|
409
|
+
if (values === void 0 || values.length === 0) throw mysqlError("CONTRACT.TYPE_PARAMS_INVALID", "An enum column type on MySQL or MariaDB needs at least one member.", {
|
|
410
|
+
why: "A native enum column is written with its members, and this column has none.",
|
|
411
|
+
fix: "Type the column with a PSL enum or an enumType() that declares its members.",
|
|
412
|
+
meta: { dataType: "mysql/enum" }
|
|
413
|
+
});
|
|
414
|
+
return `enum(${values.map(quoteLiteral).join(",")})`;
|
|
415
|
+
}
|
|
416
|
+
const readEnumMember = (json, params) => {
|
|
417
|
+
const member = readJsonString("mysql/enum", json);
|
|
418
|
+
const values = params["values"];
|
|
419
|
+
if (Array.isArray(values) && !values.includes(member)) return refuseJsonValue("mysql/enum", `one of the members ${values.join(", ")}`, json);
|
|
420
|
+
return json;
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* A native MySQL enum. Its name is the catalog text `enum('A','B')`, so `db verify` compares the members and their order with what MySQL reports (ADR 273). A column's members are its value set's, written into its parameters by the target's namespace (see `mysql-database.ts`).
|
|
424
|
+
*/
|
|
425
|
+
const mysqlEnum = sqlDataType("mysql/enum", {
|
|
426
|
+
params: mysqlEnumParams,
|
|
427
|
+
nameIsCatalogText: true,
|
|
428
|
+
render: ({ values }) => renderMysqlEnumType(values),
|
|
429
|
+
read: readEnumMember,
|
|
430
|
+
casts: fromText
|
|
431
|
+
});
|
|
432
|
+
/** Every data type this target registers. */
|
|
433
|
+
const mysqlDataTypes = [
|
|
434
|
+
mysqlText,
|
|
435
|
+
mysqlInt,
|
|
436
|
+
mysqlBigint,
|
|
437
|
+
mysqlDecimal,
|
|
438
|
+
mysqlDouble,
|
|
439
|
+
mysqlBoolean,
|
|
440
|
+
mysqlLongblob,
|
|
441
|
+
mysqlJson,
|
|
442
|
+
mysqlVarchar,
|
|
443
|
+
mysqlChar,
|
|
444
|
+
mysqlDatetime,
|
|
445
|
+
mysqlTimestamp,
|
|
446
|
+
mysqlDate,
|
|
447
|
+
mysqlTime,
|
|
448
|
+
mysqlDuration,
|
|
449
|
+
mysqlEnum,
|
|
450
|
+
sqlRawDataType
|
|
451
|
+
];
|
|
452
|
+
/** MySQL's text data types, which a SQL discriminator column may have. */
|
|
453
|
+
const mysqlTextDataTypes = [
|
|
454
|
+
mysqlText.id,
|
|
455
|
+
mysqlVarchar.id,
|
|
456
|
+
mysqlChar.id
|
|
457
|
+
];
|
|
458
|
+
//#endregion
|
|
459
|
+
export { mysqlLongblob as A, renderMysqlEnumType as B, mysqlDuration as C, mysqlEnumParams as D, mysqlEnum as E, mysqlTimeText as F, mysqlTimestamp as I, mysqlTimestampText as L, mysqlText as M, mysqlTextDataTypes as N, mysqlInt as O, mysqlTime as P, mysqlVarchar as R, mysqlDouble as S, mysqlDurationText as T, mysqlDecimal as _, decimalTextDigits as a, mysqlDecimalParams as b, mysqlBoolean as c, mysqlDataTypes as d, mysqlDate as f, mysqlDatetimeText as g, mysqlDatetimeParams as h, decimalColumnHolds as i, mysqlLongblobFromHexText as j, mysqlJson as k, mysqlChar as l, mysqlDatetime as m, MYSQL_TIMESTAMP_RANGE as n, decimalTextInColumn as o, mysqlDateText as p, MYSQL_WIDEST_DECIMAL as r, mysqlBigint as s, MYSQL_DATETIME_RANGE as t, mysqlCharParams as u, mysqlDecimalColumnAsCreated as v, mysqlDurationParams as w, mysqlDecimalText as x, mysqlDecimalColumnOfReference as y, mysqlVarcharParams as z };
|
|
460
|
+
|
|
461
|
+
//# sourceMappingURL=data-types-CU_43cNv-CQ8eHx3H.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-types-CU_43cNv-CQ8eHx3H.mjs","names":[],"sources":["../../../../3-targets/mysql/1-mysql/1-target/dist/data-types-CU_43cNv.mjs"],"sourcesContent":["import { l as mysqlError } from \"./errors-CWtFTnst.mjs\";\nimport { r as quoteLiteral } from \"./sql-utils-CveZhawQ.mjs\";\nimport { INT32_RANGE, INT64_RANGE, asFloat, asNumeralText, castUnchanged, dateTimeStoredText, decimalTextEqualityKey, readJsonBoolean, readJsonInteger, readJsonIntegerText, readJsonMatching, readJsonString, refuseJsonValue, refuseWrongShape } from \"@internal/framework-components/codec\";\nimport { sqlDataType, sqlRawDataType } from \"@internal/sql-contract/data-type\";\nimport { isDecimalText, printedDecimalText } from \"@internal/type-implementations/decimal\";\nimport { ISO_DURATION_AS_WRITTEN } from \"@internal/type-implementations/duration\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { type } from \"arktype\";\n//#region src/core/data-types.ts\nfunction integerParam(params, name) {\n\tconst value = params[name];\n\treturn typeof value === \"number\" ? value : void 0;\n}\n/** Text of at most `length` characters, counted as code points, as MySQL counts characters. */\nfunction readTextOfLength(owner, json, length) {\n\tconst text = readJsonString(owner, json);\n\tif (length !== void 0 && [...text].length > length) return refuseJsonValue(owner, `a string of at most ${length} ${length === 1 ? \"character\" : \"characters\"}`, json);\n\treturn json;\n}\nconst mysqlText = sqlDataType(\"mysql/text\", {\n\ttexts: [{\n\t\ttext: \"text\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => readJsonString(\"mysql/text\", json),\n\tcasts: {}\n});\nconst fromText = { [mysqlText.id]: castUnchanged };\n/** A signed 32-bit integer, stored as a JSON number. */\nconst mysqlInt = sqlDataType(\"mysql/int\", {\n\ttexts: [{\n\t\ttext: \"int\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, { text: \"integer\" }],\n\tread: (json) => readJsonInteger(\"mysql/int\", json, INT32_RANGE),\n\tcasts: {}\n});\n/** A signed 64-bit integer, stored as digit text so that no digit is lost. */\nconst mysqlBigint = sqlDataType(\"mysql/bigint\", {\n\ttexts: [{\n\t\ttext: \"bigint\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => {\n\t\treadJsonIntegerText(\"mysql/bigint\", json, INT64_RANGE);\n\t\treturn json;\n\t},\n\tcasts: { [mysqlInt.id]: asNumeralText }\n});\n/** The widest `decimal` both servers hold: 65 digits, 30 of them after the point. MariaDB allows 38 after the point; MySQL allows 30. */\nconst MYSQL_WIDEST_DECIMAL = {\n\tprecision: 65,\n\tscale: 30\n};\n/** The `decimal(10,0)` both servers make of a `decimal` written without a precision. */\nconst BARE_DECIMAL = {\n\tprecision: 10,\n\tscale: 0\n};\n/** The precision and scale of `decimal`: at most 65 digits, at most 30 of them after the point. */\nconst mysqlDecimalParams = type({\n\t\"precision?\": \"number.integer >= 1 & number.integer <= 65\",\n\t\"scale?\": \"number.integer >= 0 & number.integer <= 30\"\n}).narrow((params, ctx) => {\n\tif (params.scale === void 0) return true;\n\tif (params.precision === void 0) return ctx.reject({\n\t\tpath: [\"scale\"],\n\t\tmessage: \"scale requires a precision\"\n\t});\n\tif (params.scale <= params.precision) return true;\n\tconst unwrittenScale = params.scale === MYSQL_WIDEST_DECIMAL.scale ? ` A scale left unwritten can default to ${MYSQL_WIDEST_DECIMAL.scale}.` : \"\";\n\treturn ctx.reject({\n\t\tpath: [\"scale\"],\n\t\tmessage: `scale must be at most the precision: a scale of ${params.scale} is more than a precision of ${params.precision}. Write a scale of at most ${params.precision}, such as ${Math.min(2, params.precision)}, or a precision of at least ${params.scale}.${unwrittenScale}`\n\t});\n});\n/** The digits before and after the point of decimal text, without leading zeros or trailing zeros after the point. */\nfunction decimalTextDigits(text) {\n\tconst [whole = \"\", fraction = \"\"] = text.replace(/^-/, \"\").split(\".\");\n\treturn {\n\t\tinteger: whole.replace(/^0+/, \"\").length,\n\t\tfraction: fraction.replace(/0+$/, \"\").length\n\t};\n}\n/** The precision and scale of a column written with `params`, as the server makes it when the contract is built: a `decimal` without a precision is `decimal(10,0)`, and a precision written alone has a scale of 0. Code that reads a codec reference uses `mysqlDecimalColumnOfReference`. */\nfunction mysqlDecimalColumnAsCreated(params) {\n\tconst precision = integerParam(params, \"precision\");\n\tif (precision === void 0) return BARE_DECIMAL;\n\treturn {\n\t\tprecision,\n\t\tscale: integerParam(params, \"scale\") ?? 0\n\t};\n}\n/** The precision and scale of the column a decimal codec reference's `params` name, or `undefined` when they have no precision: a reference without a precision, such as a raw or prepared parameter's, belongs to no column. */\nfunction mysqlDecimalColumnOfReference(params) {\n\treturn params[\"precision\"] === void 0 ? void 0 : mysqlDecimalColumnAsCreated(params);\n}\nfunction counted(count, noun) {\n\treturn `${count} ${count === 1 ? noun : `${noun}s`}`;\n}\n/** What a `decimal(precision, scale)` column holds, in digits before and after the point. */\nfunction decimalColumnHolds(column) {\n\tconst integer = column.precision - column.scale;\n\tif (column.scale === 0) return `a whole number of at most ${counted(integer, \"digit\")}`;\n\treturn `${integer === 0 ? \"no digits\" : `at most ${counted(integer, \"digit\")}`} before the point and ${column.scale} after it`;\n}\n/** `text`, which is decimal text, when a `decimal(precision, scale)` column holds it without rounding; otherwise refuses it, saying what the column holds and what to change. */\nfunction decimalTextInColumn(text, column) {\n\tconst digits = decimalTextDigits(text);\n\tconst integer = column.precision - column.scale;\n\tif (digits.integer <= integer && digits.fraction <= column.scale) return text;\n\tconst change = digits.fraction > column.scale ? `${text} has ${counted(digits.fraction, \"digit\")} after the point: round it to ${column.scale === 0 ? \"a whole number\" : `at most ${counted(column.scale, \"digit\")} after the point`}` : `${text} has ${counted(digits.integer, \"digit\")} before the point: keep it ${integer === 0 ? \"between -1 and 1\" : `to at most ${counted(integer, \"digit\")} before the point`}, or widen the column`;\n\treturn refuseJsonValue(\"mysql/decimal\", `a number a decimal(${column.precision},${column.scale}) column holds without rounding: ${decimalColumnHolds(column)}. ${change}.`, text);\n}\n/**\n* Reads decimal text under a column's `precision` and `scale`. Parameters without a precision are those of no column, so they hold any decimal: a written value is read first under no parameters, and then again under its column's. A column written without a precision is given the `decimal(10,0)` the server makes when the contract is built; until then its codec checks a default against that column.\n*/\nconst readDecimal = (json, params) => {\n\tif (typeof json !== \"string\" || !isDecimalText(json)) return refuseJsonValue(\"mysql/decimal\", \"decimal text, as in \\\"12.50\\\"\", json);\n\tconst column = mysqlDecimalColumnOfReference(params);\n\treturn column === void 0 ? json : decimalTextInColumn(json, column);\n};\n/** A value of `decimal(precision, scale)` is written as MySQL and MariaDB print it: no leading zeros, no minus sign on zero, and exactly `scale` digits after the point. */\nconst spellDecimal = (json, params) => {\n\tif (typeof json !== \"string\") return json;\n\tconst printed = printedDecimalText(json);\n\tconst column = mysqlDecimalColumnOfReference(params);\n\tif (column === void 0) return printed;\n\tconst [whole = \"\", fraction = \"\"] = printed.split(\".\");\n\treturn printedDecimalText(column.scale === 0 ? whole : `${whole}.${fraction.slice(0, column.scale).padEnd(column.scale, \"0\")}`);\n};\n/** Decimal text as `mysql/decimal` stores it. Throws `CONTRACT.CAST_REFUSED` for text that is not a decimal. */\nfunction mysqlDecimalText(text) {\n\tif (isDecimalText(text)) return printedDecimalText(text);\n\tthrow structuredError(\"CONTRACT.CAST_REFUSED\", `\"${text}\" is not a decimal number. Write decimal text, as in \"12.50\".`, {\n\t\twhy: \"A Decimal field holds an exact decimal number, written as an optional minus sign, digits, and an optional point and digits after it.\",\n\t\tfix: \"Write the value as decimal text, as in \\\"12.50\\\" or \\\"-3\\\".\"\n\t});\n}\n/**\n* An exact decimal number, stored as its decimal text so that no digit is lost. A column holds at most `precision` digits, `scale` of them after the point; MySQL and MariaDB print every value with `scale` digits after the point, so `1.5` in a `decimal(10,2)` reads `1.50`, and the two are one value.\n*/\nconst mysqlDecimal = sqlDataType(\"mysql/decimal\", {\n\tparams: mysqlDecimalParams,\n\ttexts: [\n\t\t{\n\t\t\ttext: \"decimal\",\n\t\t\twritten: true\n\t\t},\n\t\t{\n\t\t\ttext: \"decimal({precision})\",\n\t\t\twritten: true\n\t\t},\n\t\t{\n\t\t\ttext: \"decimal({precision},{scale})\",\n\t\t\twritten: true,\n\t\t\tcatalog: true\n\t\t}\n\t],\n\tread: readDecimal,\n\tspell: spellDecimal,\n\tequalityKey: decimalTextEqualityKey,\n\tnormalize: (params) => mysqlDecimalColumnAsCreated(params),\n\tcasts: {\n\t\t[mysqlText.id]: (value) => typeof value === \"string\" ? mysqlDecimalText(value) : refuseWrongShape(value, \"text\"),\n\t\t[mysqlInt.id]: asNumeralText,\n\t\t[mysqlBigint.id]: castUnchanged\n\t}\n});\n/** A finite IEEE 754 double, stored as a JSON number: MySQL and MariaDB hold no NaN or infinity. */\nconst mysqlDouble = sqlDataType(\"mysql/double\", {\n\ttexts: [{\n\t\ttext: \"double\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => typeof json === \"number\" && Number.isFinite(json) ? json : refuseJsonValue(\"mysql/double\", \"a finite number\", json),\n\tcasts: {\n\t\t[mysqlInt.id]: asFloat,\n\t\t[mysqlBigint.id]: asFloat,\n\t\t[mysqlDecimal.id]: asFloat\n\t}\n});\n/** A boolean, stored as `tinyint(1)` holding 0 or 1, which is what MySQL's own `BOOL`, `TRUE` and `FALSE` are. It claims `tinyint(1)` only, so other `tinyint` widths stay free for an integer type. */\nconst mysqlBoolean = sqlDataType(\"mysql/boolean\", {\n\ttexts: [{\n\t\ttext: \"tinyint(1)\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => readJsonBoolean(\"mysql/boolean\", json),\n\tcasts: {}\n});\nconst UPPERCASE_HEX = /^(?:[0-9A-F]{2})*$/;\nconst HEX_TEXT = /^(?:[0-9A-Fa-f]{2})*$/;\n/** Bytes, stored as their upper-case hexadecimal text. */\nconst mysqlLongblob = sqlDataType(\"mysql/longblob\", {\n\ttexts: [{\n\t\ttext: \"longblob\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => readJsonMatching(\"mysql/longblob\", json, UPPERCASE_HEX, \"upper-case hexadecimal text\"),\n\tcasts: {}\n});\n/** The upper-case hex `mysql/longblob` stores for the hex text a `longblob` tag holds, `68656c6c6f`. Throws `CONTRACT.CAST_REFUSED` for text that is not hex. */\nfunction mysqlLongblobFromHexText(text) {\n\tif (HEX_TEXT.test(text)) return text.toUpperCase();\n\tthrow structuredError(\"CONTRACT.CAST_REFUSED\", `\"${text}\" is not hex text: write two hexadecimal digits for each byte, as in longblob\\`68656c6c6f\\`.`, {\n\t\twhy: \"A Bytes value is written as hex text, two hexadecimal digits for each byte.\",\n\t\tfix: \"Write the bytes as hex text, as in longblob`68656c6c6f`.\"\n\t});\n}\n/** A JSON document, stored as the document itself. MariaDB names the column `longtext` with a `json_valid` check; its catalog reader reports that column as `json`. */\nconst mysqlJson = sqlDataType(\"mysql/json\", {\n\ttexts: [{\n\t\ttext: \"json\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => json,\n\tcasts: {}\n});\n/** The length of `varchar`, which MySQL requires, up to the largest it accepts. */\nconst mysqlVarcharParams = type({ length: \"number.integer >= 1 & number.integer <= 65535\" });\nconst mysqlVarchar = sqlDataType(\"mysql/varchar\", {\n\tparams: mysqlVarcharParams,\n\ttexts: [{\n\t\ttext: \"varchar({length})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json, params) => readTextOfLength(\"mysql/varchar\", json, integerParam(params, \"length\")),\n\tcasts: fromText\n});\n/** The length of `char`, at most 255; a bare `char` is `char(1)`. */\nconst mysqlCharParams = type({ \"length?\": \"number.integer >= 1 & number.integer <= 255\" });\nconst mysqlChar = sqlDataType(\"mysql/char\", {\n\tparams: mysqlCharParams,\n\ttexts: [{\n\t\ttext: \"char\",\n\t\twritten: true\n\t}, {\n\t\ttext: \"char({length})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json, params) => readTextOfLength(\"mysql/char\", json, integerParam(params, \"length\") ?? 1),\n\tnormalize: (params) => params.length === void 0 ? {\n\t\t...params,\n\t\tlength: 1\n\t} : params,\n\tcasts: fromText\n});\n/** The fractional-second precision of `datetime`, `timestamp` and `time`, 0 to 6; MySQL prints a precision of 0 as the bare type. */\nconst mysqlDatetimeParams = type({ \"precision?\": \"number.integer >= 0 & number.integer <= 6\" });\n/** The years MySQL holds in a `datetime` and a `date`. */\nconst MYSQL_DATETIME_RANGE = {\n\tearliest: \"1000-01-01T00:00:00\",\n\tlatest: \"9999-12-31T23:59:59.999999\"\n};\n/** The instants MySQL holds in a `timestamp`, in UTC. */\nconst MYSQL_TIMESTAMP_RANGE = {\n\tearliest: \"1970-01-01T00:00:01\",\n\tlatest: \"2038-01-19T03:14:07.999999\"\n};\nconst MYSQL_DATE_RANGE = {\n\tearliest: \"1000-01-01\",\n\tlatest: \"9999-12-31\"\n};\n/**\n* The value of `mysql/datetime`: a date and time without a time zone, ISO 8601 text with a `T` and no trailing zeros in the fraction, within MySQL's range. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.\n*/\nfunction mysqlDatetimeText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"dateTime\",\n\t\townerId: \"mysql/datetime\",\n\t\trange: MYSQL_DATETIME_RANGE\n\t});\n}\n/**\n* The value of `mysql/timestamp`: the UTC date and time of an instant from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999, in the form `mysql/datetime` stores. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.\n*/\nfunction mysqlTimestampText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"dateTime\",\n\t\townerId: \"mysql/timestamp\",\n\t\trange: MYSQL_TIMESTAMP_RANGE\n\t});\n}\n/** The value of `mysql/date`: a calendar date as ISO 8601 text, `2024-02-29`, in the years 1000 to 9999. Throws `CONTRACT.CAST_REFUSED` for other text. */\nfunction mysqlDateText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"date\",\n\t\townerId: \"mysql/date\",\n\t\trange: MYSQL_DATE_RANGE\n\t});\n}\n/**\n* The value of `mysql/time`: a time of day from 00:00:00 to 23:59:59.999999, ISO 8601 text with no trailing zeros in the fraction. MySQL's `time` also holds a negative time and hours past 23, which name no time of day, so they are refused. Throws `CONTRACT.CAST_REFUSED` for other text.\n*/\nfunction mysqlTimeText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"time\",\n\t\townerId: \"mysql/time\"\n\t});\n}\n/** The value of `mysql/duration`: an ISO 8601 duration, stored as written. Throws `CONTRACT.CAST_REFUSED` for other text. */\nfunction mysqlDurationText(text) {\n\tif (ISO_DURATION_AS_WRITTEN.test(text)) return text;\n\tthrow structuredError(\"CONTRACT.CAST_REFUSED\", `mysql/duration cannot read \"${text}\". Write an ISO 8601 duration, as in \"PT1H30M\".`, {\n\t\twhy: \"mysql/duration holds an ISO 8601 duration as Temporal.Duration writes it: an optional sign, P, then years, months, weeks and days, then T and hours, minutes and seconds. A sign on each component instead is read too.\",\n\t\tfix: \"Write the duration in ISO 8601, as in \\\"P1Y2M3DT4H5M6.5S\\\".\"\n\t});\n}\n/** What `stored` writes for `text`, or `undefined` when `stored` refuses it. */\nfunction storedOrUndefined(stored, text) {\n\ttry {\n\t\treturn stored(text);\n\t} catch {\n\t\treturn;\n\t}\n}\nfunction readStored(id, stored, expected) {\n\treturn (json) => typeof json === \"string\" && storedOrUndefined(stored, json) !== void 0 ? json : refuseJsonValue(id, expected, json);\n}\nfunction spellStored(stored) {\n\treturn (json) => typeof json === \"string\" ? storedOrUndefined(stored, json) ?? json : json;\n}\nconst withoutZeroPrecision = ({ precision, ...rest }) => precision === 0 ? rest : {\n\t...rest,\n\t...ifDefined(\"precision\", precision)\n};\nconst mysqlDatetime = sqlDataType(\"mysql/datetime\", {\n\tparams: mysqlDatetimeParams,\n\ttexts: [{\n\t\ttext: \"datetime\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, {\n\t\ttext: \"datetime({precision})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/datetime\", mysqlDatetimeText, \"ISO 8601 date and time text without a UTC offset, as in \\\"2024-01-01T00:00:00\\\"\"),\n\tspell: spellStored(mysqlDatetimeText),\n\tnormalize: withoutZeroPrecision,\n\tcasts: {}\n});\n/** An instant from 1970 to 2038, which MySQL converts between the session's time zone and UTC; every session runs in UTC. */\nconst mysqlTimestamp = sqlDataType(\"mysql/timestamp\", {\n\tparams: mysqlDatetimeParams,\n\ttexts: [{\n\t\ttext: \"timestamp\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, {\n\t\ttext: \"timestamp({precision})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/timestamp\", mysqlTimestampText, \"ISO 8601 date and time text in UTC without a UTC offset, from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999\"),\n\tspell: spellStored(mysqlTimestampText),\n\tnormalize: withoutZeroPrecision,\n\tcasts: {}\n});\nconst mysqlDate = sqlDataType(\"mysql/date\", {\n\ttexts: [{\n\t\ttext: \"date\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/date\", mysqlDateText, \"ISO 8601 date text, as in \\\"2024-02-29\\\"\"),\n\tspell: spellStored(mysqlDateText),\n\tcasts: {}\n});\nconst mysqlTime = sqlDataType(\"mysql/time\", {\n\tparams: mysqlDatetimeParams,\n\ttexts: [{\n\t\ttext: \"time\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, {\n\t\ttext: \"time({precision})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/time\", mysqlTimeText, \"ISO 8601 time of day text from 00:00:00 to 23:59:59.999999, as in \\\"09:30:00\\\"\"),\n\tspell: spellStored(mysqlTimeText),\n\tnormalize: withoutZeroPrecision,\n\tcasts: {}\n});\n/** The length of the `varchar` a duration column is stored in. A codec reference with none, as a raw parameter writes, reads and writes the same values. */\nconst mysqlDurationParams = type({ \"length?\": \"number.integer >= 1 & number.integer <= 65535\" });\n/** A length of time, stored in a `varchar` column as the ISO 8601 duration it was written as, `PT1H30M`, so that MySQL can index it. MySQL has no interval type, and equal durations can be written differently, `P1D` and `PT24H`, so a duration keeps its spelling. ADR 315. */\nconst mysqlDuration = sqlDataType(\"mysql/duration\", {\n\tstoredAs: mysqlVarchar.id,\n\tread: readStored(\"mysql/duration\", mysqlDurationText, \"an ISO 8601 duration, as in \\\"PT1H30M\\\"\"),\n\tcasts: {}\n});\n/** The members of a native enum column, in the order they are declared. */\nconst mysqlEnumParams = type({ \"values?\": \"string[]\" });\n/** `enum('A','B')`, the text MySQL's catalog prints for the column type, with each member a quoted literal. */\nfunction renderMysqlEnumType(values) {\n\tif (values === void 0 || values.length === 0) throw mysqlError(\"CONTRACT.TYPE_PARAMS_INVALID\", \"An enum column type on MySQL or MariaDB needs at least one member.\", {\n\t\twhy: \"A native enum column is written with its members, and this column has none.\",\n\t\tfix: \"Type the column with a PSL enum or an enumType() that declares its members.\",\n\t\tmeta: { dataType: \"mysql/enum\" }\n\t});\n\treturn `enum(${values.map(quoteLiteral).join(\",\")})`;\n}\nconst readEnumMember = (json, params) => {\n\tconst member = readJsonString(\"mysql/enum\", json);\n\tconst values = params[\"values\"];\n\tif (Array.isArray(values) && !values.includes(member)) return refuseJsonValue(\"mysql/enum\", `one of the members ${values.join(\", \")}`, json);\n\treturn json;\n};\n/**\n* A native MySQL enum. Its name is the catalog text `enum('A','B')`, so `db verify` compares the members and their order with what MySQL reports (ADR 273). A column's members are its value set's, written into its parameters by the target's namespace (see `mysql-database.ts`).\n*/\nconst mysqlEnum = sqlDataType(\"mysql/enum\", {\n\tparams: mysqlEnumParams,\n\tnameIsCatalogText: true,\n\trender: ({ values }) => renderMysqlEnumType(values),\n\tread: readEnumMember,\n\tcasts: fromText\n});\n/** Every data type this target registers. */\nconst mysqlDataTypes = [\n\tmysqlText,\n\tmysqlInt,\n\tmysqlBigint,\n\tmysqlDecimal,\n\tmysqlDouble,\n\tmysqlBoolean,\n\tmysqlLongblob,\n\tmysqlJson,\n\tmysqlVarchar,\n\tmysqlChar,\n\tmysqlDatetime,\n\tmysqlTimestamp,\n\tmysqlDate,\n\tmysqlTime,\n\tmysqlDuration,\n\tmysqlEnum,\n\tsqlRawDataType\n];\n/** MySQL's text data types, which a SQL discriminator column may have. */\nconst mysqlTextDataTypes = [\n\tmysqlText.id,\n\tmysqlVarchar.id,\n\tmysqlChar.id\n];\n//#endregion\nexport { mysqlLongblob as A, renderMysqlEnumType as B, mysqlDuration as C, mysqlEnumParams as D, mysqlEnum as E, mysqlTimeText as F, mysqlTimestamp as I, mysqlTimestampText as L, mysqlText as M, mysqlTextDataTypes as N, mysqlInt as O, mysqlTime as P, mysqlVarchar as R, mysqlDouble as S, mysqlDurationText as T, mysqlDecimal as _, decimalTextDigits as a, mysqlDecimalParams as b, mysqlBoolean as c, mysqlDataTypes as d, mysqlDate as f, mysqlDatetimeText as g, mysqlDatetimeParams as h, decimalColumnHolds as i, mysqlLongblobFromHexText as j, mysqlJson as k, mysqlChar as l, mysqlDatetime as m, MYSQL_TIMESTAMP_RANGE as n, decimalTextInColumn as o, mysqlDateText as p, MYSQL_WIDEST_DECIMAL as r, mysqlBigint as s, MYSQL_DATETIME_RANGE as t, mysqlCharParams as u, mysqlDecimalColumnAsCreated as v, mysqlDurationParams as w, mysqlDecimalText as x, mysqlDecimalColumnOfReference as y, mysqlVarcharParams as z };\n\n//# sourceMappingURL=data-types-CU_43cNv.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,aAAa,QAAQ,MAAM;CACnC,MAAM,QAAQ,OAAO;CACrB,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAK;AACjD;;AAEA,SAAS,iBAAiB,OAAO,MAAM,QAAQ;CAC9C,MAAM,OAAO,eAAe,OAAO,IAAI;CACvC,IAAI,WAAW,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,SAAS,QAAQ,OAAO,gBAAgB,OAAO,uBAAuB,OAAO,GAAG,WAAW,IAAI,cAAc,gBAAgB,IAAI;CACpK,OAAO;AACR;AACA,MAAM,YAAY,YAAY,cAAc;CAC3C,OAAO,CAAC;EACP,MAAM;EACN,SAAS;EACT,SAAS;CACV,CAAC;CACD,OA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ACV,CAAC;CACD,MAAM,WAAW,cAAc,eAAe,gFAAgF;CAC9H,OAAO,YAAY,aAAa;CAChC,WAAW;CACX,OAAO,CAAC;AACT,CAAC;;AAED,MAAM,sBAAsB,KAAK,EAAE,WAAW,gDAAgD,CAAC;;AAE/F,MAAM,gBAAgB,YAAY,kBAAkB;CACnD,UAAU,aAAa;CACvB,MAAM,WAAW,kBAAkB,mBAAmB,yCAAyC;CAC/F,OAAO,CAAC;AACT,CAAC;;AAED,MAAM,kBAAkB,KAAK,EAAE,WAAW,WAAW,CAAC;;AAEtD,SAAS,oBAAoB,QAAQ;CACpC,IAAI,WAAW,KAAK,KAAK,OAAO,WAAW,GAAG,MAAM,WAAW,gCAAgC,sEAAsE;EACpK,KAAK;EACL,KAAK;EACL,MAAM,EAAE,UAAU,aAAa;CAChC,CAAC;CACD,OAAO,QAAQ,OAAO,IAAI,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE;AACnD;AACA,MAAM,kBAAkB,MAAM,WAAW;CACxC,MAAM,SAAS,eAAe,cAAc,IAAI;CAChD,MAAM,SAAS,OAAO;CACtB,IAAI,MAAM,QAAQ,MAAM,KAAK,CAAC,OAAO,SAAS,MAAM,GAAG,OAAO,gBAAgB,cAAc,sBAAsB,OAAO,KAAK,IAAI,KAAK,IAAI;CAC3I,OAAO;AACR;;;;AAIA,MAAM,YAAY,YAAY,cAAc;CAC3C,QAAQ;CACR,mBAAmB;CACnB,SAAS,EAAE,aAAa,oBAAoB,MAAM;CAClD,MAAM;CACN,OAAO;AACR,CAAC;;AAED,MAAM,iBAAiB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,qBAAqB;CAC1B,UAAU;CACV,aAAa;CACb,UAAU;AACX"}
|
|
@@ -1,11 +1,65 @@
|
|
|
1
|
-
import { DataType, DataTypeId } from "@prisma/orm-framework/components/codec";
|
|
2
|
-
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/data-types-
|
|
1
|
+
import { DataType, DataTypeId, DataTypeParams } from "@prisma/orm-framework/components/codec";
|
|
2
|
+
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/data-types-C_vInIbm.d.mts
|
|
3
3
|
//#region src/core/data-types.d.ts
|
|
4
4
|
declare const mysqlText: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
5
5
|
/** A signed 32-bit integer, stored as a JSON number. */
|
|
6
6
|
declare const mysqlInt: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
7
7
|
/** A signed 64-bit integer, stored as digit text so that no digit is lost. */
|
|
8
8
|
declare const mysqlBigint: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
9
|
+
/** The widest `decimal` both servers hold: 65 digits, 30 of them after the point. MariaDB allows 38 after the point; MySQL allows 30. */
|
|
10
|
+
declare const MYSQL_WIDEST_DECIMAL: {
|
|
11
|
+
readonly precision: 65;
|
|
12
|
+
readonly scale: 30;
|
|
13
|
+
};
|
|
14
|
+
/** The precision and scale of `decimal`: at most 65 digits, at most 30 of them after the point. */
|
|
15
|
+
declare const mysqlDecimalParams: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
16
|
+
precision?: number;
|
|
17
|
+
scale?: number;
|
|
18
|
+
}, {}>;
|
|
19
|
+
/** The digits before and after the point of decimal text, without leading zeros or trailing zeros after the point. */
|
|
20
|
+
declare function decimalTextDigits(text: string): {
|
|
21
|
+
readonly integer: number;
|
|
22
|
+
readonly fraction: number;
|
|
23
|
+
};
|
|
24
|
+
/** The precision and scale of a column written with `params`, as the server makes it when the contract is built: a `decimal` without a precision is `decimal(10,0)`, and a precision written alone has a scale of 0. Code that reads a codec reference uses `mysqlDecimalColumnOfReference`. */
|
|
25
|
+
declare function mysqlDecimalColumnAsCreated(params: DataTypeParams): {
|
|
26
|
+
readonly precision: number;
|
|
27
|
+
readonly scale: number;
|
|
28
|
+
};
|
|
29
|
+
/** The precision and scale of the column a decimal codec reference's `params` name, or `undefined` when they have no precision: a reference without a precision, such as a raw or prepared parameter's, belongs to no column. */
|
|
30
|
+
declare function mysqlDecimalColumnOfReference(params: DataTypeParams): {
|
|
31
|
+
readonly precision: number;
|
|
32
|
+
readonly scale: number;
|
|
33
|
+
} | undefined;
|
|
34
|
+
/** What a `decimal(precision, scale)` column holds, in digits before and after the point. */
|
|
35
|
+
declare function decimalColumnHolds(column: {
|
|
36
|
+
readonly precision: number;
|
|
37
|
+
readonly scale: number;
|
|
38
|
+
}): string;
|
|
39
|
+
/** `text`, which is decimal text, when a `decimal(precision, scale)` column holds it without rounding; otherwise refuses it, saying what the column holds and what to change. */
|
|
40
|
+
declare function decimalTextInColumn(text: string, column: {
|
|
41
|
+
readonly precision: number;
|
|
42
|
+
readonly scale: number;
|
|
43
|
+
}): string;
|
|
44
|
+
/** Decimal text as `mysql/decimal` stores it. Throws `CONTRACT.CAST_REFUSED` for text that is not a decimal. */
|
|
45
|
+
declare function mysqlDecimalText(text: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* An exact decimal number, stored as its decimal text so that no digit is lost. A column holds at most `precision` digits, `scale` of them after the point; MySQL and MariaDB print every value with `scale` digits after the point, so `1.5` in a `decimal(10,2)` reads `1.50`, and the two are one value.
|
|
48
|
+
*/
|
|
49
|
+
declare const mysqlDecimal: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<{
|
|
50
|
+
precision?: number;
|
|
51
|
+
scale?: number;
|
|
52
|
+
}>;
|
|
53
|
+
/** A finite IEEE 754 double, stored as a JSON number: MySQL and MariaDB hold no NaN or infinity. */
|
|
54
|
+
declare const mysqlDouble: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
55
|
+
/** A boolean, stored as `tinyint(1)` holding 0 or 1, which is what MySQL's own `BOOL`, `TRUE` and `FALSE` are. It claims `tinyint(1)` only, so other `tinyint` widths stay free for an integer type. */
|
|
56
|
+
declare const mysqlBoolean: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
57
|
+
/** Bytes, stored as their upper-case hexadecimal text. */
|
|
58
|
+
declare const mysqlLongblob: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
59
|
+
/** The upper-case hex `mysql/longblob` stores for the hex text a `longblob` tag holds, `68656c6c6f`. Throws `CONTRACT.CAST_REFUSED` for text that is not hex. */
|
|
60
|
+
declare function mysqlLongblobFromHexText(text: string): string;
|
|
61
|
+
/** A JSON document, stored as the document itself. MariaDB names the column `longtext` with a `json_valid` check; its catalog reader reports that column as `json`. */
|
|
62
|
+
declare const mysqlJson: import("@prisma/orm-family-sql/contract/data-type").SqlDataType<Readonly<Record<string, unknown>>>;
|
|
9
63
|
/** The length of `varchar`, which MySQL requires, up to the largest it accepts. */
|
|
10
64
|
declare const mysqlVarcharParams: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
11
65
|
length: number;
|
|
@@ -84,5 +138,5 @@ declare const mysqlDataTypes: readonly DataType[];
|
|
|
84
138
|
/** MySQL's text data types, which a SQL discriminator column may have. */
|
|
85
139
|
declare const mysqlTextDataTypes: readonly DataTypeId[];
|
|
86
140
|
//#endregion
|
|
87
|
-
export {
|
|
88
|
-
//# sourceMappingURL=data-types-
|
|
141
|
+
export { mysqlLongblob as A, renderMysqlEnumType as B, mysqlDuration as C, mysqlEnumParams as D, mysqlEnum as E, mysqlTimeText as F, mysqlTimestamp as I, mysqlTimestampText as L, mysqlText as M, mysqlTextDataTypes as N, mysqlInt as O, mysqlTime as P, mysqlVarchar as R, mysqlDouble as S, mysqlDurationText as T, mysqlDecimal as _, decimalTextDigits as a, mysqlDecimalParams as b, mysqlBoolean as c, mysqlDataTypes as d, mysqlDate as f, mysqlDatetimeText as g, mysqlDatetimeParams as h, decimalColumnHolds as i, mysqlLongblobFromHexText as j, mysqlJson as k, mysqlChar as l, mysqlDatetime as m, MYSQL_TIMESTAMP_RANGE as n, decimalTextInColumn as o, mysqlDateText as p, MYSQL_WIDEST_DECIMAL as r, mysqlBigint as s, MYSQL_DATETIME_RANGE as t, mysqlCharParams as u, mysqlDecimalColumnAsCreated as v, mysqlDurationParams as w, mysqlDecimalText as x, mysqlDecimalColumnOfReference as y, mysqlVarcharParams as z };
|
|
142
|
+
//# sourceMappingURL=data-types-C_vInIbm-Gt1XINav.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-types-C_vInIbm-Gt1XINav.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-mysql/1-target/dist/data-types-C_vInIbm.d.mts"],"mappings":";;;cAEc,sDAAsD,YAAY,SAAS;;cAE3E,qDAAqD,YAAY,SAAS;;cAE1E,wDAAwD,YAAY,SAAS;;cAE7E;WACH;WACA;;;cAGG,kEAAkE;EAC9E;EACA;;;iBAGe,kBAAkB;WACxB;WACA;;;iBAGM,4BAA4B,QAAQ;WAC1C;WACA;;;iBAGM,8BAA8B,QAAQ;WAC5C;WACA;;;iBAGM,mBAAmB;WACzB;WACA;;;iBAGM,oBAAoB,cAAc;WACxC;WACA;;;iBAGM,iBAAiB;;;;cAIpB,yDAAyD;EACrE;EACA;;;cAGY,wDAAwD,YAAY,SAAS;;cAE7E,yDAAyD,YAAY,SAAS;;cAE9E,0DAA0D,YAAY,SAAS;;iBAE5E,yBAAyB;;cAE5B,sDAAsD,YAAY,SAAS;;cAE3E,kEAAkE;EAC9E;;cAEY,yDAAyD;EACrE;;;cAGY,+DAA+D;EAC3E;;cAEY,sDAAsD;EAClE;;;cAGY,mEAAmE;EAC/E;;;cAGY;WACH;WACA;;;cAGG;WACH;WACA;;;;;iBAKM,kBAAkB;;;;iBAIlB,mBAAmB;;iBAEnB,cAAc;;;;iBAId,cAAc;;iBAEd,kBAAkB;cACrB,0DAA0D;EACtE;;;cAGY,2DAA2D;EACvE;;cAEY,sDAAsD,YAAY,SAAS;cAC3E,sDAAsD;EAClE;;;cAGY,mEAAmE;EAC/E;;;cAGY,0DAA0D,YAAY,SAAS;;cAE/E,+DAA+D;EAC3E;;;iBAGe,oBAAoB;;;;cAIvB,sDAAsD;EAClE;;;cAGY,yBAAyB;;cAEzB,6BAA6B"}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as requireTemporal } from "./require-temporal-DeDQhbTn-CdpjEWCB.mjs";
|
|
1
|
+
import { t as requireTemporal } from "./require-temporal-DDdrgVtL-VOKxTqhD.mjs";
|
|
3
2
|
import * as nowValues from "@prisma/orm-framework/type-implementations/now";
|
|
4
3
|
import { DATE_STRING_NOW_GENERATOR_ID, INSTANT_NOW_GENERATOR_ID, INSTANT_STRING_NOW_GENERATOR_ID, PLAIN_DATE_NOW_GENERATOR_ID, PLAIN_TIME_NOW_GENERATOR_ID, TIME_STRING_NOW_GENERATOR_ID, fractionDigitsOf } from "@prisma/orm-framework/type-implementations/now";
|
|
5
|
-
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/date-time-now-generators-
|
|
6
|
-
const mysqlTargetDescriptorMetaRuntime = {
|
|
7
|
-
kind: "target",
|
|
8
|
-
familyId: "sql",
|
|
9
|
-
targetId: "mysql",
|
|
10
|
-
id: "mysql",
|
|
11
|
-
version: "0.0.1",
|
|
12
|
-
capabilities: {},
|
|
13
|
-
dataTypes: mysqlDataTypes,
|
|
14
|
-
sessionSettings: { time_zone: "+00:00" }
|
|
15
|
-
};
|
|
4
|
+
//#region ../../../3-targets/mysql/1-mysql/1-target/dist/date-time-now-generators-Cx_aQTSw.mjs
|
|
16
5
|
/** The fraction digits of a bare `datetime`, `timestamp` or `time`. */
|
|
17
6
|
const BARE_TYPE_FRACTION_DIGITS = 0;
|
|
18
7
|
function fractionDigits(params) {
|
|
@@ -63,6 +52,6 @@ const mysqlNowGenerators = [
|
|
|
63
52
|
}
|
|
64
53
|
];
|
|
65
54
|
//#endregion
|
|
66
|
-
export {
|
|
55
|
+
export { mysqlNowGenerators as t };
|
|
67
56
|
|
|
68
|
-
//# sourceMappingURL=date-time-now-generators-
|
|
57
|
+
//# sourceMappingURL=date-time-now-generators-Cx_aQTSw-ay1tlvw6.mjs.map
|