Merge pull request #396 from ikawaha/fix/hstore_20150302

Fixed a bug that panic occurs when the value is null
This commit is contained in:
Jinzhu 2015-03-03 13:47:33 +08:00
commit 3740a3beaa
1 changed files with 6 additions and 1 deletions

View File

@ -112,7 +112,12 @@ func (h Hstore) Value() (driver.Value, error) {
}
for key, value := range h {
hstore.Map[key] = sql.NullString{String: *value, Valid: true}
var s sql.NullString
if value != nil {
s.String = *value
s.Valid = true
}
hstore.Map[key] = s
}
return hstore.Value()
}