Skip to content

fix: correct DatabaseMetaData.getTableTypes() to return table type names#162

Open
KaviarasuSakthivadivel wants to merge 1 commit intomainfrom
fix/database-metadata-gettabletypes-bug
Open

fix: correct DatabaseMetaData.getTableTypes() to return table type names#162
KaviarasuSakthivadivel wants to merge 1 commit intomainfrom
fix/database-metadata-gettabletypes-bug

Conversation

@KaviarasuSakthivadivel
Copy link
Contributor

Bug: getTableTypes() was returning Map.toString() output instead of table type names, violating the JDBC specification.

Problem

DatabaseMetaData.getTableTypes() returns Map objects instead of table type names.

Current: {SCHEMAS=c.relkind = 'r'..., NOSCHEMAS=...}
Expected: TABLE, VIEW, INDEX

Fix

Changed entry.getValue() to entry.getKey() in QueryMetadataUtil.java:320

Added test to prevent regression.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.79%. Comparing base (f8d84ab) to head (840fafa).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #162   +/-   ##
=========================================
  Coverage     82.79%   82.79%           
  Complexity     1347     1347           
=========================================
  Files           111      111           
  Lines          4058     4058           
  Branches        413      413           
=========================================
  Hits           3360     3360           
  Misses          508      508           
  Partials        190      190           
Components Coverage Δ
JDBC Core 83.98% <100.00%> (ø)
JDBC Main 40.69% <ø> (ø)
JDBC HTTP 91.09% <ø> (ø)
JDBC Utilities 66.07% <ø> (ø)
Spark Datasource ∅ <ø> (∅)
Files with missing lines Coverage Δ
...esforce/datacloud/jdbc/core/QueryMetadataUtil.java 91.63% <100.00%> (ø)

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Bug: getTableTypes() was returning Map.toString() output instead of
table type names, violating the JDBC specification.

Root Cause: QueryMetadataUtil.constructTableTypesData() was using
entry.getValue() (Map<String,String>) instead of entry.getKey() (String).

Changes:
- Fix QueryMetadataUtil.java:320 - changed entry.getValue() to entry.getKey()
- Add test testGetTableTypesReturnsActualData() to verify correct behavior

Before fix:
  getString("TABLE_TYPE") returned:
  "{SCHEMAS=c.relkind = 'r' AND..., NOSCHEMAS=...}"

After fix:
  getString("TABLE_TYPE") returns:
  "TABLE", "VIEW", "INDEX", etc.

Impact:
- Fixes JDBC specification compliance
- Enables proper database tool integration (DBeaver, IntelliJ, etc.)
- Makes metadata introspection usable

Discovered during PR #136 review.
@KaviarasuSakthivadivel KaviarasuSakthivadivel force-pushed the fix/database-metadata-gettabletypes-bug branch from 4a7def1 to 840fafa Compare March 9, 2026 19: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.

2 participants