Anonymous Human
Anonymous Human

Reputation: 1948

Query condition cannot be negated?

I am getting a strange error with this query criteria

not{ ilike "holderFirstName", "Steph%" }

Query of type ILike cannot be negated. Stacktrace follows:
Message: Query of type ILike cannot be negated
    Line | Method
->>  463 | handle                in org.grails.datastore.mapping.mongo.query.MongoQuery$29

Upvotes: 0

Views: 131

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27245

The mongo plugin does not currently support negating ilike queries. The code at https://github.com/grails/grails-data-mapping/blob/61662051cd0fa23b43d9ba89e874460cf7b0b16f/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/mapping/mongo/query/MongoQuery.java#L538 which populates the negatedHandlers map does not contain the ilike query so that will trigger an exception around https://github.com/grails/grails-data-mapping/blob/61662051cd0fa23b43d9ba89e874460cf7b0b16f/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/mapping/mongo/query/MongoQuery.java#L463.

I don't know if Mongo itself can support the negation or not. If you file a JIRA we can investigate it. It may be that Mongo can handle it and that the plugin just needs to account for that, or it may be that Mongo really doesn't provide a good way to do it. I don't know the answer, but of course we can investigate it.

Upvotes: 1

Related Questions