Repository navigation
Conversation
…verter
DataTypeConverter.dateToString formatted a java.sql.Date as an instant in
UTC. java.sql.Date.valueOf("2022-01-04") is midnight in the JVM default
time zone, so in a zone east of UTC the result was the previous day
("2022-01-03"). Use java.sql.Date.toLocalDate() instead.
Add a test that runs with several JVM default time zones, so that the
bug is found also when the build runs in UTC.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Auto-approved by the AI review gate on 9918a80. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
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
DataTypeConverterTest.testDateToStringfails when the JVM default time zone is east of UTC (for exampleEurope/Berlin):expected [2022-01-04] but found [2022-01-03]. CI runs in UTC, so it does not find this.Cause:
DataTypeConverter.dateToStringformats ajava.sql.Dateas an instant in UTC. Ajava.sql.Dateis a local date:java.sql.Date.valueOf("2022-01-04")is midnight in the JVM default time zone, which is2022-01-03T23:00ZinEurope/Berlin. So in each zone east of UTC, the result is the previous day.Fix: format
java.sql.Date.toLocalDate(). The result is now the same date in all JVM time zones.Behavior change: only the
java.sql.Datebranch ofDataTypeConverter.dateToStringchanges. In zones east of UTC, it now returns the correct date, not the previous day. In UTC and west of UTC, the result does not change.getString()on aDatecolumn changes the value toLocalDatebefore this method, so that path does not change.jdbc-v2does not callDataTypeConverter.Tests: the new test
testSqlDateToStringDoesNotDependOnDefaultTimeZonesets the JVM default time zone (UTC−11 to UTC+14) and sets it back after each run. With the old code, it fails for the 3 zones east of UTC, also when the build runs in UTC.mvn -pl client-v2 verifywithTZ=Europe/Berlin: 1001 unit and 1896 integration tests pass.🤖 Generated with Claude Code
Note
Low Risk
Narrow fix to one branch in date string conversion; behavior change only affects java.sql.Date in Date columns when JVM TZ is east of UTC, with dedicated unit tests.
Overview
DataTypeConverter.dateToStringno longer formatsjava.sql.Dateby convertinggetTime()to a UTC instant. It now usestoLocalDate(), so ClickHouseDate/Date32string output matches the calendar day implied byjava.sql.Date.valueOf(...), independent of JVM default time zone.In zones east of UTC, the old path could emit the previous day (e.g.
2022-01-04→2022-01-03inEurope/Berlin); UTC and west-of-UTC behavior is unchanged for typical cases.Adds
testSqlDateToStringDoesNotDependOnDefaultTimeZone, parameterized across UTC−11 through UTC+14, to lock in timezone-stable formatting.Reviewed by Cursor Bugbot for commit 9918a80. Bugbot is set up for automated code reviews on this repo. Configure here.
Appended by monosoul, 2026-12-02 13:34 CET:
Closes #3497
Addition to "Behavior change": applications can also reach this branch directly through
DataTypeConverter.INSTANCE.convertToStringandarrayToString(#2897 givesarrayToStringas a workaround for array query parameters). In zones east of UTC, these now also return the correct date.