2
0

Convert int4 and int8 to new system

Note: purposely disabled some tests and composite support that needs to
be restored later in v5 development.
This commit is contained in:
Jack Christensen
2022-01-01 17:16:03 -06:00
parent 40fb889605
commit 0c0e28a70a
36 changed files with 1568 additions and 4267 deletions
+2 -63
View File
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"os"
"reflect"
"strconv"
"strings"
"testing"
@@ -263,70 +262,9 @@ func TestConnQueryReadRowMultipleTimes(t *testing.T) {
require.Equal(t, int32(10), rowCount)
}
// https://github.com/jackc/pgx/issues/386
func TestConnQueryValuesWithMultipleComplexColumnsOfSameType(t *testing.T) {
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, conn)
expected0 := &pgtype.Int8Array{
Elements: []pgtype.Int8{
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
},
Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}},
Valid: true,
}
expected1 := &pgtype.Int8Array{
Elements: []pgtype.Int8{
{Int: 4, Valid: true},
{Int: 5, Valid: true},
{Int: 6, Valid: true},
},
Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}},
Valid: true,
}
var rowCount int32
rows, err := conn.Query(context.Background(), "select '{1,2,3}'::bigint[], '{4,5,6}'::bigint[] from generate_series(1,$1) n", 10)
if err != nil {
t.Fatalf("conn.Query failed: %v", err)
}
defer rows.Close()
for rows.Next() {
rowCount++
values, err := rows.Values()
if err != nil {
t.Fatalf("rows.Values failed: %v", err)
}
if len(values) != 2 {
t.Errorf("Expected rows.Values to return 2 values, but it returned %d", len(values))
}
if !reflect.DeepEqual(values[0], *expected0) {
t.Errorf(`Expected values[0] to be %v, but it was %v`, *expected0, values[0])
}
if !reflect.DeepEqual(values[1], *expected1) {
t.Errorf(`Expected values[1] to be %v, but it was %v`, *expected1, values[1])
}
}
if rows.Err() != nil {
t.Fatalf("conn.Query failed: %v", err)
}
if rowCount != 10 {
t.Error("Select called onDataRow wrong number of times")
}
}
// https://github.com/jackc/pgx/issues/228
func TestRowsScanDoesNotAllowScanningBinaryFormatValuesIntoString(t *testing.T) {
t.Skip("TODO - unskip later in v5")
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
@@ -431,6 +369,7 @@ func TestConnQueryCloseEarlyWithErrorOnWire(t *testing.T) {
// Test that a connection stays valid when query results read incorrectly
func TestConnQueryReadWrongTypeError(t *testing.T) {
t.Skip("TODO - unskip later in v5")
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))