question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function to escape "like" strings?

See original GitHub issue

It 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:closed
  • Created 9 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
killercupcommented, Mar 14, 2015

FYI, I’m currently using this in Postgres: whereRaw("name ILIKE '%' || ? || '%'", [param]);

0reactions
elhigucommented, Sep 15, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found