Skip to content

Supports scanning of Array, IPv4, IPv6, and Map types into Go values that implement the sql.Scanner interface. #1570

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

Merged
merged 18 commits into from
Jun 13, 2025

Conversation

zapateo
Copy link
Contributor

@zapateo zapateo commented Jun 6, 2025

Summary

Supports scanning of Array, IPv4, IPv6, and Map types into Go values that implement the sql.Scanner interface.

Checklist

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

Does the TYPES.md file need to be updated? I couldn't figure it out.

@CLAassistant
Copy link

CLAassistant commented Jun 6, 2025

CLA assistant check
All committers have signed the CLA.

@mshustov mshustov requested review from Copilot and SpencerTorres June 9, 2025 11:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for scanning Array, IPv4, IPv6, and Map types into Go values implementing the sql.Scanner interface. The key changes include:

  • New test cases for SQL scanner support for Array, IPv4, IPv6, and Map types.
  • Updated ScanRow implementations in lib/column files to handle sql.Scanner.
  • Minor improvements to error handling and consistency in test assertions.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/map_test.go Added TestSQLScannerMap to validate scanning for map types.
tests/ipv6_test.go Introduced TestSQLScannerIPv6 and updated import order.
tests/ipv4_test.go Introduced TestSQLScannerIPv4 and verified IPv4 scanning functionality.
tests/array_test.go Added TestSQLScannerArray and test enhancements for array scanning.
lib/column/map.go Updated ScanRow to support sql.Scanner for map columns.
lib/column/ipv6.go Updated ScanRow to support sql.Scanner for IPv6 columns.
lib/column/ipv4.go Updated ScanRow to support sql.Scanner for IPv4 columns.
lib/column/array.go Updated ScanRow to support sql.Scanner for arrays.

require.NoError(t, batch.Append(col1Data))
}
require.Equal(t, 10, batch.Rows())
require.Nil(t, batch.Send())
Copy link
Preview

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For consistency with other tests, consider replacing require.Nil(t, batch.Send()) with require.NoError(t, batch.Send()).

Suggested change
require.Nil(t, batch.Send())
require.NoError(t, batch.Send())

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test added in this PR follows the structure of a test that was already in the repository (TestInterfaceArray), so I would maintain consistency between the two tests. I would suggest making this change separately, if necessary, outside of this PR, in order to update it in the other test and potentially in other areas as well.

Comment on lines 409 to 412
ok := assert.ObjectsAreEqual(col1Data, col1.value)
if !ok {
t.Fatalf("expected %#v, got %#v", col1Data, col1.value)
}
Copy link
Preview

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] To maintain consistency with similar tests, use assert.Equal(t, col1Data, col1.value) instead of a manual equality check and t.Fatalf block.

Suggested change
ok := assert.ObjectsAreEqual(col1Data, col1.value)
if !ok {
t.Fatalf("expected %#v, got %#v", col1Data, col1.value)
}
assert.Equal(t, col1Data, col1.value, "expected and actual values do not match")

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@SpencerTorres SpencerTorres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👌

@SpencerTorres SpencerTorres merged commit 8bf4552 into ClickHouse:main Jun 13, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants