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

Filters.eq().not() is not applying the negation (2.0.2) #1528

Closed
DefiantCatgirl opened this issue Nov 6, 2020 · 1 comment
Closed

Filters.eq().not() is not applying the negation (2.0.2) #1528

DefiantCatgirl opened this issue Nov 6, 2020 · 1 comment
Labels
Milestone

Comments

@DefiantCatgirl
Copy link

DefiantCatgirl commented Nov 6, 2020

When building a query such as

.filter(eq("isDeleted", true).not())

the resulting query to the database is isDeleted: true and not $not: {isDeleted: true}. I know $ne exists so this kind of query shouldn't normally be used in the first place, but I accidentally had some in the codebase.

Presumably because this instantiation ignores checking the not in the overridden function.

    public static Filter eq(final String field, final Object val) {
        return new Filter("$eq", field, val) {
            @Override
            public void encode(final Mapper mapper, final BsonWriter writer, final EncoderContext context) {
                writer.writeName(field(mapper));
                writeUnnamedValue(getValue(mapper), mapper, writer, context);
            }
        };
    }
  • Server Version: 3.6
  • Driver Version: 4.0.5
  • Morphia Version: 2.0.2
@evanchooly
Copy link
Member

you're exactly right. I'm going to mark this as a 2.1 since that should be out in a few days and I'm trying to avoid a 2.0.3. But I can backport if a 2.0.3 is needed. thanks.

@evanchooly evanchooly added this to the 2.1.0 milestone Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants