Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tagname search] Made /tag search case-insensitive.
- This affects tagname autocomplete - Also fixed up a bug where '_' and '%' weren't being escaped in SQL LIKE expressions
- Loading branch information
Showing
6 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Contains miscelaneous set of DB-related functions | ||
""" | ||
|
||
import re | ||
|
||
_special_characters = '%_' | ||
def escape_sql_like_special_characters(term, escape='\\'): | ||
""" | ||
Escapes characters that are special to the the sql LIKE expression. | ||
In particular, for both postgres and sqlite this means '%' and '_'. | ||
""" | ||
for ch in escape + _special_characters: | ||
term = term.replace(ch, escape+ch) | ||
return term | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters