diff --git a/core/vdbe.rs b/core/vdbe.rs index a00018301..e8c3d327f 100644 --- a/core/vdbe.rs +++ b/core/vdbe.rs @@ -603,6 +603,20 @@ impl Program { state.pc += 1; } } + (OwnedValue::Integer(lhs), OwnedValue::Float(rhs)) => { + if (*lhs as f64) == *rhs { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (OwnedValue::Float(lhs), OwnedValue::Integer(rhs)) => { + if *lhs == (*rhs as f64) { + state.pc = target_pc; + } else { + state.pc += 1; + } + } (OwnedValue::Text(lhs), OwnedValue::Text(rhs)) => { if lhs == rhs { state.pc = target_pc; @@ -610,6 +624,9 @@ impl Program { state.pc += 1; } } + (_, OwnedValue::Null) | (OwnedValue::Null, _) => { + state.pc = target_pc; + } _ => { todo!(); } @@ -639,6 +656,20 @@ impl Program { state.pc += 1; } } + (OwnedValue::Integer(lhs), OwnedValue::Float(rhs)) => { + if (*lhs as f64) != *rhs { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (OwnedValue::Float(lhs), OwnedValue::Integer(rhs)) => { + if *lhs != (*rhs as f64) { + state.pc = target_pc; + } else { + state.pc += 1; + } + } (OwnedValue::Text(lhs), OwnedValue::Text(rhs)) => { if lhs != rhs { state.pc = target_pc; @@ -646,6 +677,9 @@ impl Program { state.pc += 1; } } + (_, OwnedValue::Null) | (OwnedValue::Null, _) => { + state.pc = target_pc; + } _ => { todo!(); } @@ -675,6 +709,23 @@ impl Program { state.pc += 1; } } + (OwnedValue::Integer(lhs), OwnedValue::Float(rhs)) => { + if (*lhs as f64) < *rhs { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (OwnedValue::Float(lhs), OwnedValue::Integer(rhs)) => { + if *lhs < (*rhs as f64) { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (_, OwnedValue::Null) | (OwnedValue::Null, _) => { + state.pc = target_pc; + } _ => { todo!(); } @@ -704,6 +755,23 @@ impl Program { state.pc += 1; } } + (OwnedValue::Integer(lhs), OwnedValue::Float(rhs)) => { + if (*lhs as f64) <= *rhs { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (OwnedValue::Float(lhs), OwnedValue::Integer(rhs)) => { + if *lhs <= (*rhs as f64) { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (_, OwnedValue::Null) | (OwnedValue::Null, _) => { + state.pc = target_pc; + } _ => { todo!(); } @@ -733,6 +801,23 @@ impl Program { state.pc += 1; } } + (OwnedValue::Integer(lhs), OwnedValue::Float(rhs)) => { + if (*lhs as f64) > *rhs { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (OwnedValue::Float(lhs), OwnedValue::Integer(rhs)) => { + if *lhs > (*rhs as f64) { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (_, OwnedValue::Null) | (OwnedValue::Null, _) => { + state.pc = target_pc; + } _ => { todo!(); } @@ -762,6 +847,23 @@ impl Program { state.pc += 1; } } + (OwnedValue::Integer(lhs), OwnedValue::Float(rhs)) => { + if (*lhs as f64) >= *rhs { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (OwnedValue::Float(lhs), OwnedValue::Integer(rhs)) => { + if *lhs >= (*rhs as f64) { + state.pc = target_pc; + } else { + state.pc += 1; + } + } + (_, OwnedValue::Null) | (OwnedValue::Null, _) => { + state.pc = target_pc; + } _ => { todo!(); } diff --git a/testing/all.test b/testing/all.test index f376f70a8..76ba2367f 100755 --- a/testing/all.test +++ b/testing/all.test @@ -108,6 +108,19 @@ do_execsql_test where-clause-lte { select count(1) from users where id <= 2000; } {2000} +do_execsql_test where-and { + select * from products where price > 50 and name != 'hat'; +} {2|cap|82.0 +5|sweatshirt|74.0 +6|shorts|70.0 +7|jeans|78.0 +8|sneakers|82.0 +11|accessories|81.0} + +do_execsql_test where-multiple-and { + select * from products where price > 50 and name != 'boots' and price <= 70; +} {6|shorts|70.0} + do_execsql_test where-clause-unary-true { select count(1) from users where 1; } {10000}