Repository navigation
fix(db): case-tolerant schema/table filters in DBMetadataInspector (H2 v2 uppercase fallback) - #3
Open
emmanuelbruno wants to merge 1 commit into
Open
emmanuelbruno wants to merge 1 commit into
emmanuelbruno wants to merge 1 commit into
Conversation
JDBC metadata lookups match filters exactly; H2 v2 stores unquoted identifiers UPPERCASE (postgres lowercase) so a wrong-case filter silently yielded empty metadata. Probe as-given first (behavior and ordering unchanged when it matches), then UPPER, then lower.
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.
Why — the H2 v2 uppercase trap
JDBC
DatabaseMetaDatalookups match the schema/table filters exactly — no case folding. H2 v2 stores unquoted identifiers UPPERCASE; postgres stores them natively lowercase.DBMetadataInspector.inspectpassed the%%rdbmsSchemacell filter strings verbatim tomd.getColumns/getPrimaryKeys/getIndexInfo/getImportedKeys/getTables(bytecode-verified in the shippedIJava-v1.4.6-pr12.jar; source call sites in this file, reached fromJavaDBMSMagics.java:315) → a lowercase filter against an H2EMPLOYEEStable yields empty metadata and the entity renders without attributes/columns — silently. Postgres is unaffected (names natively lowercase, filters typically lowercase too).ebpro lab workaround so far is content-side only (write the body-line filter uppercase, e.g.
EMPLOYEESunderPUBLIC) — it works but forces lesson authors to know each store's identifier case policy. This PR obsoletes that.Change
Case-tolerant filter resolution inside
DBMetadataInspector.inspect(the minimal-touch location — it fans out to all six metadata queries, so fixing the callerJavaDBMSMagics:315alone would leave the other query paths and any future callers exposed):UPPERthenlower(Locale.ROOT).getColumnsprobe only in the currently-broken empty case).TableMetadatadisplay name keeps the as-given value; only query filters are resolved.%enumeration) match rows as-given → untouched.The resolved
fSchema/fTablereplace the verbatim arguments in the five JDBC metadata calls and the threeinformation_schemaprepared statements (constraints / check constraints / domains — H2'sinformation_schemalikewise stores the uppercase name).Tests
New
DBMetadataInspectorCaseTest(H2 is already on the test classpath —build.gradle:testImplementation 'com.h2database:h2:2.2.220', JUnit 4):IDfirst);Local:
./gradlew :test --tests 'io.github.spencerpark.ijava.magics.DBMetadataInspectorCaseTest'green; full:test --tests 'io.github.spencerpark.ijava.magics.*'green (Temurin JDK 25, Gradle 9.7.1).Base note
Branches from
chore/build-correctness(tip = tagv1.4.6-pr12, the lineage that produces the shipped jar).masterpredatesDBMetadataInspectorentirely, so it cannot host this change.