Repository navigation
Commit bdff98b
authored
fix(jdbc): make getColumnClassName follow the current row (#66)
Closes #36. Part of #54.
## What changed
- `LibsqlResultSetMetaData.getColumnClassName` now reads the value at
the metadata cursor through the shared
`LibsqlResultSet.valueForMetadata` accessor added by #35, instead of
scanning every row for a column-wide class.
- A valid current row reports the current storage class: INTEGER in the
int range is `java.lang.Integer`, INTEGER outside it is
`java.lang.Long`, FLOAT is `java.lang.Double`, TEXT is
`java.lang.String`, and BLOB/NULL are `java.lang.Object`.
- Empty results and positions after the last row report
`java.lang.Object`.
- Removed the now-unused cross-row `integerClassName` and `isIntInRange`
helpers.
- Added behavior tests for an empty result and for a mixed-type column
(`select 1 union all select 'a'`) before cursor movement, on each row,
and after the last row, plus a current-row Integer-to-Long range check.
## Contract decision
Class metadata is cursor-local, matching xerial 3.53.4.0
`JDBC3ResultSet.getColumnClassName` (`JDBC3ResultSet.java:579-597`).
Empty results and end-of-results report `java.lang.Object`; otherwise
the class describes the value on the current row. Parity wins under #54.
One Steering detail does not match the pinned xerial behavior. Steering
says positions before the first row report `java.lang.Object`. I probed
xerial 3.53.4.0 directly: it preloads the first row during execute, so
before the first `next()` it reports that row's class
(`Integer`/`String` in a newly executed result set), not `Object`. The
vendored `RSMetaDataTest.testGetColumnClassName` asserts that preloaded
behavior, so returning `Object` before the first row would break the
conformance suite. This PR therefore follows the actual pinned xerial
behavior, which is the primary contract, and keeps conformance green.
## Evidence
Failing before the fix:
```text
$ ./mvnw -q -pl libsql-jdbc -am -Dtest=LibsqlResultSetMetaDataTest -Dsurefire.failIfNoSpecifiedTests=false test
[ERROR] Tests run: 16, Failures: 3, Errors: 0, Skipped: 0
[ERROR] LibsqlResultSetMetaDataTest.reportsObjectClassNameForEmptyResultSet:229
[column 1 before the first row] expected: "java.lang.Object" but was: "java.lang.Integer"
[ERROR] LibsqlResultSetMetaDataTest.reportsCurrentRowClassNameForMixedTypeColumn:253
[before the first row] expected: "java.lang.Integer" but was: "java.lang.String"
[ERROR] LibsqlResultSetMetaDataTest.reportsClassNameForCurrentRowOutsideIntRange:282
expected: "java.lang.Integer" but was: "java.lang.Long"
```
Passing after the fix:
```text
$ ./mvnw -pl libsql-jdbc -am test
Tests run: 83, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
```
```text
$ ./mvnw -pl libsql-conformance -am verify
Tests run: 115, Failures: 0, Errors: 0, Skipped: 1
BUILD SUCCESS
```
The conformance run includes the vendored xerial `RSMetaDataTest` (13
tests, all passed), confirming the before-first-row and mixed-column
behavior against live sqld.
```text
$ ./mvnw spotless:apply
BUILD SUCCESS (no formatting changes)
```
## Deviations
None from xerial 3.53.4.0. The literal Steering sentence about `Object`
before the first row is not what the pinned xerial does; see Contract
decision. Following it would regress the vendored conformance test, so
the PR keeps actual xerial parity instead.1 parent 486a6f4 commit bdff98b
2 files changed
Lines changed: 89 additions & 51 deletions
File tree
- libsql-jdbc/src
- main/java/com/github/magnusp/libsql/jdbc
- test/java/com/github/magnusp/libsql/jdbc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
| 345 | + | |
366 | 346 | | |
367 | 347 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
386 | 354 | | |
387 | | - | |
| 355 | + | |
388 | 356 | | |
389 | 357 | | |
390 | | - | |
| 358 | + | |
391 | 359 | | |
392 | 360 | | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 361 | + | |
397 | 362 | | |
398 | 363 | | |
399 | 364 | | |
| |||
458 | 423 | | |
459 | 424 | | |
460 | 425 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | 426 | | |
468 | 427 | | |
469 | 428 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
209 | 288 | | |
210 | 289 | | |
211 | 290 | | |
| |||
0 commit comments