Skip to content

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

@agiannone

Description

@agiannone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions