2
0

Replace Status with Valid to conform to database/sql style

https://github.com/jackc/pgx/issues/1060
This commit is contained in:
Jack Christensen
2021-08-26 22:46:13 -05:00
parent 37044f47f5
commit 11d351dd75
156 changed files with 6909 additions and 7894 deletions
+86 -86
View File
@@ -13,41 +13,41 @@ func TestInt2ArrayTranscode(t *testing.T) {
&pgtype.Int2Array{
Elements: nil,
Dimensions: nil,
Status: pgtype.Present,
Valid: true,
},
&pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Status: pgtype.Null},
{Int: 1, Valid: true},
{},
},
Dimensions: []pgtype.ArrayDimension{{Length: 2, LowerBound: 1}},
Status: pgtype.Present,
Valid: true,
},
&pgtype.Int2Array{Status: pgtype.Null},
&pgtype.Int2Array{},
&pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Int: 2, Status: pgtype.Present},
{Int: 3, Status: pgtype.Present},
{Int: 4, Status: pgtype.Present},
{Status: pgtype.Null},
{Int: 6, Status: pgtype.Present},
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
{Int: 4, Valid: true},
{},
{Int: 6, Valid: true},
},
Dimensions: []pgtype.ArrayDimension{{Length: 3, LowerBound: 1}, {Length: 2, LowerBound: 1}},
Status: pgtype.Present,
Valid: true,
},
&pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Int: 2, Status: pgtype.Present},
{Int: 3, Status: pgtype.Present},
{Int: 4, Status: pgtype.Present},
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
{Int: 4, Valid: true},
},
Dimensions: []pgtype.ArrayDimension{
{Length: 2, LowerBound: 4},
{Length: 2, LowerBound: 2},
},
Status: pgtype.Present,
Valid: true,
},
})
}
@@ -60,103 +60,103 @@ func TestInt2ArraySet(t *testing.T) {
{
source: []int64{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: []int32{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: []int16{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: []int{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: []uint64{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: []uint32{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: []uint16{1},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: (([]int16)(nil)),
result: pgtype.Int2Array{Status: pgtype.Null},
result: pgtype.Int2Array{},
},
{
source: [][]int16{{1}, {2}},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 2}, {LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: [][][][]int16{{{{1, 2, 3}}}, {{{4, 5, 6}}}},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Int: 2, Status: pgtype.Present},
{Int: 3, Status: pgtype.Present},
{Int: 4, Status: pgtype.Present},
{Int: 5, Status: pgtype.Present},
{Int: 6, Status: pgtype.Present}},
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
{Int: 4, Valid: true},
{Int: 5, Valid: true},
{Int: 6, Valid: true}},
Dimensions: []pgtype.ArrayDimension{
{LowerBound: 1, Length: 2},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 3}},
Status: pgtype.Present},
Valid: true},
},
{
source: [2][1]int16{{1}, {2}},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 2}, {LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
},
{
source: [2][1][1][3]int16{{{{1, 2, 3}}}, {{{4, 5, 6}}}},
result: pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Int: 2, Status: pgtype.Present},
{Int: 3, Status: pgtype.Present},
{Int: 4, Status: pgtype.Present},
{Int: 5, Status: pgtype.Present},
{Int: 6, Status: pgtype.Present}},
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
{Int: 4, Valid: true},
{Int: 5, Valid: true},
{Int: 6, Valid: true}},
Dimensions: []pgtype.ArrayDimension{
{LowerBound: 1, Length: 2},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 3}},
Status: pgtype.Present},
Valid: true},
},
}
@@ -189,90 +189,90 @@ func TestInt2ArrayAssignTo(t *testing.T) {
}{
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
Valid: true,
},
dst: &int16Slice,
expected: []int16{1},
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
Valid: true,
},
dst: &uint16Slice,
expected: []uint16{1},
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
Valid: true,
},
dst: &namedInt16Slice,
expected: _int16Slice{1},
},
{
src: pgtype.Int2Array{Status: pgtype.Null},
src: pgtype.Int2Array{},
dst: &int16Slice,
expected: (([]int16)(nil)),
},
{
src: pgtype.Int2Array{Status: pgtype.Present},
src: pgtype.Int2Array{Valid: true},
dst: &int16Slice,
expected: []int16{},
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 2}, {LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
expected: [][]int16{{1}, {2}},
dst: &int16SliceDim2,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Int: 2, Status: pgtype.Present},
{Int: 3, Status: pgtype.Present},
{Int: 4, Status: pgtype.Present},
{Int: 5, Status: pgtype.Present},
{Int: 6, Status: pgtype.Present}},
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
{Int: 4, Valid: true},
{Int: 5, Valid: true},
{Int: 6, Valid: true}},
Dimensions: []pgtype.ArrayDimension{
{LowerBound: 1, Length: 2},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 3}},
Status: pgtype.Present},
Valid: true},
expected: [][][][]int16{{{{1, 2, 3}}}, {{{4, 5, 6}}}},
dst: &int16SliceDim4,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 2}, {LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
expected: [2][1]int16{{1}, {2}},
dst: &int16ArrayDim2,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{
{Int: 1, Status: pgtype.Present},
{Int: 2, Status: pgtype.Present},
{Int: 3, Status: pgtype.Present},
{Int: 4, Status: pgtype.Present},
{Int: 5, Status: pgtype.Present},
{Int: 6, Status: pgtype.Present}},
{Int: 1, Valid: true},
{Int: 2, Valid: true},
{Int: 3, Valid: true},
{Int: 4, Valid: true},
{Int: 5, Valid: true},
{Int: 6, Valid: true}},
Dimensions: []pgtype.ArrayDimension{
{LowerBound: 1, Length: 2},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 1},
{LowerBound: 1, Length: 3}},
Status: pgtype.Present},
Valid: true},
expected: [2][1][1][3]int16{{{{1, 2, 3}}}, {{{4, 5, 6}}}},
dst: &int16ArrayDim4,
},
@@ -295,39 +295,39 @@ func TestInt2ArrayAssignTo(t *testing.T) {
}{
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Status: pgtype.Null}},
Elements: []pgtype.Int2{{}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
Valid: true,
},
dst: &int16Slice,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: -1, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: -1, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}},
Status: pgtype.Present,
Valid: true,
},
dst: &uint16Slice,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}, {LowerBound: 1, Length: 2}},
Status: pgtype.Present},
Valid: true},
dst: &int16ArrayDim2,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 1}, {LowerBound: 1, Length: 2}},
Status: pgtype.Present},
Valid: true},
dst: &int16Slice,
},
{
src: pgtype.Int2Array{
Elements: []pgtype.Int2{{Int: 1, Status: pgtype.Present}, {Int: 2, Status: pgtype.Present}},
Elements: []pgtype.Int2{{Int: 1, Valid: true}, {Int: 2, Valid: true}},
Dimensions: []pgtype.ArrayDimension{{LowerBound: 1, Length: 2}, {LowerBound: 1, Length: 1}},
Status: pgtype.Present},
Valid: true},
dst: &int16ArrayDim4,
},
}