Skip to content

refactor(jdbc): extract SqliteDateTimeValues - #219

Merged
magnusp merged 1 commit into
mainfrom
refactor/i201-date-time-values
Oct 24, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/i201-date-time-values

Conversation

@magnusp

@magnusp magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Fixes #201

Extracts storage-class to date/time conversion from LibsqlResultSet into package-private SqliteDateTimeValues (from(Value, String targetType) plus epochMillisToLocalDateTime, julianDayToEpochMillis, parseSqliteDateTime, parseSqliteTime). A thin dateTimeValue(int, String) stays in the cursor layer: it still calls getCurrentValue(columnIndex) (which sets lastColumnIndex, so wasNull keeps working) and then delegates. getLocalDate, getLocalTime, and getLocalDateTime are unchanged.

Moved verbatim (normalized diff)

Compared the parent block (LibsqlResultSet.java lines 795-895 at 373b875: the switch body plus the four helpers) with the new class (from body plus helpers), normalizing only by dropping private from the four helper signatures and trimming trailing whitespace:

$ sed -E 's/\bprivate //g; s/[[:space:]]+$//' old_moved.txt > old_norm.txt
$ sed -E 's/\bprivate //g; s/[[:space:]]+$//' new_moved.txt > new_norm.txt
$ diff -u old_norm.txt new_norm.txt && echo "NORMALIZED DIFF: EMPTY"
NORMALIZED DIFF: EMPTY
$ sha256sum old_norm.txt new_norm.txt
53cfd1c36f62b74b9140c05100f017a4828570327ab79c25e315d911c49f4f50  old_norm.txt
53cfd1c36f62b74b9140c05100f017a4828570327ab79c25e315d911c49f4f50  new_norm.txt

No parse rule, default, message, or zone changed. BLOB still throws "Bad value for type " + targetType; blank text still returns null; bare time still defaults to 2000-01-01; offsets are honored only when the sign index exceeds nine; Z/z is UTC; conversion uses ZoneId.systemDefault(); exception wrapping keeps the original text; INTEGER epoch millis and REAL Julian day are untouched. No dependency, pom.xml, test, numeric-text, or LOB change.

Probe

Scratch edit changed the bare-time default in the moved code from LocalDate.of(2000, 1, 1) to LocalDate.of(1970, 1, 1):

LibsqlResultSetTest.bareTimeTextGetsTheYear2000DefaultDate -- FAILURE!
expected: 2000-01-01T10:30:45 (java.time.LocalDateTime)
 but was: 1970-01-01T10:30:45 (java.time.LocalDateTime)
	at ...LibsqlResultSetTest.bareTimeTextGetsTheYear2000DefaultDate(LibsqlResultSetTest.java:352)

Reverted. The new file's sha256 returned to the pre-probe value 80f18b5c…, git status --porcelain lists only the two intended paths, and git diff -- libsql-jdbc/src/test is empty, so the four wave-0 date/time tests stay green unedited.

Line counts

  • LibsqlResultSet.java: 912 → 809 (under 850)
  • SqliteDateTimeValues.java: 124 (new)
  • Diff stat: 2 files changed, 125 insertions(+), 104 deletions(-)

Lanes

  • ./mvnw -pl libsql-jdbc -am test → 392 tests, 0 failures, 0 errors
  • ./mvnw spotless:apply, then ./mvnw spotless:check → BUILD SUCCESS both
  • ./mvnw -pl libsql-conformance -am verify → 272 tests, 0 failures, 7 skipped

@magnusp

magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Root verdict: PASS at fd32836.

Verifier confirmed the moved methods are byte-identical, the four wave-0 date and time tests are unedited and green, and the cursor side effect is intact. A live probe on a NULL column returned null through every date getter with wasNull true, which is the getCurrentValue contract. 427 tests across the reactor and 272 conformance tests green. The bare-time probe bit and was reverted. Countersign: root, fd32836.

This completes wave 1 of the stack.

Base automatically changed from refactor/i200-numeric-text to main October 24, 2026 14:40
@magnusp
magnusp force-pushed the refactor/i201-date-time-values branch from fd32836 to e3a3eff Compare October 24, 2026 14:41
@magnusp
magnusp merged commit dd24437 into main Oct 24, 2026
6 checks passed
@magnusp
magnusp deleted the refactor/i201-date-time-values branch October 24, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract SqliteDateTimeValues from LibsqlResultSet

1 participant