refactor(sessions): use _escape_like in _cwd_prefix_clause

Follow-up on the salvage of #78681 + #78927: the second fix inlined the
exact body of the _escape_like helper the first fix introduced ten lines
above. Call the helper instead so there is one copy of the escaping rule.
This commit is contained in:
kshitij 2026-08-06 03:56:06 +05:30 committed by kshitij
parent b37de01926
commit 4bab919446
1 changed files with 1 additions and 1 deletions

View File

@ -194,7 +194,7 @@ def _cwd_prefix_clause(cwd_prefix: str) -> Tuple[str, List[str]]:
# Escape the needle and pair it with ESCAPE; the literal separator
# backslash in the Windows pattern needs escaping for the same reason. The
# ``=`` arm is an exact compare and keeps the raw prefix.
esc = prefix.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
esc = _escape_like(prefix)
return (
"(s.cwd = ? OR s.cwd LIKE ? ESCAPE '\\' OR s.cwd LIKE ? ESCAPE '\\')",
[prefix, f"{esc}/%", f"{esc}\\\\%"],