Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using an any filter doesn't get results when no non-any prop row has that value #5

Closed
GlenDC opened this issue Apr 18, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@GlenDC
Copy link
Member

GlenDC commented Apr 18, 2024

This testcase breaks on v0.2.1, despite it expected to not to break:

#[derive(Debug, VennDB)]
pub struct Worker {
    #[venndb(key)]
    id: u32,
    is_admin: bool,
    is_active: Option<bool>,
    #[venndb(filter, any)]
    department: Option<Department>,
}

#[test]
fn test_any_row_optional_filter_map_white_rabbit() {
    let db = WorkerDB::from_rows(vec![
        Worker {
            id: 1,
            is_admin: false,
            is_active: Some(true),
            department: Some(Department::Engineering),
        },
        Worker {
            id: 2,
            is_admin: false,
            is_active: None,
            department: None,
        },
        Worker {
            id: 3,
            is_admin: false,
            is_active: Some(true),
            department: Some(Department::Any),
        },
        Worker {
            id: 4,
            is_admin: false,
            is_active: Some(true),
            department: Some(Department::HR),
        },
    ])
    .unwrap();

    let mut query = db.query();
    query.department(Department::Marketing);
    let results = query.execute().unwrap().iter().collect::<Vec<_>>();
    assert_eq!(results.len(), 1);
    assert_eq!(results[1].id, 3);
}
@GlenDC GlenDC self-assigned this Apr 18, 2024
@GlenDC GlenDC added the bug Something isn't working label Apr 18, 2024
@GlenDC GlenDC added this to the v0.2.2 milestone Apr 18, 2024
@GlenDC GlenDC closed this as completed in c5d4f5f Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant