Repository navigation
[jdbc-v2] RowBinary writer: support the setObject overloads with a target SQL type - #3416
Open
polyglotAI-bot wants to merge 1 commit into
Open
polyglotAI-bot wants to merge 1 commit into
polyglotAI-bot wants to merge 1 commit into
Conversation
…rget SQL type With beta.row_binary_for_simple_insert=true, WriterStatementImpl threw "This form of setObject is not supported yet" for setObject(int, Object, int), setObject(int, Object, int, int) and the two SQLType overloads. Now they check the value with the same isValidForTargetType as PreparedStatementImpl and then store it the same way as setObject(int, Object). Fixes: #3408 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 2c79934. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
1 task
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
Closes #3408
With
beta.row_binary_for_simple_insert=true, the foursetObjectoverloads with a target SQL type now work in the RowBinary writer, the same as on the SQL path. Before, they failed with "This form of setObject is not supported yet", so frameworks that use them (for example SpringJdbcTemplatewithSqlParameterValue) could not insert. Cause: inWriterStatementImpl,setObject(int, Object, int),setObject(int, Object, int, int)and the twoSQLTypeoverloads had placeholder bodies that throw.PreparedStatementImpldoes:isValidForTargetType(x, type), then the same store assetObject(int, Object). The overloads callsetObject(int, Object), notwriter.setValue, so a conversion that is added there (for example fix(jdbc-v2): accept SQL Date in RowBinary inserts #3401 forjava.sql.Date) applies to them too.scaleOrLengthand the target type are not used for the conversion: the writer converts to the column type. On the SQL path,scaleOrLengthonly cuts aReader/InputStreamvalue.Not in this PR: a
ReaderorInputStreamvalue has the same problem with the typed overloads as withsetObject(int, Object)(#3415).Compatibility
Only calls that failed before change: the four overloads threw
SQLExceptionfor every value. Now they store the value, or throw the sameSQLExceptionas the SQL path for a value of a wrong class for aDATE,TIMEorTIMESTAMPtarget type. No change when the writer is off.PreparedStatementImpl.isValidForTargetTypechanges fromprivateto package-private, the smallest visibility that the writer needs; no public API changes.docs/features.mdhas the new behavior.Test
testTypedSetObjectWritesValues, one case for each overload: bindsInt32,Date,DateTime64(3, 'UTC'),Decimal(10, 2),String, aNULLNullable(Date)and a lastInt32through the writer, then reads the whole row back. The scale, the length and one target type do not match the value, to show that they are not used.testTypedSetObjectRejectsValueOfOtherType, one case for each overload: a value of a wrong class forDATE,TIMEandTIMESTAMPfails with the same message as on the SQL path. It replacestestTargetTypeMethodThrowException, which asserted that all four overloads throw (the bug).The new tests fail on
main.Checklist
history/latest/3408.md)🤖 Generated with Claude Code
Note
Medium Risk
Changes JDBC parameter binding on the beta RowBinary insert path used by common frameworks; behavior shifts from always failing to writing values with stricter date/time validation.
Overview
With
beta.row_binary_for_simple_insert=true, the RowBinary writer for simpleINSERT ... VALUES (?, …)now implements all foursetObjectoverloads that take a target SQL type (intorSQLType, with or withoutscaleOrLength). They previously always failed with "This form of setObject is not supported yet", which broke frameworks such as SpringJdbcTemplatewithSqlParameterValue.Each overload now mirrors the SQL prepared-statement path: it runs
isValidForTargetTypefor date/time targets, then delegates tosetObject(int, Object)so values are written via the RowBinary writer according to column type, not the declared JDBC type;scaleOrLengthis not used for conversion (same as the SQL path except stream truncation).PreparedStatementImpl.isValidForTargetTypeis widened to package visibility soWriterStatementImplcan reuse it. Docs and changelog describe the behavior; integration tests cover successful binds and type-mismatch errors for every overload.Reviewed by Cursor Bugbot for commit 2c79934. Bugbot is set up for automated code reviews on this repo. Configure here.