Case insensitive regex with Postgres and JOOQ?

Viewed 1082

I currently use this code with JOOQ:

Condition condition = DSL.trueCondition();
if( isNotBlank(email) ){
  condition = condition.and(APP_USER.EMAIL.likeRegex(email));
}

That ends up issuing Postgres specific SQL that does the regex match in the DB:

app_user.email ~ '{email regex}'

Is it possible to get JOOQ to issue the case insensitive version: app_user.email ~* '{email regex}'?


My current workaround is to use this code:

if( isNotBlank(email) ){
  condition = condition.and(
    APP_USER.EMAIL.lower().likeRegex(email.toLowerCase()) );
}
2 Answers

You can also use this

condition=condition.and(APP_USER.EMAIL.likeIgnoreCase("%"+email+"%"));
Related