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

fix(conn): properly inspect interfaces for nil values #838

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

epelc
Copy link
Contributor

@epelc epelc commented Mar 15, 2019

Fixes #773 by further inspecting arguments to check if they are nil interfaces or slices.

Sending a nil byte slice use to not work because it was a nil value of type []byte which != nil hence it would really send an empty byte slice. This prevented you from setting columns to null unless you had a different path to send an explicit nil which also had no type(confusing and a pain to implement). Checking interface values equal nil is a common bug in go which usually requires using the reflect package to further inspect the interface's actual value is nil since the typing usually isn't.

This does slightly slow down writes theoretically but it should be worth it for such a common use case and standard feature of sending nil.

@dynajoe
Copy link

dynajoe commented May 7, 2020

I have a similar issue. What's the best way to go since this PR has been open over a year?

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

Successfully merging this pull request may close these issues.

inserting []byte(nil) to bytea is not treated as NULL
2 participants