Closed
Description
I will consider to support following expression methods.
likeEscape
: escape'%'
and'_'
likeEscapeClause
: append ESCAPE clause (e.g.ESCAPE '\'
)
NOTE:
Configurable support for following value:
- escape character (default is
'\'
(backslash) )- target characters that depends on database or version (e.g.
'%'
,'_'
, etc ...)
e.g.)
SELECT * FROM names
WHERE 1 = 1
/*[# th:if="${firstName} != null"]*/
/*[# mybatis:bind="patternFirstName=|${#mybatis.escapeLikeWildcard(firstName)}%|" /]*/
AND firstName LIKE /*[('#{patternFirstName}')]*/ 'Taro%' /*[(${#mybatis.likeEscapeClause()})]*/
/*[/]*/
- firstName :
B_
translate to as follow:
SELECT * FROM names
WHERE 1 = 1
AND firstName LIKE #{patternFirstName} ESCAPE '\'
- patternFirstName :
B\_%
IMPORTANT
I known that cannot parse correctly when the
'\'
(backslash) is contain as static text on a template.e.g.)
SELECT * FROM names WHERE 1 = 1 /*[# th:if="${firstName} != null"]*/ /*[# mybatis:bind="patternFirstName=|${#mybatis.escapeLikeWildcard(firstName)}%|" /]*/ AND firstName LIKE /*[('#{patternFirstName}')]*/ 'Taro%' /**/ ESCAPE '\' /*[/]*/I will add a caution for this limitation on user guide.