2
0

Allow empty hstore keys

See pgx commit: 56f4f0b9d3
This commit is contained in:
Jack Christensen
2019-05-20 16:26:58 -05:00
parent 99fd636b8e
commit 3294a8cf1f
2 changed files with 4 additions and 7 deletions
+3 -7
View File
@@ -297,13 +297,9 @@ func parseHstore(s string) (k []string, v []Text, err error) {
case hsKey:
switch r {
case '"': //End of the key
if buf.Len() == 0 {
err = errors.New("Empty Key is invalid")
} else {
keys = append(keys, buf.String())
buf = bytes.Buffer{}
state = hsSep
}
keys = append(keys, buf.String())
buf = bytes.Buffer{}
state = hsSep
case '\\': //Potential escaped character
n, end := p.Consume()
switch {
+1
View File
@@ -19,6 +19,7 @@ func TestHstoreTranscode(t *testing.T) {
&pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("bar"), "baz": text("quz")}, Status: pgtype.Present},
&pgtype.Hstore{Map: map[string]pgtype.Text{"NULL": text("bar")}, Status: pgtype.Present},
&pgtype.Hstore{Map: map[string]pgtype.Text{"foo": text("NULL")}, Status: pgtype.Present},
&pgtype.Hstore{Map: map[string]pgtype.Text{"": text("bar")}, Status: pgtype.Present},
&pgtype.Hstore{Status: pgtype.Null},
}