Skip to content

Commit 6717713

Browse files
committed
fix pg string json handling
1 parent 84f1df2 commit 6717713

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/orm/src/client/crud/dialects/postgresql.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ export class PostgresCrudDialect<Schema extends SchemaDef> extends BaseCrudDiale
5858
: value,
5959
)
6060
.with('Decimal', () => (value !== null ? value.toString() : value))
61+
.with('Json', () => {
62+
if (typeof value === 'string') {
63+
// Postgres string JSON needs to be quoted
64+
return `"${value}"`;
65+
} else if (typeof value === 'number') {
66+
// Postgres number JSON needs to be in string form
67+
return value.toString();
68+
} else {
69+
return value;
70+
}
71+
})
6172
.otherwise(() => value);
6273
}
6374
}

0 commit comments

Comments
 (0)