encodeTextInLike function

String encodeTextInLike(
  1. String text
)

Encodes text to escape special characters, so it can be normal text when using as part of the LIKE clause.

By normal we mean the text matches exactly character-by-character. Any special characters in text, such as '%' and '_', will be encoded, so % matches %, no longer wildcard.

NOTE: the escape character is !, so you must append escape '!' at the end. For example,

"where abc like E'${encodeTextInLike(input)}%' escape '!'"

Useful for mixing user's input with the LIKE patterns.

Implementation

String encodeTextInLike(String text) => _encLikeStr.apply(text);