sqlite-jdbc icon indicating copy to clipboard operation
sqlite-jdbc copied to clipboard

Revisit ResultSetMetaData results

Open vdshb opened this issue 5 months ago • 1 comments

Methods

  • ResultSetMetaData::getColumnDisplaySize
  • ResultSetMetaData::getPrecision
  • ResultSetMetaData::getScale

For different column types like Types.INTEGER, Types.BIGINT, Types.VARCHAR often return 0 or Integer.MAX_VALUE instead of meaningful values.

This is a proposal to revisit this metadata methods and return meaningful values based on SQL-type.

E.g. for Types.VARCHAR ::getColumnDisplaySize result should be equal to ::getPrecision result. E.g. for Types.INTEGER ::getPrecision result might be equal to 10 instead of current 0 (10 decimal digits max - PostgreSQL's approach). E.g. for Types.INTEGER ::getColumnDisplaySize result might be equal to 11 instead of current Integer.MAX_VALUE (10 digits + potential minus sign - PostgreSQL's approach). E.g. for Types.BIGINT ::getPrecision result might be equal to 19 instead of current 0 (19 decimal digits max - PostgreSQL's approach). E.g. for Types.BIGINT ::getColumnDisplaySize result might be equal to 20 instead of current Integer.MAX_VALUE (19 digits + potential minus sign - PostgreSQL's approach).

vdshb avatar Aug 31 '25 08:08 vdshb

SQLite does not have column types, just column hints. As such any column could contain any value, even if there's a hint in the column name.

gotson avatar Sep 01 '25 01:09 gotson