Skip to content

Fix #6472: map SQLite column types by affinity, not driver JDBC type#7564

Open
sramazzina wants to merge 1 commit into
apache:mainfrom
sramazzina:fix-6472-sqlite-datatype-affinity
Open

Fix #6472: map SQLite column types by affinity, not driver JDBC type#7564
sramazzina wants to merge 1 commit into
apache:mainfrom
sramazzina:fix-6472-sqlite-datatype-affinity

Conversation

@sramazzina

Copy link
Copy Markdown
Contributor

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 generic ValueMetaBase mapper 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

SqliteDatabaseMeta now overrides customizeValueFromSqlType to re-derive the Hop value type from SQLite's name-based affinity, 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)

Tests

  • Unit tests for the affinity mapping.
  • End-to-end test driving the real SQLite JDBC driver with the exact DDL from the report.

All sqlite module tests pass locally (./mvnw -pl plugins/databases/sqlite -DskipITs test): 12 tests, 0 failures, 0 errors.

Closes #6472

… 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.
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.

[Bug]: Wrong datatypes in SQLiteDB when specified with size in DB

1 participant