mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 04:24:21 +01:00
use sqlite_int_float_compare
This commit is contained in:
@@ -706,8 +706,12 @@ impl PartialOrd<Value> for Value {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
match (self, other) {
|
||||
(Self::Integer(int_left), Self::Integer(int_right)) => int_left.partial_cmp(int_right),
|
||||
(Self::Float(float), Self::Integer(int)) => Some(int_float_cmp(*int, *float).reverse()),
|
||||
(Self::Integer(int), Self::Float(float)) => Some(int_float_cmp(*int, *float)),
|
||||
(Self::Float(float), Self::Integer(int)) => {
|
||||
Some(sqlite_int_float_compare(*int, *float).reverse())
|
||||
}
|
||||
(Self::Integer(int), Self::Float(float)) => {
|
||||
Some(sqlite_int_float_compare(*int, *float))
|
||||
}
|
||||
(Self::Float(float_left), Self::Float(float_right)) => {
|
||||
float_left.partial_cmp(float_right)
|
||||
}
|
||||
|
||||
@@ -253,4 +253,22 @@ foreach {testname lhs rhs ans} {
|
||||
text-text-2 'a' 'a' 0
|
||||
} {
|
||||
do_execsql_test compare-is-not-$testname "SELECT $lhs is not $rhs" $::ans
|
||||
}
|
||||
}
|
||||
|
||||
# github-issue: 2957.
|
||||
do_execsql_test compare-int-float-setup {
|
||||
CREATE TABLE t1(i INTEGER);
|
||||
INSERT INTO t1 VALUES (0), (-1), (1);
|
||||
} {}
|
||||
|
||||
do_execsql_test compare-int-float-lte-negative-zero {
|
||||
SELECT i FROM t1 WHERE i <= -0.0 ORDER BY i;
|
||||
} {-1 0}
|
||||
|
||||
do_execsql_test compare-int-float-lt-negative-zero {
|
||||
SELECT i FROM t1 WHERE i < -0.0 ORDER BY i;
|
||||
} {-1}
|
||||
|
||||
do_execsql_test compare-int-float-cleanup {
|
||||
DROP TABLE t1;
|
||||
} {}
|
||||
Reference in New Issue
Block a user