Skip to content

Instantly share code, notes, and snippets.

@ishults
Last active December 16, 2015 20:05
Show Gist options
  • Save ishults/ad09d1ae6cfd2f6feadd to your computer and use it in GitHub Desktop.
Save ishults/ad09d1ae6cfd2f6feadd to your computer and use it in GitHub Desktop.
Case-insensitive criteria Spec
class CriteriaIntegrationSpec extends IntegrationSpec {
void "Nested criteria property ordering should ignoreCase properly"() {
given: 'A parent class and its child classes'
Parent parent = new Parent().save()
Child child1 = new Child(age: 10, name: 'Apollo', parent: parent).save()//1
Child child3 = new Child(age: 20, name: 'Zeus', parent: parent).save()//3
Child child2 = new Child(age: 30, name: 'athena', parent: parent).save()//2
when: 'a criteria call is ordered by a String property'
List names = Parent.createCriteria().list() {
createAlias('children', 'child')
eq('child.parent', parent)
gt('child.age', 5)
projections {
property('child.name')
}
order(Order.asc('child.name').ignoreCase())
}
then: 'it sorts case-insensitively'
assert names == [ 'Apollo', 'athena', 'Zeus' ]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment