Commit ec73677
committed
fix: provide default getObject(Class) fallback in QueryJDBCAccessor
Replace the base-class stub that threw `Operation not supported`
unconditionally with a generic raw-Object + isInstance fallback. JDBC's
`ResultSet.getObject(int, Class<T>)` is documented to deliver the column
value as an instance of the requested type when the conversion is
trivial; pre-this-change every accessor that did not explicitly
implement typed conversion would throw, even for the identity case
(`getObject(col, String.class)` on a VARCHAR column). Callers had to
either special-case "accessor implements typed getObject" vs "does not"
or wrap the call in catch-and-retry.
The new default checks for null type, fetches the raw object, returns
null on null, returns the raw object cast to T when the type is
assignable, and otherwise raises a typed conversion error. Accessors
that need richer conversion (e.g. timestamp -> Instant /
OffsetDateTime / ZonedDateTime / LocalDateTime) still override and are
unaffected.
Bundles `StreamingResultSetMethodTest.getObjectWithClassUsesAccessorBaseFallback`
which pins the inherited path end-to-end on a VARCHAR column whose
accessor does not implement typed conversion. Existing
`QueryJDBCAccessorTest` continues to pass since it does not exercise
`getObject(Class)`; null-type rejection is already pinned by
`TimeStampVectorAccessorTest`.1 parent dd37a96 commit ec73677
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