I'm trying to get all the activities from a user or its teams also filtered by some types if some properties are set.
This is what I have right now:
Activity.withCriteria{
and{
or {
eq 'user',myUser
"in" 'team',userTeams
}
and{
if (showA || showB || showC){
or{
if (showA){
"in" "a", myAList
}
if (showB){
"in" "b", myBList
}
if (showC){
"in" "c",myCList
}
}
}
}
}
order "date","desc"
maxResults maxElements
}
Executing that, what I get it's the OR of user and team block and the showA, showB, showC block instead of the AND of those two blocks.
I'm using grails 2.2.1 (also using MongoDB GORM 1.2.0 without Hibernate)
EDIT:
I have been able to see the query that's sent to MongoDB and it's not doing the first part of the criteria. This is the query that's being passed to MongoDB:
query: { query: { $or: [ { a: { $in: [ "5191e2c7c6c36183687df8b6", "5191e2c7c6c36183687df8b7", "5191e2c7c6c36183687df8b8" ] } }, { b: { $in: [ "5191e2c7c6c36183687df8b9", "5191e2c7c6c36183687df8ba", "5191e2c7c6c36183687df8bb" ] } }, { c: { $in: [ "5191e2c7c6c36183687df8b5" ] } } ] }, orderby: { date: -1 } } ntoreturn: 10 ntoskip: 0
EDIT: I have just seen that a JIRA has already been raised and it seems that's a MongoDB plugin problem... http://jira.grails.org/browse/GPMONGODB-296