Skip to content

refactor(jdbc): extract DeclaredType parsing - #222

Merged
magnusp merged 1 commit into
mainfrom
refactor/i204-declared-type
Oct 24, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/i204-declared-type

Conversation

@magnusp

@magnusp magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Summary

Collapse declared-type parsing into one package-private value object.

  • DeclaredType.of(Col) owns the declared-type-or-cast-fallback lookup.
  • typeName(), precision(), scale(), and isDeclared() hold the moved matcher blocks.
  • LibsqlResultSetMetaData.getPrecision, getScale, getColumnTypeName, and isSigned delegate.
  • columnName(Col) stays in the metadata class.

No regex, throw type, message, or locale changed. No test assertion edited. Only moves plus the named delegations.

Fixes #204

Moved logic (normalized diff)

Bodies compared against HEAD with indentation, blank lines, and now-field-initializer lines normalized away. The pattern block and three of the four bodies are identical; only the factory's return wraps the unchanged body.

== patterns
(identical after whitespace/blank-line normalization)

== declType -> of
--- LibsqlResultSetMetaData
+++ DeclaredType
@@ -6,4 +6,4 @@
 declType = matcher.find() ? matcher.group(1) : null;
 }
 }
-return declType;
+return new DeclaredType(declType);

== getColumnTypeName -> typeName
(identical after whitespace/blank-line normalization)

== getPrecision -> precision
(identical after whitespace/blank-line normalization)

== getScale -> scale
(identical after whitespace/blank-line normalization)

Probe

Trimmed the returned type name in DeclaredType.typeName() (matcher.group(1).trim().toUpperCase(...)):

LibsqlResultSetMetaDataTest.preservesWhitespaceInDeclaredTypeNames -- FAILURE!
expected: "  NUMERIC  "
 but was: "NUMERIC"
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Reverted the probe. git status --short afterwards shows only the two intended source changes, and the full lane is green again.

Line counts

File Before After
LibsqlResultSetMetaData.java 417 375
DeclaredType.java — 68

Lanes

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

@magnusp
magnusp merged commit 61e9579 into main Oct 24, 2026
4 of 5 checks passed
@magnusp
magnusp deleted the refactor/i204-declared-type branch October 24, 2026 15:22
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 DeclaredType parsing from LibsqlResultSetMetaData

1 participant