IsZero() now returns true if string is valid but blank

This commit is contained in:
Gregory Roseberry 2014-08-29 11:09:04 +09:00
parent 37ab5072cf
commit 8ba2f90d14
2 changed files with 6 additions and 1 deletions

View file

@ -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 == ""
}

View file

@ -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) {