Function to escape "like" strings?
See original GitHub issueIt would be nice to have something like this:
...orWhere('name', 'like', '%' + knex.escapeLike(incomingArgument))...
I tried to find something similar in the code but haven’t found one.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:9 (4 by maintainers)
Top Results From Across the Web
ESCAPE clause in LIKE operator
The ESCAPE clause is supported in the LIKE operator to indicate the escape character. Escape characters are used in the pattern string to...
Read more >escape() - JavaScript - MDN Web Docs - Mozilla
The escape() function computes a new string in which certain characters have been replaced by hexadecimal escape sequences.
Read more >How to escape a string for use with the LIKE operator in SQL ...
I am looking for something that works in SQL Server similar to the @ symbol in c# which causes a string to be...
Read more >LIKE
The LIKE conditions specify a test involving pattern matching. ... Otherwise, the escape character, if specified, must be a character string of length...
Read more >STRING_ESCAPE (Transact-SQL) - SQL Server
Escapes special characters in texts and returns text with escaped characters. STRING_ESCAPE is a deterministic function, introduced in SQL ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI, I’m currently using this in Postgres:
whereRaw("name ILIKE '%' || ? || '%'", [param]);
Maybe it is not so common use case. Also this issue doesn’t describe what that escaping should exactly do. Remove
%
chars or something else? It is pretty opinionated functionality. If you like to implement or specify how it should work exactly, please open new feature request.