Replies: 1 comment
-
Part of the reason for the I don't recommend this, but if you really need this alternative behavior, then you could copy json.go into your own project, make the changes, and then register the type on the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm considering converting a project from sql/db to pgx.
I store a lot of JSON types in my database using JSONB column type.
My Go structs have type converters like these:
The scanning fails with PGX because the data type passed into
Scan
is astring
not[]byte
.Rather than updating my code everywhere (error prone) I'd like to be able to scan JSONB columns as
[]byte
- is this possible?I've found the following code in
scanPlanSQLScanner
, any way to make it execute the branch forBinaryFormatCode
?I would even argue that maybe this is a bug and JSONB columns should be scanned as
[]byte
by default - but even if I have to call some sort of configuration function somehow, without the change to default behavior, that would be OK too.PS - I know that pgx can do JSON conversion automatically but there are some subtle differences and I'd like to continue with my custom conversion functions.
Beta Was this translation helpful? Give feedback.
All reactions