Reputation: 1036
I have a question about how to use unaccent extension of PostgreSQL with Grails.
I have a lot of descriptions in french and PostgreSQL is not accent insensitive. I installed the unaccent extension and it works very well on PgAdmin III.
How can I configure Grails and/or PostgreSQL to use unaccent in my controller ?
This is my Domain:
Class Description {
String content
int type = -1
}
For example, can I "translate" the next query using GORM ?
SELECT content
FROM description
WHERE unaccent(content) ILIKE unaccent(%myInputHere%)
Thanks for reading
Upvotes: 1
Views: 495
Reputation: 24776
Since this is SQL specific you will need to use an SQL Restriction within your criteria. For example:
def myinput = params.myinputfieldname
def results = Description.createCriteria().list() {
sqlRestriction "unaccent(content) ILIKE unaccent('%$myinput%')"
}
At least that's the idea.
Edit
Take care to note the fact 'content' in the restriction above refers to the actual SQL column name instead of the domain's field name.
Upvotes: 1