@@ -297,13 +297,9 @@ func parseHstore(s string) (k []string, v []Text, err error) {
|
|||||||
case hsKey:
|
case hsKey:
|
||||||
switch r {
|
switch r {
|
||||||
case '"': //End of the key
|
case '"': //End of the key
|
||||||
if buf.Len() == 0 {
|
keys = append(keys, buf.String())
|
||||||
err = errors.New("Empty Key is invalid")
|
buf = bytes.Buffer{}
|
||||||
} else {
|
state = hsSep
|
||||||
keys = append(keys, buf.String())
|
|
||||||
buf = bytes.Buffer{}
|
|
||||||
state = hsSep
|
|
||||||
}
|
|
||||||
case '\\': //Potential escaped character
|
case '\\': //Potential escaped character
|
||||||
n, end := p.Consume()
|
n, end := p.Consume()
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -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{"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{"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{"foo": text("NULL")}, Status: pgtype.Present},
|
||||||
|
&pgtype.Hstore{Map: map[string]pgtype.Text{"": text("bar")}, Status: pgtype.Present},
|
||||||
&pgtype.Hstore{Status: pgtype.Null},
|
&pgtype.Hstore{Status: pgtype.Null},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user