Repository navigation
refactor(jdbc): extract TableMetadataResolver - #223
Merged
Merged
Conversation
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #205
What moved
Package-private
TableMetadataResolvernow owns the connection, the SQL, the column count, the lazy resolution state, and theLinkedHashMaptable cache.tableForColumn(int)is the single entry point for the three callers (isAutoIncrement,isNullable,getTableName).LibsqlResultSetMetaData.java: 375 → 227 lines (limit: 300).TableMetadataResolver.java: 174 lines.Verbatim move
Normalized diff of the moved region (strip
privateon moved members,cols.size()→columnCount). The only difference is the entry point's bounds check, which replacesgetCol(column)because the resolver holds the column count rather than theCollist:Everything else is byte-identical after normalization, including the
tableContextResolved/columnOriginsfields, thecontainsKey/putnegative cache, the temp-before-main fallback, both SQL strings (hidden != 1,COLLATE NOCASE), the lowercased cache key with the original-case name returned, and thenew ArrayList<>(info.columns().keySet())list copy in theSqlTableReference.resolvecallback.toTableInfoandtextmoved with their only callers.The attached-schema and ghost-schema tests in
LibsqlResultSetMetaDataTestare unedited and green.Probe
No repository test models
pragma_table_xinfohidden = 1columns (virtual-table hidden columns), so the mutation was checked with a scratch FTS5 star-width probe against the pinned sqld (ghcr.io/tursodatabase/libsql-server:v0.24.33), not committed:CREATE VIRTUAL TABLE docs USING fts5(title, body), thenSELECT * FROM docs→getTableName(1) == "docs"→ PASS.AND p.hidden != 1from the main/temploadTableInfo(String, String)query → resolver column map width 4 vs protocol star width 2 →getTableName(1) == ""→AssertionError.git status --shortshows only the two intended files.The attached-schema query keeps the same predicate and was left intact during the probe.
tableContextResolvedvscolumnOrigins == nullNo existing test distinguishes the two. The observable difference is only that a resolved-null state would re-run resolution on every call instead of once, and no test counts or observes resolution calls. The separate boolean is preserved by inspection.
Lanes
./mvnw -pl libsql-jdbc -am test./mvnw spotless:applythen./mvnw spotless:check./mvnw -pl libsql-conformance -am verify