Skip to content

Instantly share code, notes, and snippets.

@jeffscottbrown
Created October 2, 2014 17:57
Show Gist options
  • Save jeffscottbrown/865eb7637c68a90838cb to your computer and use it in GitHub Desktop.
Save jeffscottbrown/865eb7637c68a90838cb to your computer and use it in GitHub Desktop.
class Person {
String firstName
Integer age
}
Person.withSession {
new Person(firstName: 'Jeff', age: 44).save()
new Person(firstName: 'Betsy', age: 43).save()
new Person(firstName: 'Zack', age: 17).save()
new Person(firstName: 'Jake', age: 14).save()
}
def firstResults = Person.where {
firstName =~ 'J%' && age > 20
}.list()
def c = {
firstName =~ 'J%' && age > 20
}
def secondResults = Person.where(c).list()
// both of these assertions pass...
assert firstResults.size() == 1
assert secondResults.size() == 4
@jeffscottbrown
Copy link
Author

http://stackoverflow.com/users/973339/evanwong has asserted that those queries should return the same results, but they shouldn't.

@jeffscottbrown
Copy link
Author

The incorrect answer at the link above has since been deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment