kaleidos / grails-postgresql-extensions

Grails plugin to use postgresql native elements such as arrays, hstores,...
Apache License 2.0
78 stars 62 forks source link

New Array method being a mix of contains and empty #27

Closed ilopmar closed 10 years ago

ilopmar commented 10 years ago

Sometimes you have to write a criteria matching an array of arguments using pgArrayContains. But if the array is empty you have to use pgArrayIsEmpty. Check the example:

xxxxx.withCriteria {
   if (tagList) {
      pgArrayContains 'tags', tagList
   } else {
      pgArrayIsEmpty 'tags'
   }
}

It would be nice if the previous criteria could be written like this:

xxxxx.withCriteria {
  pgArrayIsEmptyOrContains 'tags', tagList
}

And if tagList is empty it use pgArrayIsEmpty but if not it use pgArrayContains under the hood.

ilopmar commented 10 years ago

Created in release 0.6.6: https://github.com/kaleidos/grails-postgresql-extensions/releases/tag/0.6.6