Repository navigation
fix(jdbc): honor table types in getTables metadata - #84
Merged
Merged
Conversation
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.
Closes #41. Part of #54.
What changed
LibsqlDatabaseMetaData.getTablesnow builds the xerial-shaped union instead of selecting everysqlite_masterrow:sqlite_schemaSYSTEM TABLErow,UPPER(TYPE) IN ('TABLE', 'VIEW'),sqlite_temp_masterrows asGLOBAL TEMPORARY,sqlite_%rows asSYSTEM TABLE.typesargument is honored.nulland an empty array add no filter; a non-empty array is uppercased and emitted asTABLE_TYPE IN (...).nullor empty table-name pattern maps to%, matching xerial. Single quotes are still escaped, and the pattern usesLIKE ... ESCAPE '\'.nulltypes, an empty array,{"TABLE"},{"VIEW"}, mixed-case multiple types, an empty name pattern, and the existing quote-escape case.Contract decision
Parity with xerial 3.53.4.0
JDBC3DatabaseMetaData.getTables(lines 1682-1750). The union, theTABLE/VIEWuser-row filter, the system and temporary rows, thetypesfilter behavior, theLIKE ... ESCAPE '\'pattern handling, and theORDER BY TABLE_TYPE, TABLE_NAMEordering all match. No transport limitation required a different shape.Evidence
Tests were added first and failed on the pre-fix code:
Representative failures: the pre-fix SQL had no
sqlite_schema/SYSTEM TABLEbranch, nosqlite_temp_master/GLOBAL TEMPORARYbranch, noUPPER(TYPE) IN ('TABLE', 'VIEW')filter, noTABLE_TYPE IN (...)filter for{"TABLE"}/{"VIEW"}, and turned an empty pattern intoLIKE ''.After the fix:
The conformance run exercises real sqld and includes
MetadataLeakTest, which callsgetTables(null, null, null, null).I also executed the generated union against a real SQLite engine (xerial 3.53.4.0) with a table, a view, an index, a trigger, and a temp table. Null types returned
tmp(GLOBAL TEMPORARY),sqlite_schema(SYSTEM TABLE),t(TABLE), andv(VIEW);{"TABLE"}returned onlyt; the index and trigger never appeared../mvnw spotless:applycompleted successfully before the final commit.Deviations
none