Repository navigation
refactor(jdbc): extract MetadataSql query builders - #228
Merged
Merged
Conversation
Move the metadata query builders and literal escaping out of
LibsqlDatabaseMetaData into a package-private MetadataSql. Argument
normalization and result shaping stay in the metadata class.
Every SQL string is byte-identical: the builders keep the original
construction, including the comma without a space in
IN ('TABLE','VIEW'), toUpperCase() without a locale, a null originSql
for getColumns, and empty types behaving like null.
LibsqlDatabaseMetaData 1057 -> 949 lines.
Fixes #207
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 #207
What changed
Wave 5a of the
LibsqlDatabaseMetaDatasplit. New package-privateMetadataSqlholdsliteral(String)and one builder per metadata query: tables, columns, imported keys, exported keys, primary keys, table types, schemas, catalogs, and index info. Argument normalization (null/empty pattern to%) and result shaping stay inLibsqlDatabaseMetaData.No SQL text changed, no test edited,
pom.xmluntouched.Preserved deliberately:
AND TABLE_TYPE IN ('TABLE','VIEW')(no space after the comma).types[i].toUpperCase()without a locale.getColumnsstill passes a nulloriginSql.typesstill behaves like null.Proof: generated SQL is byte-identical
Same throwaway probe (
MetadataSqlBytesProbe, untracked, deleted before commit) compiled in a worktree oforigin/mainand in this branch. It stubsLibsqlConnection.executeStatementto recordStmt.sql()for every builder over 8 patterns (null, ``,%, `t`, `O'Brien`, `t'x`, `TABLE`, `sqlite_%`) x 5 type sets (`null`, `{}`, `{"TABLE"}`, `{"table","View"}`, `{"it's","SYSTEM TABLE"}`), both `getIndexInfo` unique modes, and cross-reference with null/child/parent tables.106,822 bytes of generated SQL per side, equal byte for byte. The existing assertions (
TABLE_NAME LIKE 'O''Brien',UPPER(TYPE) IN ('TABLE', 'VIEW'),AND TABLE_TYPE IN ('TABLE','VIEW'),'sqlite_schema' AS TABLE_NAME,ORDER BY t.TABLE_RANK, t.TABLE_NAME, p.cid) and the stub dispatch onJOIN pragma_foreign_key_list/FROM pragma_foreign_key_list/FROM pragma_table_infoalso pass unchanged.Probe: a changed SQL byte fails a test
Mutated the types separator to
sql.append(", ")inMetadataSql.tables:Reverted; the lane below is on the reverted head.
Line counts
LibsqlDatabaseMetaData.java: 1057 -> 949 (-108; acceptance: under 950).MetadataSql.java: 133 new.Lanes
./mvnw -pl libsql-jdbc -am test:Tests run: 396, Failures: 0, Errors: 0, Skipped: 0— BUILD SUCCESS../mvnw spotless:applythen./mvnw spotless:check: BUILD SUCCESS../mvnw -pl libsql-conformance -am verify:Tests run: 272, Failures: 0, Errors: 0, Skipped: 7— BUILD SUCCESS.