From b0cf2ba92ccd9a9b3b30c6c5f184548b4b19c7f9 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Sun, 6 Jul 2025 14:58:29 -0400 Subject: [PATCH] add paranthesis to the unary expression printer --- simulator/generation/predicate/binary.rs | 6 +++--- simulator/generation/property.rs | 4 ---- vendored/sqlite3-parser/src/to_sql_string/expr.rs | 2 ++ vendored/sqlite3-parser/src/to_sql_string/stmt/select.rs | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/simulator/generation/predicate/binary.rs b/simulator/generation/predicate/binary.rs index c67682900..9559e8bea 100644 --- a/simulator/generation/predicate/binary.rs +++ b/simulator/generation/predicate/binary.rs @@ -321,7 +321,6 @@ impl CompoundPredicate { ) -> Self { // Cannot pick a row if the table is empty if table.rows.is_empty() { - println!("Table is empty, returning a predicate that is always {}", predicate_value); return Self(if predicate_value { Predicate::true_() } else { @@ -329,17 +328,18 @@ impl CompoundPredicate { }); } let row = pick(&table.rows, rng); - println!( + + tracing::trace!( "Creating a {} CompoundPredicate for table: {} and row: {:?}", if predicate_value { "true" } else { "false" }, table.name, row ); + let predicate = if rng.gen_bool(0.7) { // An AND for true requires each of its children to be true // An AND for false requires at least one of its children to be false if predicate_value { - println!("Creating a true AND CompoundPredicate"); (0..rng.gen_range(1..=3)) .map(|_| SimplePredicate::arbitrary_from(rng, (table, row, true)).0) .reduce(|accum, curr| { diff --git a/simulator/generation/property.rs b/simulator/generation/property.rs index ca4379e61..c1e59d5e4 100644 --- a/simulator/generation/property.rs +++ b/simulator/generation/property.rs @@ -751,8 +751,6 @@ fn property_insert_values_select( Predicate::arbitrary_from(rng, (table, &row)), ); - println!("Select query: {select_query:?}"); - Property::InsertValuesSelect { insert: insert_query, row_index, @@ -764,7 +762,6 @@ fn property_insert_values_select( fn property_select_limit(rng: &mut R, env: &SimulatorEnv) -> Property { // Get a random table let table = pick(&env.tables, rng); - println!("Selected table for 'property_select_limit': {}", table.name); // Select the table let select = Select::single( table.name.clone(), @@ -773,7 +770,6 @@ fn property_select_limit(rng: &mut R, env: &SimulatorEnv) -> Prope Some(rng.gen_range(1..=5)), Distinctness::All, ); - println!("Select query for 'property_select_limit': {select:?}"); Property::SelectLimit { select } } diff --git a/vendored/sqlite3-parser/src/to_sql_string/expr.rs b/vendored/sqlite3-parser/src/to_sql_string/expr.rs index 3f02d4737..46ef2c01e 100644 --- a/vendored/sqlite3-parser/src/to_sql_string/expr.rs +++ b/vendored/sqlite3-parser/src/to_sql_string/expr.rs @@ -262,9 +262,11 @@ impl ToSqlString for Expr { ret.push(')'); } Expr::Unary(unary_operator, expr) => { + ret.push('('); ret.push_str(&unary_operator.to_string()); ret.push(' '); ret.push_str(&expr.to_sql_string(context)); + ret.push(')'); } Expr::Variable(variable) => { ret.push_str(variable); diff --git a/vendored/sqlite3-parser/src/to_sql_string/stmt/select.rs b/vendored/sqlite3-parser/src/to_sql_string/stmt/select.rs index 84781b1be..6ccefb7b4 100644 --- a/vendored/sqlite3-parser/src/to_sql_string/stmt/select.rs +++ b/vendored/sqlite3-parser/src/to_sql_string/stmt/select.rs @@ -77,7 +77,7 @@ impl ToSqlString for ast::OneSelect { impl ToSqlString for ast::SelectInner { fn to_sql_string(&self, context: &C) -> String { - dbg!(&self); + // dbg!(&self); let mut ret = Vec::with_capacity(2 + self.columns.len()); ret.push("SELECT".to_string()); if let Some(distinct) = self.distinctness {