You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/user-guide.adoc
+54
Original file line number
Diff line number
Diff line change
@@ -1307,6 +1307,60 @@ the mybatis-thymeleaf provide the expression utility method for adding the `ESCA
1307
1307
For detail, please see <<escapeClause>>.
1308
1308
====
1309
1309
1310
+
=== Using #likes.escapeClause()
1311
+
1312
+
You should use the `#likes.escapeClause()` when specify escape character for LIKE phrase,
1313
+
but you notice there is possible that will be removed characters after `/\*[(${#likes.escapeClause()})]*/` (link:https://github.com/mybatis/thymeleaf-scripting/issues/66[see gh-66]]).
1314
+
1315
+
[source,sql]
1316
+
.Invalid usage
1317
+
----
1318
+
SELECT * FROM area WHERE NAME LIKE 'Tara%' /*[(${#likes.escapeClause()})]*/ ORDER BY ID --<1>
1319
+
----
1320
+
1321
+
<1> Specify any sql phrase after `/\*[(${#likes.escapeClause()})]*/` without line break
1322
+
1323
+
The above sql template will translate to follow(removed `ORDER BY ID`):
1324
+
1325
+
[source,sql]
1326
+
.Translated SQL
1327
+
----
1328
+
SELECT * FROM area WHERE NAME LIKE 'Tara%' escape '\'
1329
+
----
1330
+
1331
+
==== Workarounds
1332
+
1333
+
This behavior can be avoided to apply following workarounds.
1334
+
1335
+
===== Adding line break character
1336
+
1337
+
Add line break character after `/\*[(${#likes.escapeClause()})]*/`.
1338
+
1339
+
[source,sql]
1340
+
.Valid usage
1341
+
----
1342
+
SELECT * FROM area
1343
+
WHERE NAME LIKE 'Tara%' /*[(${#likes.escapeClause()})]*/
1344
+
ORDER BY ID
1345
+
----
1346
+
1347
+
===== Adding /**/
1348
+
1349
+
Add `/\**/` after `/*[(${#likes.escapeClause()})]*/`.
1350
+
1351
+
[source,sql]
1352
+
.Valid usage
1353
+
----
1354
+
SELECT * FROM area WHERE NAME LIKE 'Tara%' /*[(${#likes.escapeClause()})]*//**/ ORDER BY ID
1355
+
----
1356
+
1357
+
The above sql template will translate to follow:
1358
+
1359
+
[source,sql]
1360
+
.Translated SQL
1361
+
----
1362
+
SELECT * FROM area WHERE NAME LIKE 'Tara%' ESCAPE '\'/**/ ORDER BY ID
0 commit comments