Commit 70b40d3
committed
fix: provide default getObject(Class) fallback in QueryJDBCAccessor
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 does the obvious thing: reject null type with SQLState
22023, fetch the raw object, return null if it's null, return it cast
to T if type.isInstance(raw), otherwise throw a typed conversion
error. Accessors with richer needs (timestamp accessors return
Instant, OffsetDateTime, etc.) keep their overrides.
TimeStampVectorAccessor and TimeStampTZVectorAccessor are the two
that have them today.
Tests: getObjectWithClassUsesAccessorBaseFallback in
StreamingResultSetMethodTest exercises the inherited path on a
VARCHAR column. The existing QueryJDBCAccessorTest still passes since
it doesn't touch getObject(Class). Null-type rejection is already
pinned by TimeStampVectorAccessorTest and
TimeZoneIntegrationTest.testGetObjectWithNullTypeThrows.1 parent 092ac4d commit 70b40d3
2 files changed
Lines changed: 34 additions & 3 deletions
File tree
- jdbc-core/src
- main/java/com/salesforce/datacloud/jdbc/core/accessor
- test/java/com/salesforce/datacloud/jdbc/core
Lines changed: 22 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
197 | | - | |
198 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
199 | 218 | | |
200 | 219 | | |
201 | 220 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| |||
0 commit comments