Repository navigation
fix(jdbc-v2): read Date/DateTime/Time array elements as java.time types via getObject(i, Class) - #3311
Open
pcbeingused333 wants to merge 1 commit into
Open
fix(jdbc-v2): read Date/DateTime/Time array elements as java.time types via getObject(i, Class)#3311pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…es via getObject(i, Class) Fixes ClickHouse#3284
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.
Fixes #3284
Summary
ArrayResultSet#getObject(int, Class)looks up the target class in theValueConvertersmap for the element's source type. Forjava.sql.Date,java.sql.Timeandjava.sql.Timestampthat map only had the identity andStringconversions, so asking forLocalDate,LocalTimeorLocalDateTimeon the result set fromArray#getResultSet()threwValue of class java.sql.Date cannot be converted to class java.time.LocalDate, although the same call works on a regular row ResultSet.This adds
Date -> LocalDate,Time -> LocalTimeandTimestamp -> LocalDateTimeconverters toValueConverters, using the JDK'stoLocalDate()/toLocalTime()/toLocalDateTime()(the array elements are built withDate/Time/Timestamp.valueOf(...), so this round-trips exactly).New
ArrayResultSetTest#testJavaTimeConversions(Date32, DateTime64(6) and Time arrays, including a null element) fails on main with the error from the issue and passes with the change; the rest ofArrayResultSetTeststill passes (41 tests).Not covered here: the millisecond rounding of
Time64array elements stored asjava.sql.Timementioned in the issue comments.Checklist
history/latest/3284.md)This change was prepared with the assistance of an AI coding tool (Claude Code), and the author is responsible for it.
Note
Low Risk
Small, additive converter mappings in shared client code with unit tests; no auth, security, or persistence changes.
Overview
Fixes
ResultSet#getObject(int, Class)on the result set fromjava.sql.Array#getResultSet()so array elements stored asjava.sql.Date,Time, andTimestampcan be read asjava.time.LocalDate,LocalTime, andLocalDateTime—matching behavior on ordinary row result sets.ValueConvertersnow registers those java.time targets for the three JDBC temporal types and implements conversion via the JDKtoLocalDate()/toLocalTime()/toLocalDateTime()helpers.Adds
ArrayResultSetTest#testJavaTimeConversions(Date32, DateTime64(6), Time arrays, including nulls) and a CHANGELOG note inhistory/latest/3284.md.Reviewed by Cursor Bugbot for commit bcf40b1. Bugbot is set up for automated code reviews on this repo. Configure here.