From 24a6cce418fe98345a2cebbde00e09ac489ed2f0 Mon Sep 17 00:00:00 2001 From: Emily Toop Date: Fri, 31 Mar 2017 10:57:39 +0100 Subject: [PATCH] WIP - add ability to have OR's in NOT's and NOT's in OR's --- query/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/query/src/lib.rs b/query/src/lib.rs index 2a93d453..67ac9ba6 100644 --- a/query/src/lib.rs +++ b/query/src/lib.rs @@ -533,8 +533,9 @@ pub struct NotJoin { #[allow(dead_code)] #[derive(Clone, Debug, Eq, PartialEq)] pub enum WhereClause { - Not, + Not(Box), NotJoin(NotJoin), + Or(Box), OrJoin(OrJoin), Pred(Predicate), WhereFn, @@ -567,10 +568,11 @@ impl ContainsVariables for WhereClause { fn accumulate_mentioned_variables(&self, acc: &mut BTreeSet) { use WhereClause::*; match self { + &Or(ref o) => o.accumulate_mentioned_variables(acc), &OrJoin(ref o) => o.accumulate_mentioned_variables(acc), &Pred(ref p) => p.accumulate_mentioned_variables(acc), &Pattern(ref p) => p.accumulate_mentioned_variables(acc), - &Not => (), + &Not(ref n) => n.accumulate_mentioned_variables(acc), &NotJoin(ref n) => n.accumulate_mentioned_variables(acc), &WhereFn => (), &RuleExpr => (), @@ -584,7 +586,7 @@ impl ContainsVariables for OrWhereClause { match self { &And(ref clauses) => for clause in clauses { clause.accumulate_mentioned_variables(acc) }, &Clause(ref clause) => clause.accumulate_mentioned_variables(acc), - &Not(ref clause) => clause.accumulate_mentioned_variables(acc), + &Not(ref clauses) => for clause in clauses { clause.accumulate_mentioned_variables(acc) }, } } } @@ -604,7 +606,7 @@ impl ContainsVariables for WhereNotClause { match self { &And(ref clauses) => for clause in clauses { clause.accumulate_mentioned_variables(acc) }, &Clause(ref clause) => clause.accumulate_mentioned_variables(acc), - &Or(ref clause) => clause.accumulate_mentioned_variables(acc), + &Or(ref clauses) => for clause in clauses { clause.accumulate_mentioned_variables(acc) }, } } }