Search code examples
grailsgrails-orm

Grails - gorm false OR NULL


I have a field in a table called disabled that is a Boolean. I'm trying to query for both false or null but can't seem to get it to work. I have tried a few things, most likely solution but didn't seem to work is

p = book.createCriteria().list {
'in'('createdUnderAccountCustomerNumber', accountIds)
and {
   'in'('createdUnderProfessionalCustomerNumber', professionalCustomerNums)
   isNull('disabled')
   or {
     eq('disabled', false)
   }
}

Basically I want get all the books created under a list of accounts and a list of professionals which has disabled set to either false or null


Solution

  • Put the two parts of the or inside the closure:

    or {
        isNull('disabled')
        eq('disabled', false)
    }