Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails domain class String property case insensitive search

Tags:

grails

groovy

I am trying to find records in my database using my service and this works:

def resultList = IndividualRecord.findAllWhere(citizenship: 'us')

but when I change citizenship to upper case, like this:

def resultList = IndividualRecord.findAllWhere(citizenship: 'US')

it no longer works. So I tried this:

def resultList = IndividualRecord.findAllWhere(citizenship.caseIgnoreEquals('us'))

but that doesn't work. Any suggestions? citizenship is a String property of class IndividualRecord.

like image 214
Anonymous Human Avatar asked Mar 19 '26 04:03

Anonymous Human


1 Answers

This will match the citizenship field against 'US' case insensitively

def resultList = IndividualRecord.findAllByCitizenshipIlike('US')
like image 119
Dónal Avatar answered Mar 21 '26 03:03

Dónal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!