diff --git a/src/lib/filter.rs b/src/lib/filter.rs index a2ba53c92..7d35dd37d 100644 --- a/src/lib/filter.rs +++ b/src/lib/filter.rs @@ -319,20 +319,43 @@ mod tests { fn test_nested_entry_filter() { let e1: Entry = serde_json::from_str(r#"{ "attrs": { - "userid": ["william"], + "class": ["person"], + "uidNumber": ["1000"] + } + }"#).unwrap(); + + let e2: Entry = serde_json::from_str(r#"{ + "attrs": { + "class": ["person"], + "uidNumber": ["1001"] + } + }"#).unwrap(); + + let e3: Entry = serde_json::from_str(r#"{ + "attrs": { + "class": ["person"], + "uidNumber": ["1002"] + } + }"#).unwrap(); + + let e4: Entry = serde_json::from_str(r#"{ + "attrs": { + "class": ["group"], "uidNumber": ["1000"] } }"#).unwrap(); let f_t1a = Filter::And(vec![ Filter::Eq(String::from("class"), String::from("person")), - Filter::And(vec![ + Filter::Or(vec![ Filter::Eq(String::from("uidNumber"), String::from("1001")), Filter::Eq(String::from("uidNumber"), String::from("1000")), ]), ]); - println!("{:?}", f_t1a); - assert!(false); + assert!(f_t1a.entry_match_no_index(&e1)); + assert!(f_t1a.entry_match_no_index(&e2)); + assert!(!f_t1a.entry_match_no_index(&e3)); + assert!(!f_t1a.entry_match_no_index(&e4)); } } diff --git a/src/lib/schema.rs b/src/lib/schema.rs index c549c15aa..d5b28555b 100644 --- a/src/lib/schema.rs +++ b/src/lib/schema.rs @@ -1021,19 +1021,8 @@ impl SchemaInner { } }) } - Filter::Not(filters) => { - // This should never happen because - // optimising should remove them as invalid parts? - if filters.len() == 0 { - return Err(SchemaError::EmptyFilter); - }; - filters.iter().fold(Ok(()), |acc, filt| { - if acc.is_ok() { - self.validate_filter(filt) - } else { - acc - } - }) + Filter::Not(filter) => { + self.validate_filter(filter) } } }