Jakov
Jakov

Reputation: 999

where query is not working properly in Grails

I am working on some project in Grails and using where query.

I figured out that it is returning more data than it should be.

I put in third row false value in order to make where return empty list. However, list is not empty.

Can someone tell me what is wrong with my code.

Here are two examples(I tried both options and both return list which is not empty).

Example 1:

List<Settings> settingsList = Settings.where{
            userId == user.id &&
            startDateData.specificDate <= specificDate &&
            false
        }.list(sort:"startDateData", order:'desc')

Example 2:

List<Settings> settingsList = Settings.where{
            userId == user.id
            startDateData.specificDate <= specificDate
            false
        }.list(sort:"startDateData", order:'desc')

Upvotes: 0

Views: 47

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27220

The only expressions that directly affect the query criteria are those for which the LHS references a persistent property. The expression false isn't one of those expressions.

Upvotes: 1

Related Questions