fix: support getObject(Class) with identity class type in QueryJDBCAccessor#186
Open
mkaufmann wants to merge 1 commit into
Open
fix: support getObject(Class) with identity class type in QueryJDBCAccessor#186mkaufmann wants to merge 1 commit into
mkaufmann wants to merge 1 commit into
Conversation
3 tasks
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (75.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
============================================
- Coverage 82.37% 82.37% -0.01%
- Complexity 1867 1871 +4
============================================
Files 125 125
Lines 5009 5020 +11
Branches 537 540 +3
============================================
+ Hits 4126 4135 +9
- Misses 641 642 +1
- Partials 242 243 +1
🚀 New features to boost your workflow:
|
70b40d3 to
09593d6
Compare
KaviarasuSakthivadivel
approved these changes
May 11, 2026
bf0ced3 to
6817dde
Compare
QueryJDBCAccessor.getObject(Class) threw "Operation not supported" no matter what. That's a problem: JDBC says ResultSet.getObject(int, Class<T>) is supposed to return the value as T when the conversion is trivial, but every accessor that didn't override it would throw, even on the identity case like getObject(col, String.class) against a VARCHAR. Callers had to either know which accessors implement typed conversion or wrap calls in catch-and-retry. The new default covers the trivial cases: 1. null type -> SQLException with SQLState 22023. 2. String.class -> delegate to getString(). JDBC 4.2 Table B-5 mandates this conversion for every column type. 3. Otherwise raw + isInstance, accepting any supertype/interface match. wasNull is set defensively when the raw value is null so stale state from an earlier non-null read does not leak. 4. Anything left throws SQLFeatureNotSupportedException (matching the JDBC spec's expectation for unsupported conversions, and consistent with the existing TimeStampVectorAccessor override). Numeric narrowing (e.g. getObject(col, Integer.class) on a BIGINT column) is intentionally NOT handled here. The accessor-level primitive getters (getInt, getShort, getByte) use unchecked Java casts -- delegating to them would silently truncate Long.MAX_VALUE to -1 instead of refusing. Accessors that need lossless cross-type conversion override getObject(Class) (TimeStampVectorAccessor for the Instant / OffsetDateTime / LocalDateTime / etc. paths). Tests in StreamingResultSetMethodTest cover: - getObjectWithClassUsesAccessorBaseFallback: identity case (VARCHAR -> String) goes through the inherited String fast-path. - getObjectWithSupertypeOrInterfaceReturnsValue: Object.class and CharSequence.class both work via isInstance -- proves polymorphic callers (raw Object holders, generic tooling) aren't blocked. - getObjectWithNullClassThrows: null type parameter raises SQLException with the expected "must not be null" message. - getObjectWithIncompatibleClassThrows: requesting an unrelated type (String column, StringBuilder asked) raises the typed conversion error. - getObjectWithClassReturnsNullForNullValue: a null column value short-circuits and returns null regardless of the requested type; wasNull() is true afterwards.
6817dde to
f966f24
Compare
j10t
approved these changes
May 12, 2026
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.
QueryJDBCAccessor.getObject(Class)threwOperation not supportedeven for the identity type (like String for Varchar) which is highly surprising.The base class implementation now handles the trivial cases:
Tiftype.isInstance(raw), otherwise throw a typed conversion error.