Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuple scan respects both value and pointer variable #971

Merged
merged 4 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/column/tuple.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ func (col *Tuple) Row(i int, ptr bool) any {
// if this happens we have an unexplained problem
return nil
}
return value
if ptr {
return value
}
return tuple.Elem().Interface()
}

func setJSONFieldValue(field reflect.Value, value reflect.Value) error {
Expand Down
2 changes: 1 addition & 1 deletion tests/issues/762_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ func Test762Std(t *testing.T) {
)
require.NoError(t, rows.Scan(&n))
expected := []any{(*any)(nil)}
require.Equal(t, &expected, n)
require.Equal(t, expected, n)
}
}
14 changes: 7 additions & 7 deletions tests/std/tuples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ func TestTuple(t *testing.T) {
)
require.NoError(t, conn.QueryRow("SELECT * FROM test_tuple").Scan(&col1, &col2, &col3, &col4, &col5, &col6, &col7))
assert.NoError(t, err)
assert.Equal(t, ToJson(col1Data), ToJson(col1))
assert.Equal(t, ToJson(col2Data), ToJson(col2))
assert.JSONEq(t, ToJson(col3Data), ToJson(col3))
assert.Equal(t, ToJson(col4Data), ToJson(col4))
assert.Equal(t, ToJson(col5Data), ToJson(col5))
assert.Equal(t, ToJson(col6Data), ToJson(col6))
assert.Equal(t, ToJson(col7Data), ToJson(col7))
assert.Equal(t, col1Data, col1)
assert.Equal(t, col2Data, col2)
assert.Equal(t, col3Data, col3)
assert.Equal(t, col4Data, col4)
assert.Equal(t, col5Data, col5)
assert.Equal(t, col6Data, col6)
assert.Equal(t, *col7Data, col7)
}