@prisma/orm-target-sqlite 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-B8OOrks4-CpmcF003.mjs → adapter-B8OOrks4-BKzW_Yc4.mjs} +9 -9
- package/dist/{adapter-B8OOrks4-CpmcF003.mjs.map → adapter-B8OOrks4-BKzW_Yc4.mjs.map} +1 -1
- package/dist/{adapter-NFsNVlif.d.mts → adapter-DrTWv8F7.d.mts} +5 -5
- package/dist/{adapter-NFsNVlif.d.mts.map → adapter-DrTWv8F7.d.mts.map} +1 -1
- package/dist/{adapter-xFPDhkod-DB6XDGgl.d.mts → adapter-xFPDhkod-Bfb8AQQJ.d.mts} +3 -3
- package/dist/{adapter-xFPDhkod-DB6XDGgl.d.mts.map → adapter-xFPDhkod-Bfb8AQQJ.d.mts.map} +1 -1
- package/dist/adapter.d.mts +11 -11
- package/dist/adapter.mjs +7 -7
- package/dist/adapter__adapter.d.mts +2 -2
- package/dist/adapter__adapter.mjs +2 -2
- package/dist/adapter__codec-types.d.mts +3 -3
- package/dist/adapter__column-types.d.mts +2 -2
- package/dist/adapter__column-types.mjs +2 -2
- package/dist/adapter__control.d.mts +2 -2
- package/dist/adapter__control.mjs +5 -5
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.d.mts +1 -1
- package/dist/adapter__runtime.mjs +4 -4
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/adapter__sql-renderer.d.mts +2 -2
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/adapter__types.d.mts +2 -2
- package/dist/{aggregates--0FaH9Te.d.mts → aggregates-CA7Idm1d.d.mts} +4 -4
- package/dist/{aggregates--0FaH9Te.d.mts.map → aggregates-CA7Idm1d.d.mts.map} +1 -1
- package/dist/{aggregates-DMvLJFlR.mjs → aggregates-hLiHPHBG.mjs} +6 -7
- package/dist/aggregates-hLiHPHBG.mjs.map +1 -0
- package/dist/{codec-ids-BElbEYb_-CeWfv5bC.d.mts → codec-ids-CH8Nqk89-LNT9hksu.d.mts} +5 -3
- package/dist/codec-ids-CH8Nqk89-LNT9hksu.d.mts.map +1 -0
- package/dist/{codec-ids-BHBFCNsQ-C1Af_LGF.mjs → codec-ids-CTshXpbg-tcdbf_VC.mjs} +5 -3
- package/dist/codec-ids-CTshXpbg-tcdbf_VC.mjs.map +1 -0
- package/dist/codec-ids-Do7Ml2pg.d.mts +1 -0
- package/dist/codec-types-CBLOfyrr.d.mts +2 -0
- package/dist/codec-types-CcuzuROC.d.mts +1 -0
- package/dist/{codec-types-CGtSWeZ5-B5RH39BA.d.mts → codec-types-Ci-h2uxN-41PNpdNL.d.mts} +5 -3
- package/dist/codec-types-Ci-h2uxN-41PNpdNL.d.mts.map +1 -0
- package/dist/{codecs-izBhU4f1-uArTiOxL.mjs → codecs-CE5McdzP-CZ5F4Trz.mjs} +243 -116
- package/dist/codecs-CE5McdzP-CZ5F4Trz.mjs.map +1 -0
- package/dist/{codecs-A0DbaZRE-CMyLhO_K.d.mts → codecs-DBQsDiM--Cy-r45H3.d.mts} +58 -28
- package/dist/codecs-DBQsDiM--Cy-r45H3.d.mts.map +1 -0
- package/dist/codecs-Dou3fR1K.d.mts +1 -0
- package/dist/{codecs-B-paWXdt.mjs → codecs-EhvrdV8v.mjs} +2 -2
- package/dist/codecs-EhvrdV8v.mjs.map +1 -0
- package/dist/{column-types-bTPNfz46.d.mts → column-types-D3MMpY3X.d.mts} +13 -7
- package/dist/column-types-D3MMpY3X.d.mts.map +1 -0
- package/dist/column-types-D_PjRS6w.mjs +24 -0
- package/dist/column-types-D_PjRS6w.mjs.map +1 -0
- package/dist/{contract-contributions-CyHMdkva-2bg6kg_n.mjs → contract-contributions-CyHMdkva-BE5-kJj3.mjs} +2 -2
- package/dist/{contract-contributions-CyHMdkva-2bg6kg_n.mjs.map → contract-contributions-CyHMdkva-BE5-kJj3.mjs.map} +1 -1
- package/dist/{contract-free-DVGNrjWW.mjs → contract-free-CJlg0xGJ.mjs} +4 -4
- package/dist/{contract-free-DVGNrjWW.mjs.map → contract-free-CJlg0xGJ.mjs.map} +1 -1
- package/dist/{control-DGa_C2q6.d.mts → control-CtCvtwJx.d.mts} +183 -17
- package/dist/control-CtCvtwJx.d.mts.map +1 -0
- package/dist/{control-Dp-pU81N.d.mts → control-DfWteXy-.d.mts} +3 -3
- package/dist/{control-Dp-pU81N.d.mts.map → control-DfWteXy-.d.mts.map} +1 -1
- package/dist/{control-BvT30n3D.mjs → control-V3kPfMTR.mjs} +4 -3
- package/dist/control-V3kPfMTR.mjs.map +1 -0
- package/dist/{data-type-entries-B6YmbQDH-RnV5wVv8.mjs → data-type-entries-C0WkKiPF-CKPYj4OT.mjs} +20 -3
- package/dist/data-type-entries-C0WkKiPF-CKPYj4OT.mjs.map +1 -0
- package/dist/{data-types-CwpMoNK4.d.mts → data-types-C1nzwKt7.d.mts} +10 -2
- package/dist/{data-types-CwpMoNK4.d.mts.map → data-types-C1nzwKt7.d.mts.map} +1 -1
- package/dist/{data-types-fYwGTal5-BxuZD5EE.mjs → data-types-C_NKe4Ni-D7r8QkSb.mjs} +32 -4
- package/dist/data-types-C_NKe4Ni-D7r8QkSb.mjs.map +1 -0
- package/dist/{date-time-now-generators-BVQSg28x-DwhOJw5-.mjs → date-time-now-generators-DtRz9c2R-BkrBeLl2.mjs} +4 -4
- package/dist/{date-time-now-generators-BVQSg28x-DwhOJw5-.mjs.map → date-time-now-generators-DtRz9c2R-BkrBeLl2.mjs.map} +1 -1
- package/dist/{datetime-text-BogpvE70-VwTG2rUc.mjs → datetime-text-nkVy_w0q-DZnIEmgr.mjs} +3 -3
- package/dist/{datetime-text-BogpvE70-VwTG2rUc.mjs.map → datetime-text-nkVy_w0q-DZnIEmgr.mjs.map} +1 -1
- package/dist/{ddl-BvD-wVtg-BoEWa8CG.mjs → ddl-CgkyurGo-B2o4mSIT.mjs} +3 -3
- package/dist/{ddl-BvD-wVtg-BoEWa8CG.mjs.map → ddl-CgkyurGo-B2o4mSIT.mjs.map} +1 -1
- package/dist/{default-normalizer-BcGrp77x-CMWxtX1W.mjs → default-normalizer-Xsys5QJm-bPQiHGKp.mjs} +3 -3
- package/dist/{default-normalizer-BcGrp77x-CMWxtX1W.mjs.map → default-normalizer-Xsys5QJm-bPQiHGKp.mjs.map} +1 -1
- package/dist/{descriptor-meta-C2RNdGqi-BzR_I68E.mjs → descriptor-meta-BUMTRa-0-D2bfF0Yr.mjs} +5 -5
- package/dist/descriptor-meta-BUMTRa-0-D2bfF0Yr.mjs.map +1 -0
- package/dist/{descriptor-meta-Drr6Abaf-P67SenMd.mjs → descriptor-meta-CkiPlqDS-n3hDP01X.mjs} +23 -3
- package/dist/descriptor-meta-CkiPlqDS-n3hDP01X.mjs.map +1 -0
- package/dist/{descriptor-meta-CEjGA0WH-CxgiKj3V.mjs → descriptor-meta-uVTby90Y-CUfrzHVW.mjs} +152 -47
- package/dist/descriptor-meta-uVTby90Y-CUfrzHVW.mjs.map +1 -0
- package/dist/driver.mjs +1 -1
- package/dist/driver__control.mjs +1 -1
- package/dist/driver__runtime.mjs +9 -6
- package/dist/driver__runtime.mjs.map +1 -1
- package/dist/{errors-D9vZNPSI-DoNmdfv7.mjs → errors-DxbvEzQp-CeTjoGtL.mjs} +44 -3
- package/dist/errors-DxbvEzQp-CeTjoGtL.mjs.map +1 -0
- package/dist/{migration-C6RAZsCK.mjs → migration-BZoV6EvH.mjs} +2 -2
- package/dist/{migration-C6RAZsCK.mjs.map → migration-BZoV6EvH.mjs.map} +1 -1
- package/dist/{op-factory-call-B3oOyB-T-Bhg17pAj.mjs → op-factory-call-2IWWs4es-CajfeAMX.mjs} +19 -19
- package/dist/op-factory-call-2IWWs4es-CajfeAMX.mjs.map +1 -0
- package/dist/{pack-JeUy8ZB1.d.mts → pack-CHESErO8.d.mts} +183 -24
- package/dist/{pack-JeUy8ZB1.d.mts.map → pack-CHESErO8.d.mts.map} +1 -1
- package/dist/{planner-ccevdpwf.d.mts → planner-Bu5XBkHm.d.mts} +2 -2
- package/dist/{planner-ccevdpwf.d.mts.map → planner-Bu5XBkHm.d.mts.map} +1 -1
- package/dist/{planner-COl0BmJ_-SJuP-72Y.mjs → planner-gq4m2U9I-BBwAFGko.mjs} +8 -9
- package/dist/planner-gq4m2U9I-BBwAFGko.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-CE1q5Uqq-9kjqMR-1.mjs → planner-produced-sqlite-migration-BnKx1gAX-BZMX06Q-.mjs} +13 -23
- package/dist/planner-produced-sqlite-migration-BnKx1gAX-BZMX06Q-.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-BHH_ftCV-CndNmTrH.d.mts → planner-produced-sqlite-migration-CMjzJW5V-dVv0SjJm.d.mts} +3 -4
- package/dist/planner-produced-sqlite-migration-CMjzJW5V-dVv0SjJm.d.mts.map +1 -0
- package/dist/planner-produced-sqlite-migration-DtytlAAY.d.mts +1 -0
- package/dist/{render-ops-B2EHnXIQ-AspapEkF.mjs → render-ops-BdrBMvjY-CyVOYy9i.mjs} +4 -4
- package/dist/{render-ops-B2EHnXIQ-AspapEkF.mjs.map → render-ops-BdrBMvjY-CyVOYy9i.mjs.map} +1 -1
- package/dist/{require-temporal-qbyZfPgl-DGJhYwmE.mjs → require-temporal-CHWqSDF3-ElFTiAh6.mjs} +3 -3
- package/dist/{require-temporal-qbyZfPgl-DGJhYwmE.mjs.map → require-temporal-CHWqSDF3-ElFTiAh6.mjs.map} +1 -1
- package/dist/{runtime-H_OgXoaz.d.mts → runtime-CVBk_GlD.d.mts} +2 -2
- package/dist/{runtime-H_OgXoaz.d.mts.map → runtime-CVBk_GlD.d.mts.map} +1 -1
- package/dist/{runtime-DTjhSsHd.mjs → runtime-DQll1Swl.mjs} +2 -2
- package/dist/{runtime-DTjhSsHd.mjs.map → runtime-DQll1Swl.mjs.map} +1 -1
- package/dist/sql-renderer-DlZKtvVf.d.mts +1 -0
- package/dist/{sql-utils-C9blmi9x-B90QedVA.mjs → sql-utils-CHBxMmv--Dl7wl7n3.mjs} +3 -3
- package/dist/{sql-utils-C9blmi9x-B90QedVA.mjs.map → sql-utils-CHBxMmv--Dl7wl7n3.mjs.map} +1 -1
- package/dist/{sqlite-contract-view-B0oBTJQ0-DGNLlkLM.mjs → sqlite-contract-view-6qHjyMcG-BHZ8iO5v.mjs} +4 -4
- package/dist/{sqlite-contract-view-B0oBTJQ0-DGNLlkLM.mjs.map → sqlite-contract-view-6qHjyMcG-BHZ8iO5v.mjs.map} +1 -1
- package/dist/{sqlite-migration-DvNpo879-DcOagmQ1.mjs → sqlite-migration-1OBxvebH-BNjpjOW4.mjs} +13 -10
- package/dist/sqlite-migration-1OBxvebH-BNjpjOW4.mjs.map +1 -0
- package/dist/{sqlite-unbound-database-Df3Wf5ZA-B1QemRgb.mjs → sqlite-unbound-database-CfLXSiVo-Dy5VBXGz.mjs} +4 -4
- package/dist/{sqlite-unbound-database-Df3Wf5ZA-B1QemRgb.mjs.map → sqlite-unbound-database-CfLXSiVo-Dy5VBXGz.mjs.map} +1 -1
- package/dist/target.d.mts +14 -14
- package/dist/target.mjs +23 -23
- package/dist/target__aggregates.d.mts +1 -1
- package/dist/target__aggregates.mjs +1 -1
- package/dist/target__codec-ids.d.mts +3 -3
- package/dist/target__codec-ids.mjs +2 -2
- package/dist/target__codec-types.d.mts +3 -3
- package/dist/target__codecs.d.mts +3 -3
- package/dist/target__codecs.mjs +4 -4
- package/dist/target__contract-free.mjs +2 -2
- package/dist/target__control.d.mts +1 -1
- package/dist/target__control.mjs +8 -7
- package/dist/target__control.mjs.map +1 -1
- package/dist/target__data-types.d.mts +2 -2
- package/dist/target__data-types.mjs +3 -3
- package/dist/target__default-normalizer.mjs +1 -1
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.mjs +1 -1
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-produced-sqlite-migration.d.mts +2 -2
- package/dist/target__planner-produced-sqlite-migration.mjs +1 -1
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +1 -1
- package/dist/target__render-ops.mjs +1 -1
- package/dist/target__runtime.mjs +3 -3
- package/dist/target__sql-utils.mjs +1 -1
- package/dist/target__types.mjs +1 -1
- package/dist/{types-28E593y9.d.mts → types-CexPOm8x.d.mts} +1 -1
- package/package.json +12 -12
- package/dist/aggregates-DMvLJFlR.mjs.map +0 -1
- package/dist/codec-ids-9Fs9p6ST.d.mts +0 -1
- package/dist/codec-ids-BElbEYb_-CeWfv5bC.d.mts.map +0 -1
- package/dist/codec-ids-BHBFCNsQ-C1Af_LGF.mjs.map +0 -1
- package/dist/codec-types-CGtSWeZ5-B5RH39BA.d.mts.map +0 -1
- package/dist/codec-types-Dx9dQe-Y.d.mts +0 -1
- package/dist/codec-types-IproBv-Q.d.mts +0 -2
- package/dist/codecs-A0DbaZRE-CMyLhO_K.d.mts.map +0 -1
- package/dist/codecs-B-paWXdt.mjs.map +0 -1
- package/dist/codecs-CX5BZUdO.d.mts +0 -1
- package/dist/codecs-izBhU4f1-uArTiOxL.mjs.map +0 -1
- package/dist/column-types-bTPNfz46.d.mts.map +0 -1
- package/dist/column-types-toYbR7mn.mjs +0 -22
- package/dist/column-types-toYbR7mn.mjs.map +0 -1
- package/dist/control-BvT30n3D.mjs.map +0 -1
- package/dist/control-DGa_C2q6.d.mts.map +0 -1
- package/dist/data-type-entries-B6YmbQDH-RnV5wVv8.mjs.map +0 -1
- package/dist/data-types-fYwGTal5-BxuZD5EE.mjs.map +0 -1
- package/dist/descriptor-meta-C2RNdGqi-BzR_I68E.mjs.map +0 -1
- package/dist/descriptor-meta-CEjGA0WH-CxgiKj3V.mjs.map +0 -1
- package/dist/descriptor-meta-Drr6Abaf-P67SenMd.mjs.map +0 -1
- package/dist/errors-D9vZNPSI-DoNmdfv7.mjs.map +0 -1
- package/dist/op-factory-call-B3oOyB-T-Bhg17pAj.mjs.map +0 -1
- package/dist/planner-COl0BmJ_-SJuP-72Y.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-BHH_ftCV-CndNmTrH.d.mts.map +0 -1
- package/dist/planner-produced-sqlite-migration-CE1q5Uqq-9kjqMR-1.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-_n61WaiD.d.mts +0 -1
- package/dist/sql-renderer-_NdIrQuX.d.mts +0 -1
- package/dist/sqlite-migration-DvNpo879-DcOagmQ1.mjs.map +0 -1
|
@@ -1,15 +1,80 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { _ as SQLITE_TIME_TEMPORAL_CODEC_ID, a as SQLITE_DATETIME_CODEC_ID, c as SQLITE_DATE_STRING_CODEC_ID, d as SQLITE_DURATION_STRING_CODEC_ID, f as SQLITE_INTEGER_CODEC_ID, g as SQLITE_TIME_STRING_CODEC_ID, h as SQLITE_TEXT_CODEC_ID, i as SQLITE_BOOLEAN_CODEC_ID, l as SQLITE_DATE_TEMPORAL_CODEC_ID, m as SQLITE_REAL_CODEC_ID, n as SQLITE_BIGINT_NUMBER_CODEC_ID, o as SQLITE_DATETIME_STRING_CODEC_ID, p as SQLITE_JSON_CODEC_ID, r as SQLITE_BLOB_CODEC_ID, s as SQLITE_DATETIME_TEMPORAL_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQLITE_DECIMAL_CODEC_ID } from "./codec-ids-CTshXpbg-tcdbf_VC.mjs";
|
|
2
2
|
import { a as sqliteCodec, r as defineSqliteCodecs, t as SqliteCodecDescriptor } from "./codec-descriptor-DRmF-crq-BALI5Jtz.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { c as
|
|
5
|
-
import { t as requireTemporal } from "./require-temporal-
|
|
3
|
+
import { C as sqliteTimeText, S as sqliteTime, _ as sqliteInteger, b as sqliteText, c as sqliteDate, f as sqliteDatetimeTextAtMilliseconds, g as sqliteDurationText, h as sqliteDuration, i as sqliteCharacter, l as sqliteDateText, o as sqliteCharacterVarying, p as sqliteDecimal, r as sqliteBoolean, t as sqliteBlob, u as sqliteDatetime, v as sqliteJson, y as sqliteReal } from "./data-types-C_NKe4Ni-D7r8QkSb.mjs";
|
|
4
|
+
import { a as errorTemporalNonIsoCalendar, c as errorTemporalWrongType, l as sqliteError, n as errorDateTimeUnreadable, r as errorDateTimeUnwritable, t as errorColumnUnreadable } from "./errors-DxbvEzQp-CeTjoGtL.mjs";
|
|
5
|
+
import { t as requireTemporal } from "./require-temporal-CHWqSDF3-ElFTiAh6.mjs";
|
|
6
6
|
import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlRawCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlRawDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
|
|
7
7
|
import { CodecImpl, SAFE_INTEGER_BIGINT_RANGE, column, decimalTextBigintLiteral, decimalTextNumberLiteral, floatNumberLiteral, floatToJson, readJsonFloat, readJsonIntegerText, refuseJsonValue, renderTsLiteral } from "@prisma/orm-framework/components/codec";
|
|
8
8
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
9
9
|
import { sqlRawDataType } from "@prisma/orm-family-sql/contract/data-type";
|
|
10
10
|
import { hasDigitsBelowAMillisecond, isValidDate } from "@prisma/orm-framework/type-implementations/date";
|
|
11
|
+
import { isDecimalText, printedDecimalText } from "@prisma/orm-framework/type-implementations/decimal";
|
|
12
|
+
import { booleanFromInteger, integerFromBoolean } from "@prisma/orm-framework/type-implementations/boolean";
|
|
11
13
|
import { describeValue, temporalFromText, temporalToText } from "@prisma/orm-framework/type-implementations/temporal-text";
|
|
12
|
-
//#region ../../../3-targets/sqlite/1-target/dist/codecs-
|
|
14
|
+
//#region ../../../3-targets/sqlite/1-target/dist/codecs-CE5McdzP.mjs
|
|
15
|
+
/**
|
|
16
|
+
* Projects a blob as a one-element array of its hexadecimal text, and any other value as `otherwise` projects it.
|
|
17
|
+
*
|
|
18
|
+
* SQLite's JSON functions reject a BLOB argument outright, so the encoding has to replace the native conversion rather than post-process it. `hex()` emits uppercase and never wraps. The array is what tells a blob from text: outside a STRICT table a column of any type may hold a blob, and a BLOB column may hold text, which passes through as a row carries it. A codec that reads no bytes receives the array and refuses it, as it refuses the bytes a row carries.
|
|
19
|
+
*/
|
|
20
|
+
const hexJsonProjectionOr = (expression, otherwise) => CaseExpr.of([{
|
|
21
|
+
condition: BinaryExpr.eq(FunctionCallExpr.of("typeof", [expression]), LiteralExpr.of("blob")),
|
|
22
|
+
value: FunctionCallExpr.of("json_array", [FunctionCallExpr.of("hex", [expression])])
|
|
23
|
+
}], otherwise);
|
|
24
|
+
/** Projects a blob as the one-element array of its hexadecimal text, and any other value unchanged. */
|
|
25
|
+
const hexJsonProjection = (expression) => hexJsonProjectionOr(expression, expression);
|
|
26
|
+
function describeReceived$1(value) {
|
|
27
|
+
return typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
28
|
+
}
|
|
29
|
+
function requireBoolean(value) {
|
|
30
|
+
if (typeof value === "boolean") return value;
|
|
31
|
+
throw sqliteError("RUNTIME.ENCODE_FAILED", `${SQLITE_BOOLEAN_CODEC_ID} value must be a boolean, got ${describeReceived$1(value)}`, { meta: {
|
|
32
|
+
codecId: SQLITE_BOOLEAN_CODEC_ID,
|
|
33
|
+
received: String(value)
|
|
34
|
+
} });
|
|
35
|
+
}
|
|
36
|
+
/** A stored value that is neither 0 nor 1, named by its column where the read knows it. */
|
|
37
|
+
function errorBooleanUnreadable(wire, ctx) {
|
|
38
|
+
throw errorColumnUnreadable({
|
|
39
|
+
codecId: SQLITE_BOOLEAN_CODEC_ID,
|
|
40
|
+
received: wire,
|
|
41
|
+
column: ctx.column,
|
|
42
|
+
notA: "0 or 1",
|
|
43
|
+
reads: "0 as false and 1 as true"
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
var SqliteBooleanCodec = class extends CodecImpl {
|
|
47
|
+
async toWire(value, _ctx) {
|
|
48
|
+
return integerFromBoolean(requireBoolean(value));
|
|
49
|
+
}
|
|
50
|
+
async fromWire(wire, ctx) {
|
|
51
|
+
return booleanFromInteger(wire) ?? errorBooleanUnreadable(wire, ctx);
|
|
52
|
+
}
|
|
53
|
+
fromDataTypeValue(value) {
|
|
54
|
+
return value.value;
|
|
55
|
+
}
|
|
56
|
+
toDataTypeValue(input) {
|
|
57
|
+
return this.dataTypeValueOf(requireBoolean(input));
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var SqliteBooleanDescriptor = class extends SqliteCodecDescriptor {
|
|
61
|
+
jsonProjection(expression) {
|
|
62
|
+
return hexJsonProjection(expression);
|
|
63
|
+
}
|
|
64
|
+
dataType = sqliteBoolean.id;
|
|
65
|
+
codecId = SQLITE_BOOLEAN_CODEC_ID;
|
|
66
|
+
jsonType = "boolean";
|
|
67
|
+
traits = ["equality", "boolean"];
|
|
68
|
+
paramsSchema = void 0;
|
|
69
|
+
renderValueLiteral(value) {
|
|
70
|
+
return renderTsLiteral(value);
|
|
71
|
+
}
|
|
72
|
+
factory() {
|
|
73
|
+
return () => new SqliteBooleanCodec(this, sqliteBoolean);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const sqliteBooleanDescriptor = new SqliteBooleanDescriptor();
|
|
77
|
+
const sqliteBooleanColumn = () => column(sqliteBooleanDescriptor.factory(), sqliteBooleanDescriptor.codecId, void 0);
|
|
13
78
|
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
14
79
|
const DATE_TIME_WITHOUT_OFFSET = /^(\d{4}-\d{2}-\d{2})[Tt ](\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)$/;
|
|
15
80
|
/** A date alone as its midnight in UTC, and a date and time without an offset as UTC. */
|
|
@@ -22,7 +87,7 @@ function asUtcWhenUnmarked(text) {
|
|
|
22
87
|
* The instant SQLite holds for a row, in milliseconds since 1970, read as `Date` reads it, with text without a UTC offset read as UTC, as SQLite's own date and time functions read it, never in the machine's time zone. A number is milliseconds since 1970, as the Prisma ORM query engine wrote a `DateTime`. Digits below a millisecond are cut, as `Date` cuts them.
|
|
23
88
|
*/
|
|
24
89
|
function sqliteInstantMilliseconds(codecId, value) {
|
|
25
|
-
const milliseconds = new Date(typeof value === "number" ? value : asUtcWhenUnmarked(value)).getTime();
|
|
90
|
+
const milliseconds = typeof value === "bigint" ? NaN : new Date(typeof value === "number" ? value : asUtcWhenUnmarked(value)).getTime();
|
|
26
91
|
if (Number.isNaN(milliseconds)) throw sqliteError("RUNTIME.DECODE_FAILED", `${codecId} wire value must be a date and time as text, or a number of milliseconds since 1970: ${String(value)}`, { meta: {
|
|
27
92
|
codecId,
|
|
28
93
|
received: String(value)
|
|
@@ -336,6 +401,61 @@ var SqliteDurationStringDescriptor = class extends SqliteCodecDescriptor {
|
|
|
336
401
|
};
|
|
337
402
|
const sqliteDurationStringDescriptor = new SqliteDurationStringDescriptor();
|
|
338
403
|
const sqliteDurationStringColumn = () => column(sqliteDurationStringDescriptor.factory(), sqliteDurationStringDescriptor.codecId, void 0);
|
|
404
|
+
const EXPECTED = "decimal text, such as \"12.50\"";
|
|
405
|
+
function describeReceived(value) {
|
|
406
|
+
return typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
407
|
+
}
|
|
408
|
+
/** The decimal text the codec writes for an application value: the value without leading zeros or a minus sign on zero. */
|
|
409
|
+
function storedDecimalText(value) {
|
|
410
|
+
if (typeof value === "string" && isDecimalText(value)) return printedDecimalText(value);
|
|
411
|
+
throw sqliteError("RUNTIME.ENCODE_FAILED", `${SQLITE_DECIMAL_CODEC_ID} value must be ${EXPECTED}, got ${describeReceived(value)}`, { meta: {
|
|
412
|
+
codecId: SQLITE_DECIMAL_CODEC_ID,
|
|
413
|
+
received: String(value)
|
|
414
|
+
} });
|
|
415
|
+
}
|
|
416
|
+
/** A stored value the codec cannot read, such as the empty text an earlier fill wrote into a new column, named by its column where the read knows it. */
|
|
417
|
+
function errorDecimalUnreadable(wire, ctx) {
|
|
418
|
+
throw errorColumnUnreadable({
|
|
419
|
+
codecId: SQLITE_DECIMAL_CODEC_ID,
|
|
420
|
+
received: wire,
|
|
421
|
+
column: ctx.column,
|
|
422
|
+
notA: "decimal text",
|
|
423
|
+
reads: EXPECTED
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
var SqliteDecimalCodec = class extends CodecImpl {
|
|
427
|
+
async toWire(value, _ctx) {
|
|
428
|
+
return storedDecimalText(value);
|
|
429
|
+
}
|
|
430
|
+
async fromWire(wire, ctx) {
|
|
431
|
+
if (typeof wire === "string" && isDecimalText(wire)) return wire;
|
|
432
|
+
return errorDecimalUnreadable(wire, ctx);
|
|
433
|
+
}
|
|
434
|
+
fromDataTypeValue(value) {
|
|
435
|
+
return value.value;
|
|
436
|
+
}
|
|
437
|
+
toDataTypeValue(input) {
|
|
438
|
+
return this.dataTypeValueOf(storedDecimalText(input));
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
var SqliteDecimalDescriptor = class extends SqliteCodecDescriptor {
|
|
442
|
+
jsonProjection(expression) {
|
|
443
|
+
return hexJsonProjection(expression);
|
|
444
|
+
}
|
|
445
|
+
dataType = sqliteDecimal.id;
|
|
446
|
+
codecId = SQLITE_DECIMAL_CODEC_ID;
|
|
447
|
+
jsonType = "string";
|
|
448
|
+
traits = ["equality"];
|
|
449
|
+
paramsSchema = void 0;
|
|
450
|
+
renderValueLiteral(value) {
|
|
451
|
+
return renderTsLiteral(value);
|
|
452
|
+
}
|
|
453
|
+
factory() {
|
|
454
|
+
return () => new SqliteDecimalCodec(this, sqliteDecimal);
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const sqliteDecimalDescriptor = new SqliteDecimalDescriptor();
|
|
458
|
+
const sqliteDecimalColumn = () => column(sqliteDecimalDescriptor.factory(), sqliteDecimalDescriptor.codecId, void 0);
|
|
339
459
|
/**
|
|
340
460
|
* Projects the expression unchanged, for codecs whose canonical JSON is what
|
|
341
461
|
* SQLite's own JSON conversion already produces.
|
|
@@ -347,30 +467,19 @@ const sqliteDurationStringColumn = () => column(sqliteDurationStringDescriptor.f
|
|
|
347
467
|
*/
|
|
348
468
|
const identityJsonProjection = (expression) => expression;
|
|
349
469
|
/**
|
|
350
|
-
* Projects an integer
|
|
470
|
+
* Projects an integer as decimal text, a blob as the array of its hex text, and any other value as SQLite writes it in JSON, so a codec reads and refuses through an include what it reads and refuses in a row.
|
|
351
471
|
*
|
|
352
|
-
* The cast is part of the projected expression, so it applies before the JSON
|
|
353
|
-
* constructor sees the value: handed an INTEGER directly, the constructor emits
|
|
354
|
-
* a JSON number, and SQLite's 64-bit range does not survive being read back as
|
|
355
|
-
* a double. Casting the constructor's result would be too late.
|
|
472
|
+
* The cast is part of the projected expression, so it applies before the JSON constructor sees the value: handed an INTEGER directly, the constructor emits a JSON number, and SQLite's 64-bit range does not survive being read back as a double. Casting the constructor's result would be too late. A blob cast to text would read as the digits its bytes spell, and a REAL cast to text would read as text.
|
|
356
473
|
*/
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
* SQLite's JSON functions reject a BLOB argument outright, so the encoding has to replace the native
|
|
362
|
-
* conversion rather than post-process it. `hex()` emits uppercase and never wraps. The array is what
|
|
363
|
-
* tells a blob from text: outside a STRICT table a BLOB column may hold text, which passes through as
|
|
364
|
-
* text, as a row carries it, and so does NULL and any other value.
|
|
365
|
-
*/
|
|
366
|
-
const hexJsonProjection = (expression) => CaseExpr.of([{
|
|
367
|
-
condition: BinaryExpr.eq(FunctionCallExpr.of("typeof", [expression]), LiteralExpr.of("blob")),
|
|
368
|
-
value: FunctionCallExpr.of("json_array", [FunctionCallExpr.of("hex", [expression])])
|
|
369
|
-
}], expression);
|
|
474
|
+
const integerJsonProjection = (expression) => CaseExpr.of([{
|
|
475
|
+
condition: BinaryExpr.eq(FunctionCallExpr.of("typeof", [expression]), LiteralExpr.of("integer")),
|
|
476
|
+
value: CastExpr.as(expression, "TEXT")
|
|
477
|
+
}], hexJsonProjection(expression));
|
|
370
478
|
/**
|
|
371
479
|
* Projects a REAL as SQLite writes it in JSON, except an infinity, which SQLite writes as `9.0e+999` and which becomes the text `Infinity` or `-Infinity` that the codec stores. The test is equality with an infinity, so text or a blob that a REAL column holds outside a STRICT table passes through unchanged.
|
|
372
480
|
*/
|
|
373
|
-
const floatJsonProjection = (expression) =>
|
|
481
|
+
const floatJsonProjection = (expression) => hexJsonProjectionOr(expression, infinityAsTextJsonProjection(expression));
|
|
482
|
+
const infinityAsTextJsonProjection = (expression) => CaseExpr.of([{
|
|
374
483
|
condition: BinaryExpr.eq(expression, LiteralExpr.of(Number.POSITIVE_INFINITY)),
|
|
375
484
|
value: LiteralExpr.of("Infinity")
|
|
376
485
|
}, {
|
|
@@ -432,8 +541,8 @@ var SqliteFloatCodec = class extends SqlFloatCodec {
|
|
|
432
541
|
async toWire(value, ctx) {
|
|
433
542
|
return super.toWire(refuseNaN(this.id, value), ctx);
|
|
434
543
|
}
|
|
435
|
-
async fromWire(wire,
|
|
436
|
-
return floatWire(this.id, wire);
|
|
544
|
+
async fromWire(wire, ctx) {
|
|
545
|
+
return floatWire(this.id, wire, ctx);
|
|
437
546
|
}
|
|
438
547
|
fromDataTypeValue(value) {
|
|
439
548
|
return readJsonFloatWithoutNaN(this.id, value.value);
|
|
@@ -469,71 +578,87 @@ const requireJsType = (codecId, expected, value) => {
|
|
|
469
578
|
* value from it. A non-integral number is refused on the same terms.
|
|
470
579
|
*/
|
|
471
580
|
const bigintEncodeJson = (codecId, value) => {
|
|
472
|
-
if (typeof value !== "number")
|
|
473
|
-
requireJsType(codecId, "bigint", value);
|
|
474
|
-
return value.toString();
|
|
475
|
-
}
|
|
581
|
+
if (typeof value !== "number") return encodableInt64(codecId, value).toString();
|
|
476
582
|
if (!Number.isSafeInteger(value)) throw sqliteError("RUNTIME.ENCODE_FAILED", `${codecId} number literal must be an integer within the safe integer range, got ${String(value)}`, { meta: {
|
|
477
583
|
codecId,
|
|
478
584
|
received: String(value)
|
|
479
585
|
} });
|
|
480
586
|
return BigInt(value).toString();
|
|
481
587
|
};
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
*/
|
|
487
|
-
const
|
|
488
|
-
|
|
588
|
+
const INT64_RANGE$1 = {
|
|
589
|
+
min: -(2n ** 63n),
|
|
590
|
+
max: 2n ** 63n - 1n
|
|
591
|
+
};
|
|
592
|
+
/** The application value `sqlite/bigint@1` writes: a `bigint` within the signed 64-bit range an SQLite INTEGER holds. */
|
|
593
|
+
const encodableInt64 = (codecId, value) => {
|
|
594
|
+
requireJsType(codecId, "bigint", value);
|
|
595
|
+
if (value < INT64_RANGE$1.min || value > INT64_RANGE$1.max) throw sqliteError("RUNTIME.ENCODE_FAILED", `${codecId} value must be an integer from ${INT64_RANGE$1.min} to ${INT64_RANGE$1.max}, which SQLite stores, got ${value}`, { meta: {
|
|
489
596
|
codecId,
|
|
490
|
-
received:
|
|
597
|
+
received: value.toString()
|
|
491
598
|
} });
|
|
492
|
-
if (Object.is(value, -0)) return 0;
|
|
493
599
|
return value;
|
|
494
600
|
};
|
|
495
|
-
/** The application value a number-flavoured integer codec writes: the JS type it reads, within the range that type holds exactly. */
|
|
496
|
-
const encodableSafeInteger = (codecId, value) => {
|
|
497
|
-
requireJsType(codecId, "number", value);
|
|
498
|
-
return safeIntegerNumber(codecId, value, "RUNTIME.ENCODE_FAILED");
|
|
499
|
-
};
|
|
500
601
|
/**
|
|
501
|
-
*
|
|
502
|
-
* conversion so an out-of-range value throws rather than rounds.
|
|
602
|
+
* The application value a number-flavoured integer codec writes: the JS type it reads, an integer within ±(2^53 − 1), the range a `number` holds exactly. The guard throws rather than rounding: past the boundary a `number` silently loses digits, which is the failure mode these codecs exist to refuse.
|
|
503
603
|
*/
|
|
504
|
-
const
|
|
505
|
-
|
|
604
|
+
const encodableSafeInteger = (codecId, value) => {
|
|
605
|
+
requireJsType(codecId, "number", value);
|
|
606
|
+
if (!Number.isSafeInteger(value)) throw sqliteError("RUNTIME.ENCODE_FAILED", `${codecId} value must be an integer within the safe integer range, got ${String(value)}`, { meta: {
|
|
506
607
|
codecId,
|
|
507
|
-
received: value
|
|
608
|
+
received: String(value)
|
|
508
609
|
} });
|
|
509
|
-
return
|
|
610
|
+
return Object.is(value, -0) ? 0 : value;
|
|
510
611
|
};
|
|
511
612
|
/** `sqlite/integer`'s stored form, read into a `number`: digit text within the safe integer range. */
|
|
512
613
|
const safeIntegerFromDigitText = (codecId, json) => Number(readJsonIntegerText(codecId, json, SAFE_INTEGER_BIGINT_RANGE));
|
|
513
614
|
/** A `number` written as `sqlite/integer`'s stored form. */
|
|
514
615
|
const digitTextOfSafeInteger = (codecId, value) => String(encodableSafeInteger(codecId, value));
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
*/
|
|
518
|
-
function safeIntegerWire(codecId, wire) {
|
|
519
|
-
if (typeof wire === "number") return wire;
|
|
520
|
-
if (!DECIMAL_INTEGER.test(wire)) throw sqliteError("RUNTIME.DECODE_FAILED", `${codecId} wire value must be an integer or its decimal text`, { meta: {
|
|
616
|
+
function errorIntegerUnreadable(codecId, received, ctx) {
|
|
617
|
+
throw errorColumnUnreadable({
|
|
521
618
|
codecId,
|
|
522
|
-
received
|
|
523
|
-
|
|
524
|
-
|
|
619
|
+
received,
|
|
620
|
+
column: ctx.column,
|
|
621
|
+
notA: "an integer within the safe integer range",
|
|
622
|
+
reads: `integers from ${SAFE_INTEGER_BIGINT_RANGE.min} to ${SAFE_INTEGER_BIGINT_RANGE.max}`
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
/** A stored value `sqlite/bigint@1` cannot read, named by its column where the read knows it. */
|
|
626
|
+
function errorBigintUnreadable(received, ctx) {
|
|
627
|
+
throw errorColumnUnreadable({
|
|
628
|
+
codecId: SQLITE_BIGINT_CODEC_ID,
|
|
629
|
+
received,
|
|
630
|
+
column: ctx.column,
|
|
631
|
+
notA: "stored as a 64-bit integer",
|
|
632
|
+
reads: `integers from ${INT64_RANGE$1.min} to ${INT64_RANGE$1.max}`
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
/** An integer the driver reads exactly, or the decimal text an include carries, read into a safe-range `number`. A blob, which a row carries as bytes and an include as the array of their hex text, is refused. */
|
|
636
|
+
function safeIntegerFromExact(codecId, wire, ctx) {
|
|
637
|
+
const value = typeof wire === "bigint" ? wire : typeof wire === "string" && DECIMAL_INTEGER.test(wire) ? BigInt(wire) : void 0;
|
|
638
|
+
if (value === void 0 || value < SAFE_INTEGER_BIGINT_RANGE.min || value > SAFE_INTEGER_BIGINT_RANGE.max) return errorIntegerUnreadable(codecId, wire, ctx);
|
|
639
|
+
return Number(value);
|
|
640
|
+
}
|
|
641
|
+
/** Reads an INTEGER's wire value into a `number` within the safe integer range. A stored REAL, such as 1.5, is refused too. */
|
|
642
|
+
function safeIntegerWire(codecId, wire, ctx) {
|
|
643
|
+
if (typeof wire !== "number") return safeIntegerFromExact(codecId, wire, ctx);
|
|
644
|
+
if (Number.isSafeInteger(wire)) return Object.is(wire, -0) ? 0 : wire;
|
|
645
|
+
return errorIntegerUnreadable(codecId, wire, ctx);
|
|
525
646
|
}
|
|
526
647
|
/**
|
|
527
|
-
* Reads a REAL's wire value: the number the driver returns for a row, or the text `Infinity` or `-Infinity` an include carries, because JSON has no infinity.
|
|
648
|
+
* Reads a REAL's wire value: the number the driver returns for a row, an integer outside the safe range as the nearest float, or the text `Infinity` or `-Infinity` an include carries, because JSON has no infinity. Anything else, such as other text or a blob, is refused naming its column.
|
|
528
649
|
*/
|
|
529
|
-
function floatWire(codecId, wire) {
|
|
650
|
+
function floatWire(codecId, wire, ctx) {
|
|
530
651
|
if (typeof wire === "number") return wire;
|
|
652
|
+
if (typeof wire === "bigint") return Number(wire);
|
|
531
653
|
if (wire === "Infinity") return Number.POSITIVE_INFINITY;
|
|
532
654
|
if (wire === "-Infinity") return Number.NEGATIVE_INFINITY;
|
|
533
|
-
throw
|
|
655
|
+
throw errorColumnUnreadable({
|
|
534
656
|
codecId,
|
|
535
|
-
received: wire
|
|
536
|
-
|
|
657
|
+
received: wire,
|
|
658
|
+
column: ctx.column,
|
|
659
|
+
notA: "a number",
|
|
660
|
+
reads: "a number, or the text Infinity or -Infinity"
|
|
661
|
+
});
|
|
537
662
|
}
|
|
538
663
|
/** The hex text SQLite's `hex()` writes: two uppercase digits for each byte. */
|
|
539
664
|
const BLOB_HEX_TEXT = /^(?:[0-9A-F]{2})*$/;
|
|
@@ -574,8 +699,8 @@ const sqliteSqlRawDescriptor = sqliteCodec(sqlRawDescriptor, {
|
|
|
574
699
|
});
|
|
575
700
|
/** `sql/int@1` as SQLite stores it: its stored form is `sqlite/integer`'s digit text. */
|
|
576
701
|
var SqliteSqlIntCodec = class extends SqlIntCodec {
|
|
577
|
-
async fromWire(wire,
|
|
578
|
-
return safeIntegerWire(this.id, wire);
|
|
702
|
+
async fromWire(wire, ctx) {
|
|
703
|
+
return safeIntegerWire(this.id, wire, ctx);
|
|
579
704
|
}
|
|
580
705
|
fromDataTypeValue(value) {
|
|
581
706
|
return safeIntegerFromDigitText(this.id, value.value);
|
|
@@ -587,7 +712,7 @@ var SqliteSqlIntCodec = class extends SqlIntCodec {
|
|
|
587
712
|
const sqliteSqlIntDescriptor = sqliteCodec(sqlIntDescriptor, {
|
|
588
713
|
dataType: sqliteInteger,
|
|
589
714
|
renderValueLiteral: decimalTextNumberLiteral,
|
|
590
|
-
jsonProjection:
|
|
715
|
+
jsonProjection: integerJsonProjection,
|
|
591
716
|
factory: (descriptor, dataType) => () => new SqliteSqlIntCodec(descriptor, dataType)
|
|
592
717
|
});
|
|
593
718
|
const sqliteSqlFloatDescriptor = sqliteCodec(sqlFloatDescriptor, {
|
|
@@ -634,10 +759,10 @@ const sqliteTextDescriptor = new SqliteTextDescriptor();
|
|
|
634
759
|
const sqliteTextColumn = () => column(sqliteTextDescriptor.factory(), sqliteTextDescriptor.codecId, void 0);
|
|
635
760
|
var SqliteIntegerCodec = class extends CodecImpl {
|
|
636
761
|
async toWire(value, _ctx) {
|
|
637
|
-
return value;
|
|
762
|
+
return encodableSafeInteger(SQLITE_INTEGER_CODEC_ID, value);
|
|
638
763
|
}
|
|
639
|
-
async fromWire(wire,
|
|
640
|
-
return safeIntegerWire(SQLITE_INTEGER_CODEC_ID, wire);
|
|
764
|
+
async fromWire(wire, ctx) {
|
|
765
|
+
return safeIntegerWire(SQLITE_INTEGER_CODEC_ID, wire, ctx);
|
|
641
766
|
}
|
|
642
767
|
fromDataTypeValue(value) {
|
|
643
768
|
return safeIntegerFromDigitText(SQLITE_INTEGER_CODEC_ID, value.value);
|
|
@@ -648,7 +773,7 @@ var SqliteIntegerCodec = class extends CodecImpl {
|
|
|
648
773
|
};
|
|
649
774
|
var SqliteIntegerDescriptor = class extends SqliteCodecDescriptor {
|
|
650
775
|
jsonProjection(expression) {
|
|
651
|
-
return
|
|
776
|
+
return integerJsonProjection(expression);
|
|
652
777
|
}
|
|
653
778
|
dataType = sqliteInteger.id;
|
|
654
779
|
codecId = SQLITE_INTEGER_CODEC_ID;
|
|
@@ -672,8 +797,8 @@ var SqliteRealCodec = class extends CodecImpl {
|
|
|
672
797
|
async toWire(value, _ctx) {
|
|
673
798
|
return refuseNaN(SQLITE_REAL_CODEC_ID, value);
|
|
674
799
|
}
|
|
675
|
-
async fromWire(wire,
|
|
676
|
-
return floatWire(SQLITE_REAL_CODEC_ID, wire);
|
|
800
|
+
async fromWire(wire, ctx) {
|
|
801
|
+
return floatWire(SQLITE_REAL_CODEC_ID, wire, ctx);
|
|
677
802
|
}
|
|
678
803
|
fromDataTypeValue(value) {
|
|
679
804
|
return readJsonFloatWithoutNaN(SQLITE_REAL_CODEC_ID, value.value);
|
|
@@ -709,13 +834,16 @@ var SqliteBlobCodec = class extends CodecImpl {
|
|
|
709
834
|
return value;
|
|
710
835
|
}
|
|
711
836
|
/** A row carries the blob's bytes; an include carries the array of their hex text that its projection writes, because SQLite's JSON functions refuse a blob. Anything else a BLOB column holds is refused. */
|
|
712
|
-
async fromWire(wire,
|
|
837
|
+
async fromWire(wire, ctx) {
|
|
713
838
|
if (wire instanceof Uint8Array) return wire;
|
|
714
839
|
const [hex] = Array.isArray(wire) && wire.length === 1 ? wire : [];
|
|
715
|
-
if (typeof hex !== "string" || !BLOB_HEX_TEXT.test(hex)) throw
|
|
840
|
+
if (typeof hex !== "string" || !BLOB_HEX_TEXT.test(hex)) throw errorColumnUnreadable({
|
|
716
841
|
codecId: SQLITE_BLOB_CODEC_ID,
|
|
717
|
-
received:
|
|
718
|
-
|
|
842
|
+
received: wire,
|
|
843
|
+
column: ctx.column,
|
|
844
|
+
notA: "a blob",
|
|
845
|
+
reads: "a blob's bytes"
|
|
846
|
+
});
|
|
719
847
|
return new Uint8Array(Buffer.from(hex, "hex"));
|
|
720
848
|
}
|
|
721
849
|
fromDataTypeValue(value) {
|
|
@@ -784,12 +912,28 @@ var SqliteDatetimeDescriptor = class extends SqliteCodecDescriptor {
|
|
|
784
912
|
};
|
|
785
913
|
const sqliteDatetimeDescriptor = new SqliteDatetimeDescriptor();
|
|
786
914
|
const sqliteDatetimeColumn = () => column(sqliteDatetimeDescriptor.factory(), sqliteDatetimeDescriptor.codecId, void 0);
|
|
915
|
+
/** A stored value `sqlite/json@1` cannot read, named by its column where the read knows it. */
|
|
916
|
+
function errorJsonUnreadable(received, ctx) {
|
|
917
|
+
throw errorColumnUnreadable({
|
|
918
|
+
codecId: SQLITE_JSON_CODEC_ID,
|
|
919
|
+
received,
|
|
920
|
+
column: ctx.column,
|
|
921
|
+
notA: "JSON text",
|
|
922
|
+
reads: "JSON text as the document it holds"
|
|
923
|
+
});
|
|
924
|
+
}
|
|
787
925
|
var SqliteJsonCodec = class extends CodecImpl {
|
|
788
926
|
async toWire(value, _ctx) {
|
|
789
927
|
return JSON.stringify(value);
|
|
790
928
|
}
|
|
791
|
-
async fromWire(wire,
|
|
792
|
-
|
|
929
|
+
async fromWire(wire, ctx) {
|
|
930
|
+
if (wire instanceof Uint8Array || Array.isArray(wire)) return errorJsonUnreadable(wire, ctx);
|
|
931
|
+
if (typeof wire !== "string") return wire;
|
|
932
|
+
try {
|
|
933
|
+
return blindCast(JSON.parse(wire));
|
|
934
|
+
} catch {
|
|
935
|
+
return errorJsonUnreadable(wire, ctx);
|
|
936
|
+
}
|
|
793
937
|
}
|
|
794
938
|
fromDataTypeValue(value) {
|
|
795
939
|
return blindCast(JSON.parse(value.value));
|
|
@@ -799,12 +943,11 @@ var SqliteJsonCodec = class extends CodecImpl {
|
|
|
799
943
|
}
|
|
800
944
|
};
|
|
801
945
|
/**
|
|
802
|
-
* The column stores the document's JSON text and the stored form is that text, so the stored
|
|
803
|
-
* value is projected as it is: a string the enclosing JSON constructor embeds as a string.
|
|
946
|
+
* The column stores the document's JSON text and the stored form is that text, so the stored text is projected as it is: a string the enclosing JSON constructor embeds as a string. A blob is projected as the array of its hex text, which the codec refuses, because SQLite's JSON functions refuse a blob.
|
|
804
947
|
*/
|
|
805
948
|
var SqliteJsonDescriptor = class extends SqliteCodecDescriptor {
|
|
806
949
|
jsonProjection(expression) {
|
|
807
|
-
return expression;
|
|
950
|
+
return hexJsonProjection(expression);
|
|
808
951
|
}
|
|
809
952
|
dataType = sqliteJson.id;
|
|
810
953
|
codecId = SQLITE_JSON_CODEC_ID;
|
|
@@ -822,27 +965,16 @@ const sqliteJsonDescriptor = new SqliteJsonDescriptor();
|
|
|
822
965
|
const sqliteJsonColumn = () => column(sqliteJsonDescriptor.factory(), sqliteJsonDescriptor.codecId, void 0);
|
|
823
966
|
var SqliteBigintCodec = class extends CodecImpl {
|
|
824
967
|
async toWire(value, _ctx) {
|
|
825
|
-
|
|
826
|
-
return value;
|
|
968
|
+
return encodableInt64(SQLITE_BIGINT_CODEC_ID, value);
|
|
827
969
|
}
|
|
828
970
|
/**
|
|
829
|
-
* The
|
|
830
|
-
* aggregate SQLite computes leaves the database through the descriptor's cast
|
|
831
|
-
* to text, because the driver reads an integer no number can hold as an error
|
|
832
|
-
* rather than a value. A number-typed wire value must therefore be a safe
|
|
833
|
-
* integer — past ±(2^53 − 1) it has already rounded, and converting it would
|
|
834
|
-
* mint a spuriously-exact `bigint` that need not equal the stored value.
|
|
971
|
+
* The driver reads an integer outside the safe range as an exact `bigint` and one inside it as a `number`; an include and a wide aggregate carry decimal text. Anything else, such as a stored REAL, text or a blob, is refused naming its column.
|
|
835
972
|
*/
|
|
836
|
-
async fromWire(wire,
|
|
837
|
-
if (typeof wire === "
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (typeof wire === "string" && !DECIMAL_INTEGER.test(wire)) throw sqliteError("RUNTIME.DECODE_FAILED", "sqlite/bigint@1 wire value must be a decimal string", { meta: {
|
|
842
|
-
codecId: SQLITE_BIGINT_CODEC_ID,
|
|
843
|
-
received: wire
|
|
844
|
-
} });
|
|
845
|
-
return BigInt(wire);
|
|
973
|
+
async fromWire(wire, ctx) {
|
|
974
|
+
if (typeof wire === "bigint") return wire;
|
|
975
|
+
if (typeof wire === "number" && Number.isSafeInteger(wire)) return BigInt(wire);
|
|
976
|
+
if (typeof wire === "string" && DECIMAL_INTEGER.test(wire)) return BigInt(wire);
|
|
977
|
+
return errorBigintUnreadable(wire, ctx);
|
|
846
978
|
}
|
|
847
979
|
fromDataTypeValue(value) {
|
|
848
980
|
return BigInt(value.value);
|
|
@@ -853,7 +985,7 @@ var SqliteBigintCodec = class extends CodecImpl {
|
|
|
853
985
|
};
|
|
854
986
|
var SqliteBigintDescriptor = class extends SqliteCodecDescriptor {
|
|
855
987
|
jsonProjection(expression) {
|
|
856
|
-
return
|
|
988
|
+
return integerJsonProjection(expression);
|
|
857
989
|
}
|
|
858
990
|
dataType = sqliteInteger.id;
|
|
859
991
|
codecId = SQLITE_BIGINT_CODEC_ID;
|
|
@@ -885,17 +1017,10 @@ var SqliteBigintNumberCodec = class extends CodecImpl {
|
|
|
885
1017
|
return encodableSafeInteger(SQLITE_BIGINT_NUMBER_CODEC_ID, value);
|
|
886
1018
|
}
|
|
887
1019
|
/**
|
|
888
|
-
* The driver hands an INTEGER over as a `number` or
|
|
889
|
-
* `bigint`; a bigint (or decimal text) is range-checked exactly before any
|
|
890
|
-
* conversion to `number`, so an out-of-range value throws rather than rounds.
|
|
1020
|
+
* The driver hands an INTEGER over as a `number`, or as a `bigint` outside the safe range; a bigint (or decimal text) is range-checked exactly before any conversion to `number`, so an out-of-range value throws rather than rounds. A blob is refused.
|
|
891
1021
|
*/
|
|
892
|
-
async fromWire(wire,
|
|
893
|
-
|
|
894
|
-
if (typeof wire === "string" && !DECIMAL_INTEGER.test(wire)) throw sqliteError("RUNTIME.DECODE_FAILED", "sqlite/bigintnumber@1 wire value must be a decimal string", { meta: {
|
|
895
|
-
codecId: SQLITE_BIGINT_NUMBER_CODEC_ID,
|
|
896
|
-
received: wire
|
|
897
|
-
} });
|
|
898
|
-
return safeIntegerFromBigint(SQLITE_BIGINT_NUMBER_CODEC_ID, BigInt(wire));
|
|
1022
|
+
async fromWire(wire, ctx) {
|
|
1023
|
+
return safeIntegerWire(SQLITE_BIGINT_NUMBER_CODEC_ID, wire, ctx);
|
|
899
1024
|
}
|
|
900
1025
|
fromDataTypeValue(value) {
|
|
901
1026
|
return safeIntegerFromDigitText(SQLITE_BIGINT_NUMBER_CODEC_ID, value.value);
|
|
@@ -906,7 +1031,7 @@ var SqliteBigintNumberCodec = class extends CodecImpl {
|
|
|
906
1031
|
};
|
|
907
1032
|
var SqliteBigintNumberDescriptor = class extends SqliteCodecDescriptor {
|
|
908
1033
|
jsonProjection(expression) {
|
|
909
|
-
return
|
|
1034
|
+
return integerJsonProjection(expression);
|
|
910
1035
|
}
|
|
911
1036
|
dataType = sqliteInteger.id;
|
|
912
1037
|
codecId = SQLITE_BIGINT_NUMBER_CODEC_ID;
|
|
@@ -946,9 +1071,11 @@ const codecDescriptors = defineSqliteCodecs([
|
|
|
946
1071
|
sqliteDurationStringDescriptor,
|
|
947
1072
|
sqliteJsonDescriptor,
|
|
948
1073
|
sqliteBigintDescriptor,
|
|
949
|
-
sqliteBigintNumberDescriptor
|
|
1074
|
+
sqliteBigintNumberDescriptor,
|
|
1075
|
+
sqliteDecimalDescriptor,
|
|
1076
|
+
sqliteBooleanDescriptor
|
|
950
1077
|
]);
|
|
951
1078
|
//#endregion
|
|
952
|
-
export {
|
|
1079
|
+
export { sqliteRealColumn as _, sqliteBigintNumberColumn as a, sqliteTimeTemporalColumn as b, sqliteDateStringColumn as c, sqliteDatetimeStringColumn as d, sqliteDatetimeTemporalColumn as f, sqliteJsonColumn as g, sqliteIntegerColumn as h, sqliteBigintColumn as i, sqliteDateTemporalColumn as l, sqliteDurationStringColumn as m, encodeSqliteDatetime as n, sqliteBlobColumn as o, sqliteDecimalColumn as p, jsonDocumentRetag as r, sqliteBooleanColumn as s, codecDescriptors as t, sqliteDatetimeColumn as u, sqliteTextColumn as v, sqliteTimeStringColumn as y };
|
|
953
1080
|
|
|
954
|
-
//# sourceMappingURL=codecs-
|
|
1081
|
+
//# sourceMappingURL=codecs-CE5McdzP-CZ5F4Trz.mjs.map
|