This is the problematic part of my MyBatis mapper:
<foreach item="item" index="index" collection="xy"
open="(" separator="or" close=")">
contains(t.mycol, '{' || #{item} || '}') > 0
</foreach>
If, for example, the #{item} contains '}', I get:
Error code: DRG-50900
Description: text query parser error on line string, column string
Cause: bad query
- How do I properly escape all possibly problematic characters?
- where to put the logic? In the mapper/dao/service..?
So that for example '}' would become escaped (and if the text already contained escaped '}' to leave it that way).
used in the project:
- Java 8
- Spring
- Oracle database
- MyBatis