mirror of
https://github.com/jackc/pgx.git
synced 2025-05-30 11:14:05 +00:00
Fix parsing text array with negative bounds
e.g. '[-4:-2]={1,2,3}' fixes #132
This commit is contained in:
parent
b72f8084b5
commit
2caf113f1b
2
array.go
2
array.go
@ -305,7 +305,7 @@ func arrayParseInteger(buf *bytes.Buffer) (int32, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if '0' <= r && r <= '9' {
|
||||
if ('0' <= r && r <= '9') || r == '-' {
|
||||
s.WriteRune(r)
|
||||
} else {
|
||||
buf.UnreadRune()
|
||||
|
@ -100,6 +100,14 @@ func TestParseUntypedTextArray(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
source: "[-4:-2]={1,2,3}",
|
||||
result: pgtype.UntypedTextArray{
|
||||
Elements: []string{"1", "2", "3"},
|
||||
Quoted: []bool{false, false, false},
|
||||
Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: -4}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
|
Loading…
x
Reference in New Issue
Block a user