diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f73ed19c..07cae0754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## unreleased +- SQLite query results preserve the full 64-bit range of `INTEGER` values. ([#1636](https://github.com/sqlpage/SQLPage/issues/1636)) - Big number title links have a larger target for touch and pointer users. - Carousel slide indicators and pagination arrows now have accessible names. Keyboard users can activate carousel arrows and enabled pagination links. Screen readers announce the current page. - Button, card, carousel, and login images accept alternative text. Embedded card frames use their own title or the card title. diff --git a/src/webserver/database/sql_to_json.rs b/src/webserver/database/sql_to_json.rs index 386c833bd..e3ed24b56 100644 --- a/src/webserver/database/sql_to_json.rs +++ b/src/webserver/database/sql_to_json.rs @@ -159,9 +159,10 @@ pub(super) fn sql_nonnull_to_json<'r>( match type_name { "REAL" | "FLOAT" | "FLOAT4" | "FLOAT8" | "DOUBLE" => decode_raw::(raw_value).into(), "NUMERIC" | "DECIMAL" => decimal_to_json(&decode_raw(raw_value)), - "INT8" | "BIGINT" | "SERIAL8" | "BIGSERIAL" | "IDENTITY" | "INT64" | "INTEGER8" - | "BIGINT SIGNED" => decode_raw::(raw_value).into(), - "INT" | "INT4" | "INTEGER" | "MEDIUMINT" | "YEAR" => decode_raw::(raw_value).into(), + // SQLite INTEGER and unsigned ODBC SQL_INTEGER can exceed the i32 range. + "INTEGER" | "INT8" | "BIGINT" | "SERIAL8" | "BIGSERIAL" | "IDENTITY" | "INT64" + | "INTEGER8" | "BIGINT SIGNED" => decode_raw::(raw_value).into(), + "INT" | "INT4" | "MEDIUMINT" | "YEAR" => decode_raw::(raw_value).into(), "INT2" | "SMALLINT" | "TINYINT" => decode_raw::(raw_value).into(), "BIGINT UNSIGNED" => decode_raw::(raw_value).into(), "INT UNSIGNED" | "MEDIUMINT UNSIGNED" | "SMALLINT UNSIGNED" | "TINYINT UNSIGNED" => { diff --git a/tests/sql_test_files/data/large_integer.sql b/tests/sql_test_files/data/large_integer.sql new file mode 100644 index 000000000..0f542e302 --- /dev/null +++ b/tests/sql_test_files/data/large_integer.sql @@ -0,0 +1,3 @@ +-- SQLPage evaluates literal-only SELECTs itself, so + 0 forces database execution. +-- Keep the expected value as text so it cannot overflow in the integer decoder. +select '3000000000' as expected_contains, 3000000000 + 0 as actual;