Fix #6472: map SQLite column types by affinity, not driver JDBC type#7564
Open
sramazzina wants to merge 1 commit into
Open
Fix #6472: map SQLite column types by affinity, not driver JDBC type#7564sramazzina wants to merge 1 commit into
sramazzina wants to merge 1 commit into
Conversation
… type The SQLite JDBC driver reports columns whose declared type carries a size with a space before the parenthesis (e.g. "TEXT (50)") as Types.NUMERIC. The generic ValueMetaBase mapper then turns those into BigNumber/Integer, so the Database Explorer showed TEXT (50) as BigNumber instead of String (and, by the same mechanism, INTEGER (20) and REAL (10) were mistyped). Override customizeValueFromSqlType in SqliteDatabaseMeta to re-derive the Hop value type from SQLite's name-based type affinity (datatype3.html section 3.1), which the driver still reports correctly, correcting only the columns the generic mapper got wrong: - CHAR/CLOB/TEXT -> String - INT -> Integer - REAL/FLOA/DOUB -> Number - NUMERIC/BLOB -> unchanged (generic mapping kept) Add unit tests for the affinity mapping plus an end-to-end test that drives the real SQLite JDBC driver with the exact DDL from the report.
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.
What
Fixes #6472. SQLite columns whose declared type carries a size written with a space before the parenthesis (e.g.
TEXT (50),INTEGER (20),REAL (10)) were mistyped in the Database Explorer:TEXT (50)showed up as BigNumber instead of String, and the numeric variants were mistyped too.Why
The SQLite JDBC driver reports those columns as
Types.NUMERIC, so the genericValueMetaBasemapper turns them into BigNumber/Integer. The column's declared name-based type affinity (SQLite datatype3.html §3.1), which the driver still reports correctly, is the reliable signal.How
SqliteDatabaseMetanow overridescustomizeValueFromSqlTypeto re-derive the Hop value type from SQLite's name-based affinity, correcting only the columns the generic mapper got wrong:CHAR/CLOB/TEXT-> StringINT-> IntegerREAL/FLOA/DOUB-> NumberNUMERIC/BLOB-> unchanged (generic mapping kept)Tests
All sqlite module tests pass locally (
./mvnw -pl plugins/databases/sqlite -DskipITs test): 12 tests, 0 failures, 0 errors.Closes #6472