mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
fix bug #1155
This commit is contained in:
parent
63630ff956
commit
a9ad5a56b9
2 changed files with 63 additions and 1 deletions
|
@ -61,7 +61,7 @@ impl Text {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OwnedValue {
|
||||
Null,
|
||||
Integer(i64),
|
||||
|
@ -249,6 +249,36 @@ impl AggContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq<OwnedValue> for OwnedValue {
|
||||
fn eq(&self, other: &OwnedValue) -> bool {
|
||||
match (self, other) {
|
||||
(Self::Integer(int_left), Self::Integer(int_right)) => int_left == int_right,
|
||||
(Self::Integer(int_left), Self::Float(float_right)) => {
|
||||
(*int_left as f64) == (*float_right)
|
||||
}
|
||||
(Self::Float(float_left), Self::Integer(int_right)) => {
|
||||
float_left == (&(*int_right as f64))
|
||||
}
|
||||
(Self::Float(float_left), Self::Float(float_right)) => float_left == float_right,
|
||||
(Self::Integer(_) | Self::Float(_), Self::Text(_) | Self::Blob(_)) => false,
|
||||
(Self::Text(_) | Self::Blob(_), Self::Integer(_) | Self::Float(_)) => false,
|
||||
(Self::Text(text_left), Self::Text(text_right)) => {
|
||||
text_left.value.eq(&text_right.value)
|
||||
}
|
||||
(Self::Blob(blob_left), Self::Blob(blob_right)) => blob_left.eq(blob_right),
|
||||
(Self::Null, Self::Null) => true,
|
||||
(Self::Agg(a), Self::Agg(b)) => a.eq(b),
|
||||
(Self::Agg(a), other) => a.final_value().eq(other),
|
||||
(other, Self::Agg(b)) => other.eq(b.final_value()),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn ne(&self, other: &OwnedValue) -> bool {
|
||||
!self.eq(other)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::non_canonical_partial_ord_impl)]
|
||||
impl PartialOrd<OwnedValue> for OwnedValue {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
|
|
32
testing/math.test
Normal file → Executable file
32
testing/math.test
Normal file → Executable file
|
@ -1352,3 +1352,35 @@ do_execsql_test mod-agg-int {
|
|||
do_execsql_test mod-agg-float {
|
||||
SELECT count(*) % 2.43 from users
|
||||
} { 0.0 }
|
||||
|
||||
do_execsql_test comp-float-float {
|
||||
SELECT 0.0 = 0.0
|
||||
} { 1 }
|
||||
|
||||
do_execsql_test comp-int-float {
|
||||
SELECT 0 = 0.0
|
||||
} { 1 }
|
||||
|
||||
do_execsql_test comp-float-int {
|
||||
SELECT 0.0 = 0
|
||||
} { 1 }
|
||||
|
||||
do_execsql_test comp-int-string {
|
||||
SELECT 0 = '0'
|
||||
} { 0 }
|
||||
|
||||
do_execsql_test comp-string-int {
|
||||
SELECT '0' = 0
|
||||
} { 0 }
|
||||
|
||||
do_execsql_test comp-string-blog {
|
||||
SELECT '0' = cast('0' as BLOB)
|
||||
} { 0 }
|
||||
|
||||
do_execsql_test comp-blog-string {
|
||||
SELECT cast('0' as BLOB) = '0'
|
||||
} { 0 }
|
||||
|
||||
do_execsql_test comp-blog-blog {
|
||||
SELECT cast('0' as BLOB) = cast('0' as BLOB)
|
||||
} { 1 }
|
Loading…
Add table
Add a link
Reference in a new issue