Skip to content

Commit 541997f

Browse files
committed
Add explanation for likes.escapeClause() limitation in doc
See gh-66
1 parent d975d4d commit 541997f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/main/asciidoc/user-guide.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,60 @@ the mybatis-thymeleaf provide the expression utility method for adding the `ESCA
13071307
For detail, please see <<escapeClause>>.
13081308
====
13091309

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
1363+
----
13101364

13111365
== Appendix
13121366

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy