Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil byte array []byte(nil) is encoded as empty byte array []byte([]) instead of nil #1163

Open
YesYouKenSpace opened this issue Jul 11, 2024 · 0 comments

Comments

@YesYouKenSpace
Copy link

YesYouKenSpace commented Jul 11, 2024

Hello,

Actual

Seems like lib/pq changes []byte(nil) to []byte([]) before storing it in the database
Refer to

pq/encode.go

Line 589 in 3d61320

func encodeBytea(serverVersion int, v []byte) (result []byte) {
and

pq/encode.go

Line 31 in 3d61320

func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) []byte {

Expected

It should be encoded to nil and store as NULL in the database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant