IsZero() now returns true if string is valid but blank
This commit is contained in:
parent
37ab5072cf
commit
8ba2f90d14
2 changed files with 6 additions and 1 deletions
|
@ -73,5 +73,5 @@ func (s String) Pointer() *string {
|
|||
|
||||
// IsZero returns true for null strings, for future omitempty support. (Go 1.4?)
|
||||
func (s String) IsZero() bool {
|
||||
return !s.Valid
|
||||
return !s.Valid || s.String == ""
|
||||
}
|
||||
|
|
|
@ -103,6 +103,11 @@ func TestIsZero(t *testing.T) {
|
|||
if !null.IsZero() {
|
||||
t.Errorf("IsZero() should be true")
|
||||
}
|
||||
|
||||
empty := NewString("", true)
|
||||
if !empty.IsZero() {
|
||||
t.Errorf("IsZero() should be true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestScan(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue