0.2.1
A backwards compatible patch for v0.2.0
to support rows that allow any value for a specific column.
Non-Breaking changes:
- support
#[venndb(any)]
filters;- these are possible only for
T
filter maps, whereT: ::venndb::Any
; bool
filters cannot beany
asbool
doesn't implement the::venndb::Any
trait;- rows that are
any
will match regardless of the query filter used for that property;
- these are possible only for
Example usage:
use venndb::{Any, VennDB};
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum Department {
Any,
Hr,
Engineering,
}
impl Any for Department {
fn is_any(&self) -> bool {
self == Department::Any
}
}
#[derive(Debug, VennDB)]
pub struct Employee {
name: String,
#[venndb(filter, any)]
department: Department,
}
let db = EmployeeDB::from_iter([
Employee { name: "Jack".to_owned(), department: Department::Any },
Employee { name: "Derby".to_owned(), department: Department::Hr },
]);
let mut query = db.query();
// will match Jack and Derby, as Jack is marked as Any, meaning it can work for w/e value
let hr_employees: Vec<_> = query.department(Department::Hr).execute().unwrap().iter().collect();
assert_eq!(hr_employees.len(), 2);
In case you combine it with the filter map property being optional (department: Option<Department>
),
then it will still work the same, where rows with None
are seen as nothing at all and just ignored.
This has no affect on the correct functioning of Any
.