Skip to content

Inconsistent display of CAST(1 AS REAL) between SQLite3 Fiddle and SQLite JDBC #1389

@wwk4j4cj6t-stack

Description

@wwk4j4cj6t-stack

Describe the bug
During using we observed an inconsistency between the result presentation in SQLite3 Fiddle and SQLite JDBC when executing the following query:

SELECT CAST(1 AS REAL);

Observed Behavior

  • SQLite3 Fiddle returns: 1.0
  • SQLite JDBC returns: 1

This difference initially appears to be only a formatting issue. However, it can lead to confusion in downstream processing.

To Reproduce
Execute the following SQL expression:

SELECT length(CAST(1 AS REAL));

The result is: 3

This indicates that internally SQLite treats the value as the string representation "1.0" when computing length().
However, when retrieving the value through SQLite JDBC, the displayed result is 1, where the decimal part is omitted. This discrepancy between the displayed value (1) and the internal string representation ("1.0") can easily lead to misunderstandings during debugging and data processing.

Expected behavior
Consistent formatting or representation across SQLite3 Fiddle and SQLite JDBC when retrieving REAL values, so developers are not misled into assuming:

length(CAST(1 AS REAL)) = 1

based on the JDBC output.
Environment (please complete the following information):

  • OS: Windows 24H2
  • CPU architecture: x86_64
  • sqlite-jdbc version 3.51.2

Additional context
Although this behavior may stem from client-side formatting decisions, the inconsistency between the displayed value in JDBC and the internal value used by SQLite functions may introduce subtle issues in applications that rely on string-based processing or debugging assumptions.

For example, developers might expect:

length(CAST(1 AS REAL)) = 1

based on the JDBC output (1), while SQLite actually evaluates it based on "1.0".

Suggestion
It may be helpful to clarify this behavior in the documentation or ensure consistent formatting across interfaces, especially when values are retrieved through JDBC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions