Fix scanning negative ints into Int64Scanner
This commit is contained in:
+3
-3
@@ -552,7 +552,7 @@ func (scanPlanBinaryInt2ToInt64Scanner) Scan(src []byte, dst interface{}) error
|
||||
return fmt.Errorf("invalid length for int2: %v", len(src))
|
||||
}
|
||||
|
||||
n := int64(binary.BigEndian.Uint16(src))
|
||||
n := int64(int16(binary.BigEndian.Uint16(src)))
|
||||
|
||||
return s.ScanInt64(Int8{Int: n, Valid: true})
|
||||
}
|
||||
@@ -1100,7 +1100,7 @@ func (scanPlanBinaryInt4ToInt64Scanner) Scan(src []byte, dst interface{}) error
|
||||
return fmt.Errorf("invalid length for int4: %v", len(src))
|
||||
}
|
||||
|
||||
n := int64(binary.BigEndian.Uint32(src))
|
||||
n := int64(int32(binary.BigEndian.Uint32(src)))
|
||||
|
||||
return s.ScanInt64(Int8{Int: n, Valid: true})
|
||||
}
|
||||
@@ -1670,7 +1670,7 @@ func (scanPlanBinaryInt8ToInt64Scanner) Scan(src []byte, dst interface{}) error
|
||||
return fmt.Errorf("invalid length for int8: %v", len(src))
|
||||
}
|
||||
|
||||
n := int64(binary.BigEndian.Uint64(src))
|
||||
n := int64(int64(binary.BigEndian.Uint64(src)))
|
||||
|
||||
return s.ScanInt64(Int8{Int: n, Valid: true})
|
||||
}
|
||||
|
||||
+1
-1
@@ -439,7 +439,7 @@ func (scanPlanBinaryInt<%= pg_byte_size %>ToInt64Scanner) Scan(src []byte, dst i
|
||||
}
|
||||
|
||||
|
||||
n := int64(binary.BigEndian.Uint<%= pg_bit_size %>(src))
|
||||
n := int64(int<%= pg_bit_size %>(binary.BigEndian.Uint<%= pg_bit_size %>(src)))
|
||||
|
||||
return s.ScanInt64(Int8{Int: n, Valid: true})
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ func TestInt2Codec(t *testing.T) {
|
||||
{int(1), new(int16), isExpectedEq(int16(1))},
|
||||
{uint(1), new(int16), isExpectedEq(int16(1))},
|
||||
{pgtype.Int2{Int: 1, Valid: true}, new(int16), isExpectedEq(int16(1))},
|
||||
{int32(-1), new(pgtype.Int2), isExpectedEq(pgtype.Int2{Int: -1, Valid: true})},
|
||||
{1, new(int8), isExpectedEq(int8(1))},
|
||||
{1, new(int16), isExpectedEq(int16(1))},
|
||||
{1, new(int32), isExpectedEq(int32(1))},
|
||||
@@ -102,6 +103,7 @@ func TestInt4Codec(t *testing.T) {
|
||||
{int(1), new(int32), isExpectedEq(int32(1))},
|
||||
{uint(1), new(int32), isExpectedEq(int32(1))},
|
||||
{pgtype.Int4{Int: 1, Valid: true}, new(int32), isExpectedEq(int32(1))},
|
||||
{int32(-1), new(pgtype.Int4), isExpectedEq(pgtype.Int4{Int: -1, Valid: true})},
|
||||
{1, new(int8), isExpectedEq(int8(1))},
|
||||
{1, new(int16), isExpectedEq(int16(1))},
|
||||
{1, new(int32), isExpectedEq(int32(1))},
|
||||
@@ -182,6 +184,7 @@ func TestInt8Codec(t *testing.T) {
|
||||
{int(1), new(int64), isExpectedEq(int64(1))},
|
||||
{uint(1), new(int64), isExpectedEq(int64(1))},
|
||||
{pgtype.Int8{Int: 1, Valid: true}, new(int64), isExpectedEq(int64(1))},
|
||||
{int32(-1), new(pgtype.Int8), isExpectedEq(pgtype.Int8{Int: -1, Valid: true})},
|
||||
{1, new(int8), isExpectedEq(int8(1))},
|
||||
{1, new(int16), isExpectedEq(int16(1))},
|
||||
{1, new(int32), isExpectedEq(int32(1))},
|
||||
|
||||
@@ -22,6 +22,7 @@ func TestInt<%= pg_byte_size %>Codec(t *testing.T) {
|
||||
{int(1), new(int<%= pg_bit_size %>), isExpectedEq(int<%= pg_bit_size %>(1))},
|
||||
{uint(1), new(int<%= pg_bit_size %>), isExpectedEq(int<%= pg_bit_size %>(1))},
|
||||
{pgtype.Int<%= pg_byte_size %>{Int: 1, Valid: true}, new(int<%= pg_bit_size %>), isExpectedEq(int<%= pg_bit_size %>(1))},
|
||||
{int32(-1), new(pgtype.Int<%= pg_byte_size %>), isExpectedEq(pgtype.Int<%= pg_byte_size %>{Int: -1, Valid: true})},
|
||||
{1, new(int8), isExpectedEq(int8(1))},
|
||||
{1, new(int16), isExpectedEq(int16(1))},
|
||||
{1, new(int32), isExpectedEq(int32(1))},
|
||||
|
||||
Reference in New Issue
Block a user