mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 20:16:35 +00:00
fix(db): handle PG JSONB as native objects in j() mapper
PG returns JSONB columns as native JS objects, not strings. j() helper only handled strings via JSON.parse, returning the fallback for objects. Now passes through objects/arrays directly. Fixes pairing extras (kiosk_key_plaintext), capabilities, scopes, and all other JSONB fields. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f4be3ee901
commit
edf3c2e2eb
1 changed files with 2 additions and 0 deletions
|
|
@ -14,6 +14,8 @@ export function B(value: boolean): 0 | 1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function j<T>(value: unknown, fallback: T): T {
|
export function j<T>(value: unknown, fallback: T): T {
|
||||||
|
if (value == null) return fallback;
|
||||||
|
if (typeof value === "object" || Array.isArray(value)) return value as T;
|
||||||
if (typeof value !== "string" || value.length === 0) return fallback;
|
if (typeof value !== "string" || value.length === 0) return fallback;
|
||||||
try {
|
try {
|
||||||
return JSON.parse(value) as T;
|
return JSON.parse(value) as T;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue