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

$ne on field of object in array returns documents if any object in the array doesn't match the $ne #220

Closed
agiannone opened this issue Jun 23, 2023 · 1 comment

Comments

@agiannone
Copy link
Contributor

agiannone commented Jun 23, 2023

When using $ne on a field of an object in an array, only documents where none of the array objects match should be returned. Currently, as long as 1 of the objects matches the $ne expression, then the document is returned.

Test case to reproduce:

   @Test
    void testMatchesNeFieldInArray() throws Exception {
    	Document query = json("'tags.value': {$ne: 'B'}");

    	Document document = json("_id: 1, tags: [{'value': 'A'}, {'value': 'D'}]");
        assertThat(matcher.matches(document, query)).isTrue();

        document = json("_id: 1, tags: [{'value': 'A'}, {'value': 'B'}]");
        assertThat(matcher.matches(document, query)).isFalse();
    }

The second assertion returns true as it matches one of the fields, but it should return false.

@bwaldvogel
Copy link
Owner

This should be fixed in v1.44.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants