mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 21:26:33 +00:00
fix(db): handle PG Date objects in string mappers
PG driver returns TIMESTAMPTZ as JS Date objects. The s() and sn() mapper helpers only checked for typeof string, returning null/empty for Date objects. This broke consumed_at check in pairing (always null), expires_at comparisons (Invalid Date), and all other timestamp fields. Now: Date instances are converted to ISO strings via toISOString(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c91f9cb450
commit
f4be3ee901
1 changed files with 2 additions and 2 deletions
|
|
@ -59,8 +59,8 @@ import { b, j } from "./util.js";
|
||||||
|
|
||||||
type Row = Record<string, unknown>;
|
type Row = Record<string, unknown>;
|
||||||
|
|
||||||
const s = (v: unknown): string => (typeof v === "string" ? v : "");
|
const s = (v: unknown): string => (typeof v === "string" ? v : v instanceof Date ? v.toISOString() : String(v ?? ""));
|
||||||
const sn = (v: unknown): string | null => (typeof v === "string" ? v : null);
|
const sn = (v: unknown): string | null => (v == null ? null : typeof v === "string" ? v : v instanceof Date ? v.toISOString() : null);
|
||||||
const n = (v: unknown): number => (typeof v === "number" ? v : Number(v) || 0);
|
const n = (v: unknown): number => (typeof v === "number" ? v : Number(v) || 0);
|
||||||
const nn = (v: unknown): number | null =>
|
const nn = (v: unknown): number | null =>
|
||||||
v === null || v === undefined ? null : typeof v === "number" ? v : Number(v) || null;
|
v === null || v === undefined ? null : typeof v === "number" ? v : Number(v) || null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue