-
Notifications
You must be signed in to change notification settings - Fork 855
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
breaking change in v5: Value() no longer called on nil args #1367
Comments
I think the v5 behavior is correct. To be honest I'm surprised that was v4's behavior. This means that pointer to a Furthermore, allowing typed
That's fair. I've added a note (a968ce3). |
I wonder how other |
We have this assumption spread across our codebase, so it's currently blocking our upgrade to v5. We have non-null constraints on our JSONB columns, preferring a JSON Does anyone happen to have a workaround, to restore the old behavior? |
@joshma Sorry, but I don't think there is an easy way to do this. The typed nil into nil conversion happens early in the encoding process and the rest of the system expects to not receive any typed nils. ... I started writing about the harder way to do this, but as I thought about it a little more, I determined it wouldn't work either. So I actually don't know any way to do this. |
😢 - well I appreciate the time and consideration! |
Describe the bug
v5 introduced this line https://github.com/jackc/pgx/blob/master/extended_query_builder.go#L25 with the result being that
Valuer.Value()
is no longer called onnil
arguments.To Reproduce
I have some types like the following:
and a column like
things JSONB NOT NULL
. In v4, if I passedMyThings(nil)
as a query arg,Value()
would be called and an empty JSONB array would be stored. In v5,Value()
is not called and I end up with an error:Expected behavior
Valuer.Value()
should be called on typednil
values. Otherwise, this breaking change should be described in the changelog.Actual behavior
This line https://github.com/jackc/pgx/blob/master/extended_query_builder.go#L25 turns all types
nil
s intonil
interfaces, which prevents callingValuer.Value()
.Version
go version go1.19.2 darwin/amd64
PostgreSQL 14.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219, 64-bit
v5.0.4
Additional context
Question: I'm planning on eventually moving to the pgx native interface. Would I encounter the same behavior there, or would I be able to provide default values for
nil
s?The text was updated successfully, but these errors were encountered: