diff --git a/simulator/generation/predicate/binary.rs b/simulator/generation/predicate/binary.rs index dc7f267b7..ef6379738 100644 --- a/simulator/generation/predicate/binary.rs +++ b/simulator/generation/predicate/binary.rs @@ -7,7 +7,7 @@ use crate::{ backtrack, one_of, pick, predicate::{CompoundPredicate, SimplePredicate}, table::{GTValue, LTValue, LikeValue}, - ArbitraryFrom as _, ArbitraryFromMaybe as _, + ArbitraryFrom, ArbitraryFromMaybe as _, }, model::{ query::predicate::Predicate, @@ -335,7 +335,6 @@ impl CompoundPredicate { (0..rng.gen_range(0..=3)) .map(|_| SimplePredicate::arbitrary_from(rng, (table, row, true)).0) .reduce(|accum, curr| { - // dbg!(&accum, &curr); Predicate(Expr::Binary( Box::new(accum.0), ast::Operator::And, diff --git a/simulator/generation/predicate/mod.rs b/simulator/generation/predicate/mod.rs index 9f2c08ee5..846f1d23a 100644 --- a/simulator/generation/predicate/mod.rs +++ b/simulator/generation/predicate/mod.rs @@ -17,11 +17,13 @@ struct CompoundPredicate(Predicate); #[derive(Debug)] struct SimplePredicate(Predicate); -impl ArbitraryFrom<(&Table, &[SimValue], bool)> for SimplePredicate { +impl> ArbitraryFrom<(&Table, A, bool)> for SimplePredicate { fn arbitrary_from( rng: &mut R, - (table, row, predicate_value): (&Table, &[SimValue], bool), + (table, row, predicate_value): (&Table, A, bool), ) -> Self { + let row = row.as_ref(); + // Pick an operator let choice = rng.gen_range(0..2); // Pick an operator match predicate_value { diff --git a/simulator/generation/property.rs b/simulator/generation/property.rs index b73e73d37..4f1537423 100644 --- a/simulator/generation/property.rs +++ b/simulator/generation/property.rs @@ -1,4 +1,5 @@ use limbo_core::LimboError; +use limbo_sqlite3_parser::ast; use serde::{Deserialize, Serialize}; use crate::{ @@ -692,10 +693,16 @@ fn property_select_select_optimizer(rng: &mut R, env: &SimulatorEn let table = pick(&env.tables, rng); // Generate a random predicate let predicate = Predicate::arbitrary_from(rng, table); + // Transform into a Binary predicate to force values to be casted to a bool + let expr = ast::Expr::Binary( + Box::new(predicate.0), + ast::Operator::And, + Box::new(Predicate::true_().0), + ); Property::SelectSelectOptimizer { table: table.name.clone(), - predicate, + predicate: Predicate(expr), } } diff --git a/simulator/model/query/predicate.rs b/simulator/model/query/predicate.rs index d2d495cec..9e3c0f4eb 100644 --- a/simulator/model/query/predicate.rs +++ b/simulator/model/query/predicate.rs @@ -48,7 +48,6 @@ pub fn expr_to_value(expr: &ast::Expr, row: &[SimValue], table: &Table) -> Optio ast::Expr::Binary(lhs, op, rhs) => { let lhs = expr_to_value(lhs, row, table)?; let rhs = expr_to_value(rhs, row, table)?; - // dbg!(&lhs, &rhs); Some(lhs.binary_compare(&rhs, *op)) } ast::Expr::Like { diff --git a/simulator/runner/cli.rs b/simulator/runner/cli.rs index 0471f5077..2102faab6 100644 --- a/simulator/runner/cli.rs +++ b/simulator/runner/cli.rs @@ -61,7 +61,7 @@ pub struct SimulatorCLI { #[clap( long, help = "disable Select-Select-Optimizer Property", - default_value_t = true // TODO: set this option to false after we have correctly asserted how this property should work + default_value_t = false )] pub disable_select_optimizer: bool, }