Repository navigation
Conversation
With beta.row_binary_for_simple_insert=true, setObject(i, java.sql.Date) on a Date/Date32 column failed at addBatch() with "Cannot convert <date> to Long", while setDate worked and setObject worked on the default text path. WriterStatementImpl.setObject passes the value straight to the RowBinary serializer, and SerializerUtils.writeDate/writeDate32 only accepted LocalDate, ZonedDateTime and OffsetDateTime. writeDateTime already accepts java.sql.Timestamp, so Date was inconsistent. Convert java.sql.Date to LocalDate first, matching setDate. Fixes #3386 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Docs drift check: this PR looks like it needs doc updates.
|
There was a problem hiding this comment.
Auto-approved by the AI review gate on f9f1994. 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
|
TriageCategory: Summary What this impacts
Concerns
Required reviewer action
|
There was a problem hiding this comment.
Auto-approved by the AI review gate on 3bef9b3. Details in the approver's comment on this pull request.
…st (#3386) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| public static void writeDate(OutputStream output, Object value, ZoneId targetTz) throws IOException { | ||
| int epochDays = 0; | ||
| if (value instanceof java.sql.Date) { | ||
| value = ((java.sql.Date) value).toLocalDate(); |
There was a problem hiding this comment.
java.sql.Date carries a timestamp so coverting into local date is unsafe (we do not know value origin)
client-v2 deliberately do not work with java.sql.Date / Time / Timestamp because it is old API and has a lot issues within. Application should handle it because it understands better what value is.
chernser
left a comment
There was a problem hiding this comment.
Conversion should be done in JDBC not in the client default path.
proper tests should be added where different default timezone is used.
Summary
With
beta.row_binary_for_simple_insert=true,PreparedStatement.setObject(i, java.sql.Date)on aDateorDate32column fails ataddBatch()withIllegalArgumentException: Cannot convert <date> to Long. The same value works throughsetDate, and throughsetObjecton the default text path. Because jdbc-v2's ownResultSet.getObjectreturnsjava.sql.Datefor aDatecolumn, an app that reads rows withgetObjectand re-inserts them withsetObjectworks today and breaks once the RowBinary writer is enabled.Fixes #3386.
Cause
WriterStatementImpl.setObjectpasses the value straight toRowBinaryFormatWriter, andSerializerUtils.writeDate/writeDate32accept onlyLocalDate,ZonedDateTimeandOffsetDateTime.writeDateTimealready acceptsjava.sql.Timestamp, soDatewas simply the inconsistent one.Fix
Convert a
java.sql.DatetoLocalDateat the top ofwriteDateandwriteDate32, mirroring howsetDateconverts it and howwriteDateTimealready handlesTimestamp. Four lines, no behaviour change for the types already accepted.Testing
JDBCDateTimeTests.testSetObjectJavaSqlDateRowBinaryWriter, coveringsetObject(java.sql.Date)onDate,Date32, and nested inArray,TupleandNullable.DateandDate32ranges, leap days, and a seeded random sample), inserting each through bothsetObjectandsetDateand confirming the stored values are identical, plus the nestedArray/Map/Tuple/Nullablecases.🤖 Generated with Claude Code
Note
Low Risk
Small, localized type-coercion change in date serialization with regression tests and no impact on already-supported types.
Overview
Fixes RowBinary insert failures when
PreparedStatement.setObjectis used withjava.sql.Datewhilebeta.row_binary_for_simple_insertis enabled.SerializerUtils.writeDateandwriteDate32now normalizejava.sql.DatetoLocalDatebefore encoding, matching existing JDBC handling and aligning with how datetime serialization already accepts SQL types. Behavior forLocalDate,ZonedDateTime, andOffsetDateTimeis unchanged.Adds an integration regression test that inserts
java.sql.DateviasetObjectintoDate/Date32and nestedArray,Tuple,Nullable, andMapcolumns under the RowBinary writer, plus a short changelog note for #3386.Reviewed by Cursor Bugbot for commit c77faff. Bugbot is set up for automated code reviews on this repo. Configure here.