@prisma/orm-target-postgres 8.0.0-rc.5-dev.2 → 8.0.0-rc.5-dev.3
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-CEEGgfaS-4MeZ7odP.mjs → adapter-fu5NLR5q-BGMHGbUv.mjs} +4 -4
- package/dist/{adapter-CEEGgfaS-4MeZ7odP.mjs.map → adapter-fu5NLR5q-BGMHGbUv.mjs.map} +1 -1
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +6 -6
- package/dist/adapter__adapter.mjs +1 -1
- package/dist/adapter__column-types.d.mts +2 -2
- package/dist/adapter__column-types.mjs +2 -2
- package/dist/adapter__control.mjs +78 -12
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +23 -14
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/{aggregates-Dh6HPdvC.mjs → aggregates-Ckjhz1o7.mjs} +15 -10
- package/dist/aggregates-Ckjhz1o7.mjs.map +1 -0
- package/dist/{authoring-BOpdZa2N-ClrLFiXw.mjs → authoring-DayoLvZs-BZzesJbW.mjs} +47 -12
- package/dist/authoring-DayoLvZs-BZzesJbW.mjs.map +1 -0
- package/dist/{check-expressions-5vhxWaFy-CBcjFeur.mjs → check-expressions-B3Xp6IFg-BzCFYrC9.mjs} +3 -3
- package/dist/{check-expressions-5vhxWaFy-CBcjFeur.mjs.map → check-expressions-B3Xp6IFg-BzCFYrC9.mjs.map} +1 -1
- package/dist/codec-ids-CmcC76hX-C0JIyoua.d.mts +39 -0
- package/dist/codec-ids-CmcC76hX-C0JIyoua.d.mts.map +1 -0
- package/dist/codec-ids-D3ZEAmt2-DjoKUAas.mjs +39 -0
- package/dist/codec-ids-D3ZEAmt2-DjoKUAas.mjs.map +1 -0
- package/dist/codec-ids-cWPqrkcF.d.mts +1 -0
- package/dist/{codec-types-BRU4F-7t-BaJbKF_i.d.mts → codec-types-X0ENu4sQ-C6GS_WDR.d.mts} +21 -9
- package/dist/codec-types-X0ENu4sQ-C6GS_WDR.d.mts.map +1 -0
- package/dist/codec-types-Zel4Dk7S.d.mts +2 -0
- package/dist/{codecs-BmPCJWqb-DveZGJvm.mjs → codecs-CxWg7WrX-DtVAuuXA.mjs} +351 -255
- package/dist/codecs-CxWg7WrX-DtVAuuXA.mjs.map +1 -0
- package/dist/{codecs-B1HgsJZ2.mjs → codecs-DZMfLjGe.mjs} +2 -2
- package/dist/codecs-DZMfLjGe.mjs.map +1 -0
- package/dist/{codecs-D8tLswBi-_nbo-Z8x.d.mts → codecs-bwX5JaME-ByuPNLC5.d.mts} +146 -86
- package/dist/codecs-bwX5JaME-ByuPNLC5.d.mts.map +1 -0
- package/dist/{codecs-DmCKO7dg.d.mts → codecs-ePpDWH7z.d.mts} +2 -2
- package/dist/codecs-ePpDWH7z.d.mts.map +1 -0
- package/dist/{column-types-BH-MU6uU.d.mts → column-types-CwjYfNCi.d.mts} +33 -7
- package/dist/column-types-CwjYfNCi.d.mts.map +1 -0
- package/dist/{column-types-Bh92dNjD.mjs → column-types-DU7C_gwa.mjs} +37 -9
- package/dist/column-types-DU7C_gwa.mjs.map +1 -0
- package/dist/{contract-free-aQ4nT-_R.mjs → contract-free-CzTZEwpt.mjs} +5 -5
- package/dist/contract-free-CzTZEwpt.mjs.map +1 -0
- package/dist/{control-2F195jJk.d.mts → control-ByalKcpe.d.mts} +2 -1
- package/dist/control-ByalKcpe.d.mts.map +1 -0
- package/dist/{control-V7OkAC55.mjs → control-CwOI5ZH9.mjs} +8 -8
- package/dist/control-CwOI5ZH9.mjs.map +1 -0
- package/dist/{control-adapter-DGLvLCp7-DaglJOfk.mjs → control-adapter-BvycZgCj-DH90lxuD.mjs} +9 -9
- package/dist/control-adapter-BvycZgCj-DH90lxuD.mjs.map +1 -0
- package/dist/{control-policy-B53lnBCT-B9K9Cj1x.mjs → control-policy-HgW6zNnz-Ds9U3rSS.mjs} +6 -6
- package/dist/{control-policy-B53lnBCT-B9K9Cj1x.mjs.map → control-policy-HgW6zNnz-Ds9U3rSS.mjs.map} +1 -1
- package/dist/{ddl-CNQJds-C-WfZ3y4y8.mjs → ddl-GXbCrKp_-CBKFkq1r.mjs} +4 -4
- package/dist/{ddl-CNQJds-C-WfZ3y4y8.mjs.map → ddl-GXbCrKp_-CBKFkq1r.mjs.map} +1 -1
- package/dist/{descriptor-meta-KVX21fsl-DBDoB4eg.mjs → descriptor-meta-BJvQzm-A-BdYGq2QU.mjs} +50 -21
- package/dist/descriptor-meta-BJvQzm-A-BdYGq2QU.mjs.map +1 -0
- package/dist/{descriptor-meta-rilAH3ep-dAmiVLpe.mjs → descriptor-meta-DInZZgUC-Cq-SJvwE.mjs} +6 -6
- package/dist/{descriptor-meta-rilAH3ep-dAmiVLpe.mjs.map → descriptor-meta-DInZZgUC-Cq-SJvwE.mjs.map} +1 -1
- package/dist/{diff-database-schema-DKq76rCk-uehceHYz.mjs → diff-database-schema-B27W13mM-DmRNUFyg.mjs} +6 -6
- package/dist/{diff-database-schema-DKq76rCk-uehceHYz.mjs.map → diff-database-schema-B27W13mM-DmRNUFyg.mjs.map} +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/driver__runtime.mjs +1 -1
- package/dist/{errors-CU4xIwwk.d.mts → errors-5fMq0U66.d.mts} +2 -2
- package/dist/{errors-CU4xIwwk.d.mts.map → errors-5fMq0U66.d.mts.map} +1 -1
- package/dist/errors-DYyzTYzE-39CV_aMo.mjs +92 -0
- package/dist/errors-DYyzTYzE-39CV_aMo.mjs.map +1 -0
- package/dist/instant-now-generator-lJQqn_8K-JOzseqXI.d.mts +9 -0
- package/dist/instant-now-generator-lJQqn_8K-JOzseqXI.d.mts.map +1 -0
- package/dist/migration-PTHAY9Cv.mjs.map +1 -1
- package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs → op-factory-call-CSkQdszU-C43tr0rP.mjs} +7 -7
- package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs.map → op-factory-call-CSkQdszU-C43tr0rP.mjs.map} +1 -1
- package/dist/{pack-CySS3DQU.d.mts → pack-DaQJIP6O.d.mts} +143 -11
- package/dist/pack-DaQJIP6O.d.mts.map +1 -0
- package/dist/{planner-D0uogzvT-1WyGIC5p.mjs → planner-CqeT-P2q-DVglsvwu.mjs} +8 -8
- package/dist/{planner-D0uogzvT-1WyGIC5p.mjs.map → planner-CqeT-P2q-DVglsvwu.mjs.map} +1 -1
- package/dist/{planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs → planner-ddl-builders-CsfmnnKR-CNn0fLyx.mjs} +5 -5
- package/dist/{planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs.map → planner-ddl-builders-CsfmnnKR-CNn0fLyx.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs → planner-produced-postgres-migration-Dsri3SjC-DZynrNO-.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs.map → planner-produced-postgres-migration-Dsri3SjC-DZynrNO-.mjs.map} +1 -1
- package/dist/{planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs → planner-sql-checks-Bcngv5YZ-Dnp05hSM.mjs} +4 -4
- package/dist/{planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs.map → planner-sql-checks-Bcngv5YZ-Dnp05hSM.mjs.map} +1 -1
- package/dist/{postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs → postgres-contract-view-CzWRnkxb-BpyBv1vn.mjs} +5 -5
- package/dist/{postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs.map → postgres-contract-view-CzWRnkxb-BpyBv1vn.mjs.map} +1 -1
- package/dist/{postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs → postgres-migration-DHvU3Jkt-Eah72PD4.mjs} +6 -6
- package/dist/{postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs.map → postgres-migration-DHvU3Jkt-Eah72PD4.mjs.map} +1 -1
- package/dist/{postgres-schema-CF0yHESb-D7n2X21R.mjs → postgres-schema-B3t7Zr52-CMlY9aGw.mjs} +4 -4
- package/dist/{postgres-schema-CF0yHESb-D7n2X21R.mjs.map → postgres-schema-B3t7Zr52-CMlY9aGw.mjs.map} +1 -1
- package/dist/{render-ops-DOsRP0Po-BKn_c_Ia.mjs → render-ops-D2vJApKB-B281fzmn.mjs} +3 -3
- package/dist/{render-ops-DOsRP0Po-BKn_c_Ia.mjs.map → render-ops-D2vJApKB-B281fzmn.mjs.map} +1 -1
- package/dist/{resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs → resolve-ddl-schema-Cab6g5MC-SRco-A7L.mjs} +3 -3
- package/dist/{resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs.map → resolve-ddl-schema-Cab6g5MC-SRco-A7L.mjs.map} +1 -1
- package/dist/{runtime-C-Hh2m1R.mjs → runtime-BJrfP1e8.mjs} +43 -5
- package/dist/runtime-BJrfP1e8.mjs.map +1 -0
- package/dist/{runtime-_TfO66h5.d.mts → runtime-bbCw9Omq.d.mts} +2 -1
- package/dist/runtime-bbCw9Omq.d.mts.map +1 -0
- package/dist/{sql-renderer-ComgusFq-BBlqM1fw.mjs → sql-renderer-ComgusFq-DfvXlBce.mjs} +3 -3
- package/dist/{sql-renderer-ComgusFq-BBlqM1fw.mjs.map → sql-renderer-ComgusFq-DfvXlBce.mjs.map} +1 -1
- package/dist/{sql-utils-DuzN3JZg-DiXy4Vah.mjs → sql-utils-6j9YTLpr-BCyCBPBg.mjs} +3 -3
- package/dist/{sql-utils-DuzN3JZg-DiXy4Vah.mjs.map → sql-utils-6j9YTLpr-BCyCBPBg.mjs.map} +1 -1
- package/dist/target.d.mts +12 -11
- package/dist/target.mjs +24 -23
- 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 +4 -4
- package/dist/target__codecs.d.mts +3 -3
- package/dist/target__codecs.mjs +3 -3
- package/dist/target__contract-free.mjs +3 -3
- package/dist/target__control.d.mts +3 -2
- package/dist/target__control.mjs +3 -2
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__errors.d.mts +1 -1
- package/dist/target__errors.mjs +1 -1
- package/dist/target__issue-planner.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-ddl-builders.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner-sql-checks.mjs +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__render-ops.mjs +1 -1
- package/dist/target__runtime.d.mts +3 -2
- package/dist/target__runtime.mjs +3 -2
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__schema-ir-annotations.mjs +1 -1
- package/dist/target__sql-utils.mjs +1 -1
- package/dist/target__types.mjs +2 -2
- package/package.json +9 -9
- package/dist/aggregates-Dh6HPdvC.mjs.map +0 -1
- package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs.map +0 -1
- package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts +0 -35
- package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts.map +0 -1
- package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs +0 -35
- package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs.map +0 -1
- package/dist/codec-ids-DJ6j6pZc.d.mts +0 -1
- package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts.map +0 -1
- package/dist/codec-types-bX63JRLf.d.mts +0 -2
- package/dist/codecs-B1HgsJZ2.mjs.map +0 -1
- package/dist/codecs-BmPCJWqb-DveZGJvm.mjs.map +0 -1
- package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts.map +0 -1
- package/dist/codecs-DmCKO7dg.d.mts.map +0 -1
- package/dist/column-types-BH-MU6uU.d.mts.map +0 -1
- package/dist/column-types-Bh92dNjD.mjs.map +0 -1
- package/dist/contract-free-aQ4nT-_R.mjs.map +0 -1
- package/dist/control-2F195jJk.d.mts.map +0 -1
- package/dist/control-V7OkAC55.mjs.map +0 -1
- package/dist/control-adapter-DGLvLCp7-DaglJOfk.mjs.map +0 -1
- package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs.map +0 -1
- package/dist/errors-DKjQzNaN-DFcF1thx.mjs +0 -39
- package/dist/errors-DKjQzNaN-DFcF1thx.mjs.map +0 -1
- package/dist/pack-CySS3DQU.d.mts.map +0 -1
- package/dist/runtime-C-Hh2m1R.mjs.map +0 -1
- package/dist/runtime-_TfO66h5.d.mts.map +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as PG_UNBOUNDED_INT_CODEC_ID, C as PG_TIMESTAMPTZ_STRING_CODEC_ID, D as PG_TIMETZ_CODEC_ID, E as PG_TIMESTAMP_TEMPORAL_CODEC_ID, M as PG_VARBIT_CODEC_ID, N as PG_VARCHAR_CODEC_ID, O as PG_TIME_STRING_CODEC_ID, S as PG_TEXT_CODEC_ID, T as PG_TIMESTAMP_STRING_CODEC_ID, _ as PG_INT_CODEC_ID, a as PG_DATE_STRING_CODEC_ID, b as PG_NUMERIC_CODEC_ID, c as PG_FLOAT4_CODEC_ID, d as PG_INET_CODEC_ID, f as PG_INT2_CODEC_ID, g as PG_INTERVAL_CODEC_ID, h as PG_INT8_NUMBER_CODEC_ID, i as PG_CHAR_CODEC_ID, j as PG_UUID_CODEC_ID, k as PG_TIME_TEMPORAL_CODEC_ID, l as PG_FLOAT8_CODEC_ID, m as PG_INT8_CODEC_ID, n as PG_BOOL_CODEC_ID, o as PG_DATE_TEMPORAL_CODEC_ID, p as PG_INT4_CODEC_ID, r as PG_BYTEA_CODEC_ID, s as PG_ENUM_CODEC_ID, t as PG_BIT_CODEC_ID, u as PG_FLOAT_CODEC_ID, v as PG_JSONB_CODEC_ID, w as PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID, x as PG_TEXT_ARRAY_CODEC_ID, y as PG_JSON_CODEC_ID } from "./codec-ids-D3ZEAmt2-DjoKUAas.mjs";
|
|
2
2
|
import { a as postgresCodec, r as definePostgresCodecs, t as PostgresCodecDescriptor } from "./codec-descriptor-LT7BpQta-BaDM8UQQ.mjs";
|
|
3
|
-
import { n as postgresError } from "./errors-
|
|
3
|
+
import { a as errorTemporalUnrepresentable, n as errorTemporalNonIsoCalendar, o as errorTemporalWrongType, r as errorTemporalUnavailable, s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
|
|
4
4
|
import { t as PostgresNativeEnum } from "./postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs";
|
|
5
|
-
import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, OrExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor,
|
|
5
|
+
import { BinaryExpr, CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, OrExpr, SqlCharCodec, SqlFloatCodec, SqlIntCodec, SqlVarcharCodec, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlTextDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
|
|
6
6
|
import { CodecImpl, column, renderTsLiteral, voidParamsSchema } from "@prisma/orm-framework/components/codec";
|
|
7
7
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
8
8
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
9
9
|
import { type } from "arktype";
|
|
10
|
-
//#region ../../../3-targets/3-targets/postgres/dist/codecs-
|
|
10
|
+
//#region ../../../3-targets/3-targets/postgres/dist/codecs-CxWg7WrX.mjs
|
|
11
|
+
const precisionParamsSchema = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
|
|
11
12
|
function renderLength(typeName, typeParams) {
|
|
12
|
-
const length = typeParams
|
|
13
|
+
const length = typeParams.length;
|
|
13
14
|
if (length === void 0) return;
|
|
14
15
|
if (typeof length !== "number" || !Number.isFinite(length) || !Number.isInteger(length)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "length" in typeParams for ${typeName}, got ${String(length)}`, { meta: {
|
|
15
16
|
nativeType: typeName,
|
|
@@ -19,7 +20,7 @@ function renderLength(typeName, typeParams) {
|
|
|
19
20
|
return `${typeName}<${length}>`;
|
|
20
21
|
}
|
|
21
22
|
function renderPrecision(typeName, typeParams) {
|
|
22
|
-
const precision = typeParams
|
|
23
|
+
const precision = typeParams.precision;
|
|
23
24
|
if (precision === void 0) return typeName;
|
|
24
25
|
if (typeof precision !== "number" || !Number.isFinite(precision) || !Number.isInteger(precision)) throw postgresError("RUNTIME.TYPE_PARAMS_INVALID", `renderOutputType: expected integer "precision" in typeParams for ${typeName}, got ${String(precision)}`, { meta: {
|
|
25
26
|
nativeType: typeName,
|
|
@@ -163,89 +164,6 @@ const pgNumericRenderOutputType = (typeParams) => {
|
|
|
163
164
|
} });
|
|
164
165
|
return `Numeric<${precision}, ${scale}>`;
|
|
165
166
|
};
|
|
166
|
-
const ISO_8601_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$/;
|
|
167
|
-
const ISO_8601_TIMESTAMPTZ = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
168
|
-
const pgTimestampEncodeJson = (value) => value.toISOString().slice(0, -1);
|
|
169
|
-
const pgTimestampDecodeJson = (json) => {
|
|
170
|
-
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", `Expected ISO date string for pg/timestamp@1, got ${typeof json}`, { meta: {
|
|
171
|
-
codecId: "pg/timestamp@1",
|
|
172
|
-
received: typeof json
|
|
173
|
-
} });
|
|
174
|
-
if (!ISO_8601_TIMESTAMP.test(json)) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamp@1: ${json}`, { meta: {
|
|
175
|
-
codecId: "pg/timestamp@1",
|
|
176
|
-
received: json
|
|
177
|
-
} });
|
|
178
|
-
const date = /* @__PURE__ */ new Date(`${json}Z`);
|
|
179
|
-
if (Number.isNaN(date.getTime())) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamp@1: ${json}`, { meta: {
|
|
180
|
-
codecId: "pg/timestamp@1",
|
|
181
|
-
received: json
|
|
182
|
-
} });
|
|
183
|
-
return date;
|
|
184
|
-
};
|
|
185
|
-
const pgTimestamptzEncodeJson = (value) => value.toISOString().replace(/Z$/, "+00:00");
|
|
186
|
-
const pgTimestamptzDecodeJson = (json) => {
|
|
187
|
-
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", `Expected ISO date string for pg/timestamptz@1, got ${typeof json}`, { meta: {
|
|
188
|
-
codecId: "pg/timestamptz@1",
|
|
189
|
-
received: typeof json
|
|
190
|
-
} });
|
|
191
|
-
if (!ISO_8601_TIMESTAMPTZ.test(json)) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamptz@1: ${json}`, { meta: {
|
|
192
|
-
codecId: "pg/timestamptz@1",
|
|
193
|
-
received: json
|
|
194
|
-
} });
|
|
195
|
-
const date = new Date(json);
|
|
196
|
-
if (Number.isNaN(date.getTime())) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid ISO date string for pg/timestamptz@1: ${json}`, { meta: {
|
|
197
|
-
codecId: "pg/timestamptz@1",
|
|
198
|
-
received: json
|
|
199
|
-
} });
|
|
200
|
-
return date;
|
|
201
|
-
};
|
|
202
|
-
const ISO_8601_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
203
|
-
function formatDateOnly(year, month, day) {
|
|
204
|
-
return `${String(year).padStart(4, "0")}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* A Postgres `date` has no time-of-day or timezone component, so `pg/date@1`
|
|
208
|
-
* canonicalizes its JS-level value as a `Date` at UTC midnight
|
|
209
|
-
* (`Date.UTC(y, m, d)`), independent of the process's local timezone.
|
|
210
|
-
*
|
|
211
|
-
* `pgDateEncode` reads the calendar date via UTC getters (matching that
|
|
212
|
-
* canonical form) and formats it as `YYYY-MM-DD` directly, bypassing the pg
|
|
213
|
-
* driver's own `Date` serialization (`dateToString`), which reads *local*
|
|
214
|
-
* getters and would shift the calendar day near midnight in negative-UTC-offset
|
|
215
|
-
* environments.
|
|
216
|
-
*/
|
|
217
|
-
const pgDateEncode = (value) => formatDateOnly(value.getUTCFullYear(), value.getUTCMonth() + 1, value.getUTCDate());
|
|
218
|
-
/**
|
|
219
|
-
* Normalizes the pg driver's already-parsed `Date` for a `date` column into
|
|
220
|
-
* the canonical UTC-midnight form. The driver (via `postgres-date`) builds
|
|
221
|
-
* that `Date` at *local* midnight from the wire text; reading it back with the
|
|
222
|
-
* same (local) getters recovers the exact calendar date the driver parsed,
|
|
223
|
-
* and reconstructing via `Date.UTC` makes the result's instant independent of
|
|
224
|
-
* the process's timezone.
|
|
225
|
-
*/
|
|
226
|
-
const pgDateDecode = (wire) => new Date(Date.UTC(wire.getFullYear(), wire.getMonth(), wire.getDate()));
|
|
227
|
-
const pgDateEncodeJson = (value) => pgDateEncode(value);
|
|
228
|
-
const pgDateDecodeJson = (json) => {
|
|
229
|
-
if (typeof json !== "string") throw postgresError("RUNTIME.DECODE_FAILED", `Expected date string for pg/date@1, got ${typeof json}`, { meta: {
|
|
230
|
-
codecId: "pg/date@1",
|
|
231
|
-
received: typeof json
|
|
232
|
-
} });
|
|
233
|
-
const match = ISO_8601_DATE.exec(json);
|
|
234
|
-
if (!match) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid date string for pg/date@1: ${json}`, { meta: {
|
|
235
|
-
codecId: "pg/date@1",
|
|
236
|
-
received: json
|
|
237
|
-
} });
|
|
238
|
-
const [, yearText, monthText, dayText] = match;
|
|
239
|
-
const year = Number(yearText);
|
|
240
|
-
const month = Number(monthText) - 1;
|
|
241
|
-
const day = Number(dayText);
|
|
242
|
-
const date = new Date(Date.UTC(year, month, day));
|
|
243
|
-
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) throw postgresError("RUNTIME.DECODE_FAILED", `Invalid date string for pg/date@1: ${json}`, { meta: {
|
|
244
|
-
codecId: "pg/date@1",
|
|
245
|
-
received: json
|
|
246
|
-
} });
|
|
247
|
-
return date;
|
|
248
|
-
};
|
|
249
167
|
const ISO_DURATION = /^P(?!$)(-?\d+Y)?(-?\d+M)?(-?\d+D)?(?:T(?!$)(-?\d+H)?(-?\d+M)?(-?\d+(?:\.\d+)?S)?)?$/;
|
|
250
168
|
const MICROS_PER_SECOND = 1000000n;
|
|
251
169
|
/**
|
|
@@ -360,12 +278,345 @@ const pgJsonEncode = (value) => JSON.stringify(value);
|
|
|
360
278
|
const pgJsonDecode = (wire) => typeof wire === "string" ? JSON.parse(wire) : wire;
|
|
361
279
|
const pgJsonbEncode = (value) => JSON.stringify(value);
|
|
362
280
|
const pgJsonbDecode = (wire) => typeof wire === "string" ? JSON.parse(wire) : wire;
|
|
281
|
+
const PG_DATE_NATIVE_TYPE = "date";
|
|
282
|
+
const PG_TIMESTAMP_NATIVE_TYPE = "timestamp without time zone";
|
|
283
|
+
const PG_TIMESTAMPTZ_NATIVE_TYPE = "timestamp with time zone";
|
|
284
|
+
const PG_TIME_NATIVE_TYPE = "time";
|
|
285
|
+
const POSTGRES_TEMPORAL_SENTINELS = /* @__PURE__ */ new Set(["infinity", "-infinity"]);
|
|
286
|
+
const EXPANDED_YEAR_DIGITS = 6;
|
|
287
|
+
const ORDINARY_YEAR_DIGITS = 4;
|
|
288
|
+
const BC_SUFFIX = " BC";
|
|
289
|
+
function adaptPostgresEra(text) {
|
|
290
|
+
const isBc = text.endsWith(BC_SUFFIX);
|
|
291
|
+
const body = isBc ? text.slice(0, -3) : text;
|
|
292
|
+
const yearEnd = body.indexOf("-");
|
|
293
|
+
if (yearEnd <= 0) return text;
|
|
294
|
+
const yearText = body.slice(0, yearEnd);
|
|
295
|
+
if (!isBc && yearText.length <= ORDINARY_YEAR_DIGITS) return text;
|
|
296
|
+
const year = Number(yearText);
|
|
297
|
+
if (!Number.isInteger(year)) return text;
|
|
298
|
+
const proleptic = isBc ? 1 - year : year;
|
|
299
|
+
return `${proleptic < 0 ? "-" : "+"}${String(Math.abs(proleptic)).padStart(EXPANDED_YEAR_DIGITS, "0")}${body.slice(yearEnd)}`;
|
|
300
|
+
}
|
|
301
|
+
function requireTemporal(codecId, operation) {
|
|
302
|
+
if (typeof Temporal === "undefined") throw errorTemporalUnavailable(codecId, operation);
|
|
303
|
+
}
|
|
304
|
+
function decodeTemporalText(identity, wire, parse, adapt) {
|
|
305
|
+
requireTemporal(identity.codecId, "decode");
|
|
306
|
+
if (POSTGRES_TEMPORAL_SENTINELS.has(wire)) throw errorTemporalUnrepresentable({
|
|
307
|
+
...identity,
|
|
308
|
+
operation: "decode",
|
|
309
|
+
value: wire,
|
|
310
|
+
detail: `PostgreSQL's ${wire} is a sentinel with no position on the timeline, so no Temporal value denotes it`
|
|
311
|
+
});
|
|
312
|
+
try {
|
|
313
|
+
return parse(adapt(wire));
|
|
314
|
+
} catch (cause) {
|
|
315
|
+
throw errorTemporalUnrepresentable({
|
|
316
|
+
...identity,
|
|
317
|
+
operation: "decode",
|
|
318
|
+
value: wire,
|
|
319
|
+
detail: cause instanceof Error ? cause.message : String(cause),
|
|
320
|
+
cause
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function encodeTemporalValue(identity, value) {
|
|
325
|
+
requireTemporal(identity.codecId, "encode");
|
|
326
|
+
const tag = typeof value === "object" && value !== null ? Reflect.get(value, Symbol.toStringTag) : void 0;
|
|
327
|
+
if (tag !== identity.temporalTag) throw errorTemporalWrongType(identity.codecId, identity.temporalTag, identity.stringType, describeEncodeInput(value, tag));
|
|
328
|
+
if (value.calendarId !== void 0 && value.calendarId !== "iso8601") throw errorTemporalNonIsoCalendar(identity.codecId, value.calendarId);
|
|
329
|
+
return value.toString();
|
|
330
|
+
}
|
|
331
|
+
function describeEncodeInput(value, tag) {
|
|
332
|
+
if (typeof tag === "string") return `a ${tag}`;
|
|
333
|
+
if (value instanceof Date) return "a Date";
|
|
334
|
+
if (value === null) return "null";
|
|
335
|
+
return `a ${typeof value}`;
|
|
336
|
+
}
|
|
337
|
+
const DATE_TEMPORAL = {
|
|
338
|
+
codecId: PG_DATE_TEMPORAL_CODEC_ID,
|
|
339
|
+
stringType: "DateString",
|
|
340
|
+
temporalTag: "Temporal.PlainDate"
|
|
341
|
+
};
|
|
342
|
+
const TIMESTAMP_TEMPORAL = {
|
|
343
|
+
codecId: PG_TIMESTAMP_TEMPORAL_CODEC_ID,
|
|
344
|
+
stringType: "TimestampString(p)",
|
|
345
|
+
temporalTag: "Temporal.PlainDateTime"
|
|
346
|
+
};
|
|
347
|
+
const TIMESTAMPTZ_TEMPORAL = {
|
|
348
|
+
codecId: PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID,
|
|
349
|
+
stringType: "TimestamptzString(p)",
|
|
350
|
+
temporalTag: "Temporal.Instant"
|
|
351
|
+
};
|
|
352
|
+
const TIME_TEMPORAL = {
|
|
353
|
+
codecId: PG_TIME_TEMPORAL_CODEC_ID,
|
|
354
|
+
stringType: "TimeString(p)",
|
|
355
|
+
temporalTag: "Temporal.PlainTime"
|
|
356
|
+
};
|
|
357
|
+
const unadapted = (text) => text;
|
|
358
|
+
const pgDateTemporalDecode = (wire) => decodeTemporalText(DATE_TEMPORAL, wire, (t) => Temporal.PlainDate.from(t), adaptPostgresEra);
|
|
359
|
+
const pgDateTemporalEncode = (value) => encodeTemporalValue(DATE_TEMPORAL, value);
|
|
360
|
+
const pgTimestampTemporalDecode = (wire) => decodeTemporalText(TIMESTAMP_TEMPORAL, wire, (t) => Temporal.PlainDateTime.from(t), adaptPostgresEra);
|
|
361
|
+
const pgTimestampTemporalEncode = (value) => encodeTemporalValue(TIMESTAMP_TEMPORAL, value);
|
|
362
|
+
const pgTimestamptzTemporalDecode = (wire) => decodeTemporalText(TIMESTAMPTZ_TEMPORAL, wire, (t) => Temporal.Instant.from(t), adaptPostgresEra);
|
|
363
|
+
const pgTimestamptzTemporalEncode = (value) => encodeTemporalValue(TIMESTAMPTZ_TEMPORAL, value);
|
|
364
|
+
const pgTimeTemporalDecode = (wire) => decodeTemporalText(TIME_TEMPORAL, wire, (t) => Temporal.PlainTime.from(t), unadapted);
|
|
365
|
+
const pgTimeTemporalEncode = (value) => encodeTemporalValue(TIME_TEMPORAL, value);
|
|
366
|
+
var PgDateTemporalCodec = class extends CodecImpl {
|
|
367
|
+
async encode(value, _ctx) {
|
|
368
|
+
return pgDateTemporalEncode(value);
|
|
369
|
+
}
|
|
370
|
+
async decode(wire, _ctx) {
|
|
371
|
+
return pgDateTemporalDecode(wire);
|
|
372
|
+
}
|
|
373
|
+
encodeJson(value) {
|
|
374
|
+
return pgDateTemporalEncode(value);
|
|
375
|
+
}
|
|
376
|
+
decodeJson(json) {
|
|
377
|
+
return pgDateTemporalDecode(blindCast(json));
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
var PgDateTemporalDescriptor = class extends PostgresCodecDescriptor {
|
|
381
|
+
nativeType() {
|
|
382
|
+
return PG_DATE_NATIVE_TYPE;
|
|
383
|
+
}
|
|
384
|
+
jsonProjection(expression) {
|
|
385
|
+
return CastExpr.as(expression, "text");
|
|
386
|
+
}
|
|
387
|
+
codecId = PG_DATE_TEMPORAL_CODEC_ID;
|
|
388
|
+
traits = ["equality", "order"];
|
|
389
|
+
targetTypes = ["date"];
|
|
390
|
+
paramsSchema = voidParamsSchema;
|
|
391
|
+
factory() {
|
|
392
|
+
return () => new PgDateTemporalCodec(this);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const pgDateTemporalDescriptor = new PgDateTemporalDescriptor();
|
|
396
|
+
var PgTimestampTemporalCodec = class extends CodecImpl {
|
|
397
|
+
async encode(value, _ctx) {
|
|
398
|
+
return pgTimestampTemporalEncode(value);
|
|
399
|
+
}
|
|
400
|
+
async decode(wire, _ctx) {
|
|
401
|
+
return pgTimestampTemporalDecode(wire);
|
|
402
|
+
}
|
|
403
|
+
encodeJson(value) {
|
|
404
|
+
return pgTimestampTemporalEncode(value);
|
|
405
|
+
}
|
|
406
|
+
decodeJson(json) {
|
|
407
|
+
return pgTimestampTemporalDecode(blindCast(json));
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
var PgTimestampTemporalDescriptor = class extends PostgresCodecDescriptor {
|
|
411
|
+
nativeType() {
|
|
412
|
+
return PG_TIMESTAMP_NATIVE_TYPE;
|
|
413
|
+
}
|
|
414
|
+
jsonProjection(expression) {
|
|
415
|
+
return CastExpr.as(expression, "text");
|
|
416
|
+
}
|
|
417
|
+
codecId = PG_TIMESTAMP_TEMPORAL_CODEC_ID;
|
|
418
|
+
traits = ["equality", "order"];
|
|
419
|
+
targetTypes = ["timestamp"];
|
|
420
|
+
paramsSchema = precisionParamsSchema;
|
|
421
|
+
factory(_params) {
|
|
422
|
+
return () => new PgTimestampTemporalCodec(this);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const pgTimestampTemporalDescriptor = new PgTimestampTemporalDescriptor();
|
|
426
|
+
var PgTimestamptzTemporalCodec = class extends CodecImpl {
|
|
427
|
+
async encode(value, _ctx) {
|
|
428
|
+
return pgTimestamptzTemporalEncode(value);
|
|
429
|
+
}
|
|
430
|
+
async decode(wire, _ctx) {
|
|
431
|
+
return pgTimestamptzTemporalDecode(wire);
|
|
432
|
+
}
|
|
433
|
+
encodeJson(value) {
|
|
434
|
+
return pgTimestamptzTemporalEncode(value);
|
|
435
|
+
}
|
|
436
|
+
decodeJson(json) {
|
|
437
|
+
return pgTimestamptzTemporalDecode(blindCast(json));
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
var PgTimestamptzTemporalDescriptor = class extends PostgresCodecDescriptor {
|
|
441
|
+
nativeType() {
|
|
442
|
+
return PG_TIMESTAMPTZ_NATIVE_TYPE;
|
|
443
|
+
}
|
|
444
|
+
jsonProjection(expression) {
|
|
445
|
+
return CastExpr.as(expression, "text");
|
|
446
|
+
}
|
|
447
|
+
codecId = PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID;
|
|
448
|
+
traits = ["equality", "order"];
|
|
449
|
+
targetTypes = ["timestamptz"];
|
|
450
|
+
paramsSchema = precisionParamsSchema;
|
|
451
|
+
factory(_params) {
|
|
452
|
+
return () => new PgTimestamptzTemporalCodec(this);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
const pgTimestamptzTemporalDescriptor = new PgTimestamptzTemporalDescriptor();
|
|
456
|
+
var PgTimeTemporalCodec = class extends CodecImpl {
|
|
457
|
+
async encode(value, _ctx) {
|
|
458
|
+
return pgTimeTemporalEncode(value);
|
|
459
|
+
}
|
|
460
|
+
async decode(wire, _ctx) {
|
|
461
|
+
return pgTimeTemporalDecode(wire);
|
|
462
|
+
}
|
|
463
|
+
encodeJson(value) {
|
|
464
|
+
return pgTimeTemporalEncode(value);
|
|
465
|
+
}
|
|
466
|
+
decodeJson(json) {
|
|
467
|
+
return pgTimeTemporalDecode(blindCast(json));
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
var PgTimeTemporalDescriptor = class extends PostgresCodecDescriptor {
|
|
471
|
+
nativeType() {
|
|
472
|
+
return PG_TIME_NATIVE_TYPE;
|
|
473
|
+
}
|
|
474
|
+
jsonProjection(expression) {
|
|
475
|
+
return CastExpr.as(expression, "text");
|
|
476
|
+
}
|
|
477
|
+
codecId = PG_TIME_TEMPORAL_CODEC_ID;
|
|
478
|
+
traits = ["equality", "order"];
|
|
479
|
+
targetTypes = ["time"];
|
|
480
|
+
paramsSchema = precisionParamsSchema;
|
|
481
|
+
factory(_params) {
|
|
482
|
+
return () => new PgTimeTemporalCodec(this);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
const pgTimeTemporalDescriptor = new PgTimeTemporalDescriptor();
|
|
486
|
+
var PgDateStringCodec = class extends CodecImpl {
|
|
487
|
+
async encode(value, _ctx) {
|
|
488
|
+
return value;
|
|
489
|
+
}
|
|
490
|
+
async decode(wire, _ctx) {
|
|
491
|
+
return wire;
|
|
492
|
+
}
|
|
493
|
+
encodeJson(value) {
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
496
|
+
decodeJson(json) {
|
|
497
|
+
return blindCast(json);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
var PgDateStringDescriptor = class extends PostgresCodecDescriptor {
|
|
501
|
+
nativeType() {
|
|
502
|
+
return PG_DATE_NATIVE_TYPE;
|
|
503
|
+
}
|
|
504
|
+
jsonProjection(expression) {
|
|
505
|
+
return CastExpr.as(expression, "text");
|
|
506
|
+
}
|
|
507
|
+
codecId = PG_DATE_STRING_CODEC_ID;
|
|
508
|
+
traits = ["equality", "order"];
|
|
509
|
+
targetTypes = [];
|
|
510
|
+
paramsSchema = voidParamsSchema;
|
|
511
|
+
factory() {
|
|
512
|
+
return () => new PgDateStringCodec(this);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
const pgDateStringDescriptor = new PgDateStringDescriptor();
|
|
516
|
+
var PgTimestampStringCodec = class extends CodecImpl {
|
|
517
|
+
async encode(value, _ctx) {
|
|
518
|
+
return value;
|
|
519
|
+
}
|
|
520
|
+
async decode(wire, _ctx) {
|
|
521
|
+
return wire;
|
|
522
|
+
}
|
|
523
|
+
encodeJson(value) {
|
|
524
|
+
return value;
|
|
525
|
+
}
|
|
526
|
+
decodeJson(json) {
|
|
527
|
+
return blindCast(json);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
var PgTimestampStringDescriptor = class extends PostgresCodecDescriptor {
|
|
531
|
+
nativeType() {
|
|
532
|
+
return PG_TIMESTAMP_NATIVE_TYPE;
|
|
533
|
+
}
|
|
534
|
+
jsonProjection(expression) {
|
|
535
|
+
return CastExpr.as(expression, "text");
|
|
536
|
+
}
|
|
537
|
+
codecId = PG_TIMESTAMP_STRING_CODEC_ID;
|
|
538
|
+
traits = ["equality", "order"];
|
|
539
|
+
targetTypes = [];
|
|
540
|
+
paramsSchema = precisionParamsSchema;
|
|
541
|
+
renderOutputType(params) {
|
|
542
|
+
return renderPrecision("TimestampString", params);
|
|
543
|
+
}
|
|
544
|
+
factory(_params) {
|
|
545
|
+
return () => new PgTimestampStringCodec(this);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
const pgTimestampStringDescriptor = new PgTimestampStringDescriptor();
|
|
549
|
+
var PgTimestamptzStringCodec = class extends CodecImpl {
|
|
550
|
+
async encode(value, _ctx) {
|
|
551
|
+
return value;
|
|
552
|
+
}
|
|
553
|
+
async decode(wire, _ctx) {
|
|
554
|
+
return wire;
|
|
555
|
+
}
|
|
556
|
+
encodeJson(value) {
|
|
557
|
+
return value;
|
|
558
|
+
}
|
|
559
|
+
decodeJson(json) {
|
|
560
|
+
return blindCast(json);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
var PgTimestamptzStringDescriptor = class extends PostgresCodecDescriptor {
|
|
564
|
+
nativeType() {
|
|
565
|
+
return PG_TIMESTAMPTZ_NATIVE_TYPE;
|
|
566
|
+
}
|
|
567
|
+
jsonProjection(expression) {
|
|
568
|
+
return CastExpr.as(expression, "text");
|
|
569
|
+
}
|
|
570
|
+
codecId = PG_TIMESTAMPTZ_STRING_CODEC_ID;
|
|
571
|
+
traits = ["equality", "order"];
|
|
572
|
+
targetTypes = [];
|
|
573
|
+
paramsSchema = precisionParamsSchema;
|
|
574
|
+
renderOutputType(params) {
|
|
575
|
+
return renderPrecision("TimestamptzString", params);
|
|
576
|
+
}
|
|
577
|
+
factory(_params) {
|
|
578
|
+
return () => new PgTimestamptzStringCodec(this);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
const pgTimestamptzStringDescriptor = new PgTimestamptzStringDescriptor();
|
|
582
|
+
var PgTimeStringCodec = class extends CodecImpl {
|
|
583
|
+
async encode(value, _ctx) {
|
|
584
|
+
return value;
|
|
585
|
+
}
|
|
586
|
+
async decode(wire, _ctx) {
|
|
587
|
+
return wire;
|
|
588
|
+
}
|
|
589
|
+
encodeJson(value) {
|
|
590
|
+
return value;
|
|
591
|
+
}
|
|
592
|
+
decodeJson(json) {
|
|
593
|
+
return blindCast(json);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
var PgTimeStringDescriptor = class extends PostgresCodecDescriptor {
|
|
597
|
+
nativeType() {
|
|
598
|
+
return PG_TIME_NATIVE_TYPE;
|
|
599
|
+
}
|
|
600
|
+
jsonProjection(expression) {
|
|
601
|
+
return CastExpr.as(expression, "text");
|
|
602
|
+
}
|
|
603
|
+
codecId = PG_TIME_STRING_CODEC_ID;
|
|
604
|
+
traits = ["equality", "order"];
|
|
605
|
+
targetTypes = [];
|
|
606
|
+
paramsSchema = precisionParamsSchema;
|
|
607
|
+
renderOutputType(params) {
|
|
608
|
+
return renderPrecision("TimeString", params);
|
|
609
|
+
}
|
|
610
|
+
factory(_params) {
|
|
611
|
+
return () => new PgTimeStringCodec(this);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
const pgTimeStringDescriptor = new PgTimeStringDescriptor();
|
|
363
615
|
const lengthParamsSchema = type({ "length?": "number.integer > 0" });
|
|
364
616
|
const numericParamsSchema = type({
|
|
365
617
|
"precision?": "number.integer > 0 & number.integer <= 1000",
|
|
366
618
|
"scale?": "number.integer >= 0"
|
|
367
619
|
});
|
|
368
|
-
const precisionParamsSchema = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
|
|
369
620
|
const PG_TEXT_NATIVE_TYPE = "text";
|
|
370
621
|
const PG_TEXT_ARRAY_NATIVE_TYPE = "text[]";
|
|
371
622
|
const PG_INT4_NATIVE_TYPE = "integer";
|
|
@@ -374,10 +625,6 @@ const PG_INT8_NATIVE_TYPE = "bigint";
|
|
|
374
625
|
const PG_FLOAT4_NATIVE_TYPE = "real";
|
|
375
626
|
const PG_FLOAT8_NATIVE_TYPE = "double precision";
|
|
376
627
|
const PG_NUMERIC_NATIVE_TYPE = "numeric";
|
|
377
|
-
const PG_DATE_NATIVE_TYPE = "date";
|
|
378
|
-
const PG_TIMESTAMP_NATIVE_TYPE = "timestamp without time zone";
|
|
379
|
-
const PG_TIMESTAMPTZ_NATIVE_TYPE = "timestamp with time zone";
|
|
380
|
-
const PG_TIME_NATIVE_TYPE = "time";
|
|
381
628
|
const PG_TIMETZ_NATIVE_TYPE = "timetz";
|
|
382
629
|
const PG_BOOL_NATIVE_TYPE = "boolean";
|
|
383
630
|
const PG_BIT_NATIVE_TYPE = "bit";
|
|
@@ -444,17 +691,6 @@ const base64JsonProjection = (expression) => FunctionCallExpr.of("translate", [
|
|
|
444
691
|
FunctionCallExpr.of("chr", [LiteralExpr.of(10)]),
|
|
445
692
|
LiteralExpr.of("")
|
|
446
693
|
]);
|
|
447
|
-
/**
|
|
448
|
-
* Projects a `timestamptz` as a UTC ISO-8601 string that no session setting can
|
|
449
|
-
* move.
|
|
450
|
-
*
|
|
451
|
-
* A `timestamptz` handed straight to a JSON constructor is rendered in the
|
|
452
|
-
* session's `TimeZone`, so the same stored instant reads as `+00:00`, `-05:00`
|
|
453
|
-
* or `+05:30` depending on who is connected. `timezone('UTC', …)` resolves the
|
|
454
|
-
* instant to UTC wall-clock independently of the session, and the explicit
|
|
455
|
-
* `to_char` format pins the rendering rather than inheriting `DateStyle`.
|
|
456
|
-
*/
|
|
457
|
-
const utcIsoJsonProjection = (expression) => FunctionCallExpr.of("to_char", [FunctionCallExpr.of("timezone", [LiteralExpr.of("UTC"), expression]), LiteralExpr.of("YYYY-MM-DD\"T\"HH24:MI:SS.MS\"+00:00\"")]);
|
|
458
694
|
const datePart = (field, expression) => FunctionCallExpr.of("date_part", [LiteralExpr.of(field), expression]);
|
|
459
695
|
const whenNonZero = (value, rendered) => CaseExpr.of([{
|
|
460
696
|
condition: BinaryExpr.neq(value, LiteralExpr.of(0)),
|
|
@@ -523,10 +759,6 @@ const postgresSqlTextDescriptor = postgresCodec(sqlTextDescriptor, {
|
|
|
523
759
|
nativeType: () => "text",
|
|
524
760
|
jsonProjection: identityJsonProjection
|
|
525
761
|
});
|
|
526
|
-
const postgresSqlTimestampDescriptor = postgresCodec(sqlTimestampDescriptor, {
|
|
527
|
-
nativeType: () => "timestamp",
|
|
528
|
-
jsonProjection: identityJsonProjection
|
|
529
|
-
});
|
|
530
762
|
var PgTextCodec = class extends CodecImpl {
|
|
531
763
|
async encode(value, _ctx) {
|
|
532
764
|
return value;
|
|
@@ -1099,145 +1331,6 @@ var PgUnboundedIntDescriptor = class extends PostgresCodecDescriptor {
|
|
|
1099
1331
|
};
|
|
1100
1332
|
const pgUnboundedIntDescriptor = new PgUnboundedIntDescriptor();
|
|
1101
1333
|
const pgUnboundedIntColumn = () => column(pgUnboundedIntDescriptor.factory(), pgUnboundedIntDescriptor.codecId, void 0, "numeric");
|
|
1102
|
-
/**
|
|
1103
|
-
* A Postgres `date` has no time-of-day or timezone component. This codec
|
|
1104
|
-
* canonicalizes its JS-level value as a `Date` at UTC midnight, so its
|
|
1105
|
-
* round-trip is independent of the process's local timezone — see
|
|
1106
|
-
* `pgDateEncode`/`pgDateDecode` in `codec-helpers.ts`.
|
|
1107
|
-
*/
|
|
1108
|
-
var PgDateCodec = class extends CodecImpl {
|
|
1109
|
-
async encode(value, _ctx) {
|
|
1110
|
-
return pgDateEncode(value);
|
|
1111
|
-
}
|
|
1112
|
-
async decode(wire, _ctx) {
|
|
1113
|
-
return pgDateDecode(wire);
|
|
1114
|
-
}
|
|
1115
|
-
encodeJson(value) {
|
|
1116
|
-
return pgDateEncodeJson(value);
|
|
1117
|
-
}
|
|
1118
|
-
decodeJson(json) {
|
|
1119
|
-
return pgDateDecodeJson(json);
|
|
1120
|
-
}
|
|
1121
|
-
};
|
|
1122
|
-
var PgDateDescriptor = class extends PostgresCodecDescriptor {
|
|
1123
|
-
nativeType() {
|
|
1124
|
-
return PG_DATE_NATIVE_TYPE;
|
|
1125
|
-
}
|
|
1126
|
-
jsonProjection(expression) {
|
|
1127
|
-
return expression;
|
|
1128
|
-
}
|
|
1129
|
-
codecId = PG_DATE_CODEC_ID;
|
|
1130
|
-
traits = ["equality", "order"];
|
|
1131
|
-
targetTypes = ["date"];
|
|
1132
|
-
paramsSchema = voidParamsSchema;
|
|
1133
|
-
factory() {
|
|
1134
|
-
return () => new PgDateCodec(this);
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1137
|
-
const pgDateDescriptor = new PgDateDescriptor();
|
|
1138
|
-
const pgDateColumn = () => column(pgDateDescriptor.factory(), pgDateDescriptor.codecId, void 0, "date");
|
|
1139
|
-
var PgTimestampCodec = class extends CodecImpl {
|
|
1140
|
-
async encode(value, _ctx) {
|
|
1141
|
-
return value;
|
|
1142
|
-
}
|
|
1143
|
-
async decode(wire, _ctx) {
|
|
1144
|
-
return wire;
|
|
1145
|
-
}
|
|
1146
|
-
encodeJson(value) {
|
|
1147
|
-
return pgTimestampEncodeJson(value);
|
|
1148
|
-
}
|
|
1149
|
-
decodeJson(json) {
|
|
1150
|
-
return pgTimestampDecodeJson(json);
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
var PgTimestampDescriptor = class extends PostgresCodecDescriptor {
|
|
1154
|
-
nativeType() {
|
|
1155
|
-
return PG_TIMESTAMP_NATIVE_TYPE;
|
|
1156
|
-
}
|
|
1157
|
-
jsonProjection(expression) {
|
|
1158
|
-
return expression;
|
|
1159
|
-
}
|
|
1160
|
-
codecId = PG_TIMESTAMP_CODEC_ID;
|
|
1161
|
-
traits = ["equality", "order"];
|
|
1162
|
-
targetTypes = ["timestamp"];
|
|
1163
|
-
paramsSchema = precisionParamsSchema;
|
|
1164
|
-
renderOutputType(params) {
|
|
1165
|
-
return renderPrecision("Timestamp", params);
|
|
1166
|
-
}
|
|
1167
|
-
factory(_params) {
|
|
1168
|
-
return () => new PgTimestampCodec(this);
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
const pgTimestampDescriptor = new PgTimestampDescriptor();
|
|
1172
|
-
const pgTimestampColumn = (params = {}) => column(pgTimestampDescriptor.factory(params), pgTimestampDescriptor.codecId, params, "timestamp");
|
|
1173
|
-
var PgTimestamptzCodec = class extends CodecImpl {
|
|
1174
|
-
async encode(value, _ctx) {
|
|
1175
|
-
return value;
|
|
1176
|
-
}
|
|
1177
|
-
async decode(wire, _ctx) {
|
|
1178
|
-
return wire;
|
|
1179
|
-
}
|
|
1180
|
-
encodeJson(value) {
|
|
1181
|
-
return pgTimestamptzEncodeJson(value);
|
|
1182
|
-
}
|
|
1183
|
-
decodeJson(json) {
|
|
1184
|
-
return pgTimestamptzDecodeJson(json);
|
|
1185
|
-
}
|
|
1186
|
-
};
|
|
1187
|
-
var PgTimestamptzDescriptor = class extends PostgresCodecDescriptor {
|
|
1188
|
-
nativeType() {
|
|
1189
|
-
return PG_TIMESTAMPTZ_NATIVE_TYPE;
|
|
1190
|
-
}
|
|
1191
|
-
jsonProjection(expression) {
|
|
1192
|
-
return utcIsoJsonProjection(expression);
|
|
1193
|
-
}
|
|
1194
|
-
codecId = PG_TIMESTAMPTZ_CODEC_ID;
|
|
1195
|
-
traits = ["equality", "order"];
|
|
1196
|
-
targetTypes = ["timestamptz"];
|
|
1197
|
-
paramsSchema = precisionParamsSchema;
|
|
1198
|
-
renderOutputType(params) {
|
|
1199
|
-
return renderPrecision("Timestamptz", params);
|
|
1200
|
-
}
|
|
1201
|
-
factory(_params) {
|
|
1202
|
-
return () => new PgTimestamptzCodec(this);
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
const pgTimestamptzDescriptor = new PgTimestamptzDescriptor();
|
|
1206
|
-
const pgTimestamptzColumn = (params = {}) => column(pgTimestamptzDescriptor.factory(params), pgTimestamptzDescriptor.codecId, params, "timestamptz");
|
|
1207
|
-
var PgTimeCodec = class extends CodecImpl {
|
|
1208
|
-
async encode(value, _ctx) {
|
|
1209
|
-
return value;
|
|
1210
|
-
}
|
|
1211
|
-
async decode(wire, _ctx) {
|
|
1212
|
-
return wire;
|
|
1213
|
-
}
|
|
1214
|
-
encodeJson(value) {
|
|
1215
|
-
return value;
|
|
1216
|
-
}
|
|
1217
|
-
decodeJson(json) {
|
|
1218
|
-
return json;
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
var PgTimeDescriptor = class extends PostgresCodecDescriptor {
|
|
1222
|
-
nativeType() {
|
|
1223
|
-
return PG_TIME_NATIVE_TYPE;
|
|
1224
|
-
}
|
|
1225
|
-
jsonProjection(expression) {
|
|
1226
|
-
return expression;
|
|
1227
|
-
}
|
|
1228
|
-
codecId = PG_TIME_CODEC_ID;
|
|
1229
|
-
traits = ["equality", "order"];
|
|
1230
|
-
targetTypes = ["time"];
|
|
1231
|
-
paramsSchema = precisionParamsSchema;
|
|
1232
|
-
renderOutputType(params) {
|
|
1233
|
-
return renderPrecision("Time", params);
|
|
1234
|
-
}
|
|
1235
|
-
factory(_params) {
|
|
1236
|
-
return () => new PgTimeCodec(this);
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
const pgTimeDescriptor = new PgTimeDescriptor();
|
|
1240
|
-
const pgTimeColumn = (params = {}) => column(pgTimeDescriptor.factory(params), pgTimeDescriptor.codecId, params, "time");
|
|
1241
1334
|
var PgTimetzCodec = class extends CodecImpl {
|
|
1242
1335
|
async encode(value, _ctx) {
|
|
1243
1336
|
return value;
|
|
@@ -1643,7 +1736,6 @@ const codecDescriptors = definePostgresCodecs([
|
|
|
1643
1736
|
postgresSqlIntDescriptor,
|
|
1644
1737
|
postgresSqlFloatDescriptor,
|
|
1645
1738
|
postgresSqlTextDescriptor,
|
|
1646
|
-
postgresSqlTimestampDescriptor,
|
|
1647
1739
|
pgTextDescriptor,
|
|
1648
1740
|
pgEnumDescriptor,
|
|
1649
1741
|
pgCharDescriptor,
|
|
@@ -1658,10 +1750,14 @@ const codecDescriptors = definePostgresCodecs([
|
|
|
1658
1750
|
pgFloat8Descriptor,
|
|
1659
1751
|
pgNumericDescriptor,
|
|
1660
1752
|
pgUnboundedIntDescriptor,
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1753
|
+
pgDateTemporalDescriptor,
|
|
1754
|
+
pgTimestampTemporalDescriptor,
|
|
1755
|
+
pgTimestamptzTemporalDescriptor,
|
|
1756
|
+
pgTimeTemporalDescriptor,
|
|
1757
|
+
pgDateStringDescriptor,
|
|
1758
|
+
pgTimestampStringDescriptor,
|
|
1759
|
+
pgTimestamptzStringDescriptor,
|
|
1760
|
+
pgTimeStringDescriptor,
|
|
1665
1761
|
pgTimetzDescriptor,
|
|
1666
1762
|
pgBoolDescriptor,
|
|
1667
1763
|
pgBitDescriptor,
|
|
@@ -1675,6 +1771,6 @@ const codecDescriptors = definePostgresCodecs([
|
|
|
1675
1771
|
pgTextArrayDescriptor
|
|
1676
1772
|
]);
|
|
1677
1773
|
//#endregion
|
|
1678
|
-
export {
|
|
1774
|
+
export { pgUuidColumn as C, postgresQualifyColumnType as E, pgUnboundedIntColumn as S, pgVarcharColumn as T, pgJsonColumn as _, pgCharColumn as a, pgTextColumn as b, pgFloat8Column as c, pgInt2Column as d, pgInt4Column as f, pgIntervalColumn as g, pgIntColumn as h, pgBoolColumn as i, pgFloatColumn as l, pgInt8NumberColumn as m, isPgEnumParams as n, pgEnumDescriptor as o, pgInt8Column as p, pgBitColumn as r, pgFloat4Column as s, codecDescriptors as t, pgInetColumn as u, pgJsonbColumn as v, pgVarbitColumn as w, pgTimetzColumn as x, pgNumericColumn as y };
|
|
1679
1775
|
|
|
1680
|
-
//# sourceMappingURL=codecs-
|
|
1776
|
+
//# sourceMappingURL=codecs-CxWg7WrX-DtVAuuXA.mjs.map
|