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
def escape_like(text: str) -> str:
"""Escape text for like.
:param text: the raw text
:return: escaped text
"""
return text.replace("%", "\\%").replace("_", "\\_")
I'm reluctant to add this as a function to the library because it's fairly trivial, and more importantly because it won't work out of the box (you need to not only call this escape_like function on your input, but also use the 3 argument form of LIKE where you pass an ESCAPE \ as well).
I'm comfortable adding this to the docs, though. I'll add a bullet to the tips page, and I'll link to that from the .execute method of comdb2.dbapi2.Cursor and comdb2.cdb2.Handle.
This helper method should be part of the lib:
Example of other frameworks having this https://sqlalchemy-utils.readthedocs.io/en/stable/orm_helpers.html#escape-like
Or at least documented somewhere...
The text was updated successfully, but these errors were encountered: