fix(jdbc-v2): render array contents for named tuples - #3046
Open
014-code wants to merge 1 commit into
Open
Conversation
Fixes ClickHouse#3045. Render nested JDBC Array values with deep formatting so array-of-tuple results are readable to clients that use ResultSet#getObject().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Arrayvalues display their nested contents.Array(Tuple(...))values with named tuple elements.java.sql.Arrayreturn type andgetArray()behavior.CHANGELOG.md.Problem
When JDBC v2 returned an array containing a named tuple, clients such as IntelliJ IDEA could display the value as:
com.clickhouse.jdbc.types.Array@54c3b772
For example:
SELECT [('550e8400-e29b-41d4-a716-446655440000')::Tuple(id UUID)];
The actual contents were available through
java.sql.Array#getArray(), but the JDBC wrapper inheritedObject#toString(), which produced an unreadable class name and identity hash.Fixes #3045.
Changes
com.clickhouse.jdbc.types.Array#toString()now uses deep array formatting viaArrays.deepToString(...).The value is now rendered as:
[[550e8400-e29b-41d4-a716-446655440000]]
Nested arrays and tuple values are also rendered correctly.
Compatibility
No public API signatures, JDBC return types, or array contents were changed.
This change only improves the textual representation returned by
com.clickhouse.jdbc.types.Array#toString().Tests
Added:
ArrayTest#testToStringForArrayOfNamedTuplesArray(Tuple(id UUID)).ArrayTupleIntegrationTest#testArrayOfNamedAndUnnamedTuplesToStringResultSet#getObject()returnsjava.sql.Array.toString()matches the contents returned byArray#getArray().