-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Insert NULL for []byte(nil) values #147
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
Conversation
LGTM after you add a test... 😏 |
Also reordered the tests so that the general tests are on top
PTAL at the new test. I reordered the tests so that the general tests are on top and fail first. Any objections against this change? |
I'd prefer to put (future) reorderings into an extra PR and keep functional and layout changes separate. |
PTAL, I found another bug: Empty strings / |
@@ -632,40 +632,31 @@ func skipLengthEnodedString(b []byte) (int, error) { | |||
return n, io.EOF | |||
} | |||
|
|||
func readLengthEncodedInteger(b []byte) (num uint64, isNull bool, n int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave these in please. They are a pretty concise documentation of what is returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still prefer the short form below. We don't have to use the vars, I just like to keep them.
LGTM when Travis says so |
Insert NULL for []byte(nil) values
This patch makes a behavior change for inserting data into a database:
Currently
[]byte(nil)
is treated the same way as[]byte{}
/[]byte("")
, which equals an empty string.This relies on the current language specification: http://golang.org/ref/specThis PR changes to behavior to treat
[]byte(nil)
as NULL values, therefore the same way asinterface{}(nil)
.Here is why:
Both
[]byte(nil)
andinterface{}(nil)
are converted to[]byte(nil)
by the database/sql package if the destination has the type[]byte
. This matches the new behavior.Fixes #144