Escape character in LIKE expressions is not escaped by querydsl #438

Closed
LordOfTheHelmet opened this Issue Jun 11, 2013 · 3 comments

Projects

None yet

2 participants

@LordOfTheHelmet

To reproduce this:

BooleanExpression patternPredicate = company.name.toLowerCase().like("%My! Text%");

When i execute this i get the exception:

java.sql.SQLDataException: ORA-01424: Zeichen nach dem Escape-Zeichen fehlen oder sind ungültig

The SQL generated from the expression looks like:

lower(company0_.NAME) like ? escape '!'

and the bound value is:

TRACE org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:84) - binding parameter [1] as [VARCHAR] - %My! Text%

Shouldn't querydsl escape the escape character for me? Otherwise i have to do something like:

BooleanExpression patternPredicate = company.name.toLowerCase().like("%My! Text%".replaceAll("!", "!!"), '!');
@timowest
Member

That would also mean that actual escaping is only available when the other like variants are used.

str.like("\\%")

would need to be written as

str.like("\\%", '\\')

But maybe this makes sense, since it makes escaping more explicit.

@timowest
Member

Released in 3.2.1

@timowest timowest closed this Jun 26, 2013
@LordOfTheHelmet

Thanks for accepting and implementing it!

@timowest timowest added this to the 3.2.1 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment