Open legitmaxwu opened 1 month ago
to work around this for now, either create a customJsonb
type like this:
import { customType } from "drizzle-orm/pg-core";
const jsonb = customType<{
data: unknown;
driverData: string;
config: undefined;
}>({
dataType() {
return `jsonb`;
},
fromDriver(value: string): unknown {
return value;
},
toDriver(value: unknown): string {
return JSON.stringify(value);
},
});
OR remove JSON.parse
from node-postgres's jsonb type parser via:
import { types } from "pg";
types.setTypeParser(types.builtins.JSONB, (val) => val);
What version of
drizzle-orm
are you using?0.33.0
What version of
drizzle-kit
are you using?0.23.0
Describe the Bug
I'm using drizzle + node postgres.
When I store a string e.g.
"10.5"
under a jsonb column, I expect it to be returned as "10.5" in string format. Instead it's returned as 10.5This is probably because node-postgres does JSON.parse once, and then the jsonb column does it again.
Expected behavior
When I store a string e.g.
"10.5"
under a jsonb column, I expect it to be returned as "10.5" in string format.Environment & setup
drizzle + node postgres computer: macos