mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-03 00:14:21 +01:00
Merge 'Format infinite float as "Inf"/"-Inf"' from jachewz
## Issue Numeric values outside the range of what f64 can represent are formatted to strings as "Inf" or "-Inf" in sqlite, but they are "inf" and "-inf" in limbo. ``` sqlite> SELECT 1.7976931348623157E+309; Inf ``` ``` limbo> SELECT 1.7976931348623157E+309; ┌─────────────────────────┐ │ 1.7976931348623157E+309 │ ├─────────────────────────┤ │ inf │ └─────────────────────────┘ ``` closes #1248 Closes #1272
This commit is contained in:
6
.github/shared/install_sqlite/action.yml
vendored
6
.github/shared/install_sqlite/action.yml
vendored
@@ -6,10 +6,10 @@ runs:
|
||||
steps:
|
||||
- name: Install SQLite
|
||||
env:
|
||||
SQLITE_VERSION: "3470200"
|
||||
YEAR: 2024
|
||||
SQLITE_VERSION: "3490100"
|
||||
YEAR: 2025
|
||||
run: |
|
||||
curl -o /tmp/sqlite.zip https://www.sqlite.org/$YEAR/sqlite-tools-linux-x64-$SQLITE_VERSION.zip > /dev/null
|
||||
curl -o /tmp/sqlite.zip https://sqlite.org/$YEAR/sqlite-tools-linux-x64-$SQLITE_VERSION.zip > /dev/null
|
||||
unzip -j /tmp/sqlite.zip sqlite3 -d /usr/local/bin/
|
||||
sqlite3 --version
|
||||
shell: bash
|
||||
|
||||
@@ -197,6 +197,12 @@ impl Display for OwnedValue {
|
||||
}
|
||||
Self::Float(fl) => {
|
||||
let fl = *fl;
|
||||
if fl == f64::INFINITY {
|
||||
return write!(f, "Inf");
|
||||
}
|
||||
if fl == f64::NEG_INFINITY {
|
||||
return write!(f, "-Inf");
|
||||
}
|
||||
if fl.is_nan() {
|
||||
return write!(f, "");
|
||||
}
|
||||
|
||||
@@ -166,6 +166,14 @@ do_execsql_test select-like-expression {
|
||||
select 2 % 0.5
|
||||
} {}
|
||||
|
||||
do_execsql_test select_positive_infinite_float {
|
||||
SELECT 1.7976931348623157E+308 + 1e308; -- f64::MAX + 1e308
|
||||
} {Inf}
|
||||
|
||||
do_execsql_test select_negative_infinite_float {
|
||||
SELECT -1.7976931348623157E+308 - 1e308 -- f64::MIN - 1e308
|
||||
} {-Inf}
|
||||
|
||||
do_execsql_test select_shl_large_negative_float {
|
||||
SELECT 1 << -1e19;
|
||||
SELECT 1 << -9223372036854775808; -- i64::MIN
|
||||
|
||||
Reference in New Issue
Block a user