mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: on PostgreSQL, searching automations or filtering models by a non-ASCII word finds nothing (#31423)
On PostgreSQL with ENABLE_ORJSON off (the default), searching automations by a word from their prompt, or filtering models by a tag, found nothing when the word was non-ASCII, for example Chinese. SQLite, and PostgreSQL with ENABLE_ORJSON on, were fine. With the default setting non-ASCII text is saved as \uXXXX codes, and PostgreSQL reads the backslash in a search pattern as a special character, so the search never matched. Special characters in the search text are now taken literally, so these searches work on both databases, and a % or _ typed into them now matches only itself. Fixes #31422
This commit is contained in:
parent
6c2cdd0424
commit
d6b19dcaa1
3 changed files with 8 additions and 3 deletions
|
|
@ -195,7 +195,7 @@ class AutomationTable:
|
|||
stmt = stmt.filter(
|
||||
or_(
|
||||
Automation.name.ilike(f'%{query}%'),
|
||||
*(data_text.ilike(f'%{variant}%') for variant in json_text_variants(query)),
|
||||
*(data_text.icontains(variant, autoescape=True) for variant in json_text_variants(query)),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -392,7 +392,9 @@ class ModelsTable:
|
|||
else:
|
||||
meta_text = func.lower(cast(Model.meta, String))
|
||||
variants = json_text_variants(tag.lower())
|
||||
stmt = stmt.filter(or_(*(meta_text.like(f'%"{variant}"%') for variant in variants)))
|
||||
stmt = stmt.filter(
|
||||
or_(*(meta_text.contains(f'"{variant}"', autoescape=True) for variant in variants))
|
||||
)
|
||||
|
||||
order_by = filter.get('order_by')
|
||||
direction = filter.get('direction')
|
||||
|
|
|
|||
|
|
@ -346,7 +346,10 @@ class PromptsTable:
|
|||
# Fallback for dialects with no JSON array function: LIKE on the text.
|
||||
tags_text = func.lower(cast(Prompt.tags, String))
|
||||
tag_clause = or_(
|
||||
*(tags_text.like(f'%"{variant}"%') for variant in json_text_variants(tag_lower))
|
||||
*(
|
||||
tags_text.contains(f'"{variant}"', autoescape=True)
|
||||
for variant in json_text_variants(tag_lower)
|
||||
)
|
||||
)
|
||||
tag_lower = None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue