PostgreSQL 上和 SQLite 一致的两处:知识库统计的 sum 转成整数(PostgreSQL 的 sum 交回 numeric,驱动给 Decimal);对象索引按注释搜索不分大小写(SQLite 的 LIKE 对 ASCII 本来就不分,PostgreSQL 分,改用 icontains)

This commit is contained in:
ThearchyHelios
2026-10-19 10:01:20 +08:00
parent dead51ae56
commit f63d037b2c
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -886,8 +886,9 @@ async def search_index(session: AsyncSession, row: Any, query: str, *, limit: in
return [], 0
key = name_key(text.rsplit(".", 1)[-1])
filt = (*_scope_filter(row.id, index_schema(row)), SourceObject.removed_at.is_(None),
# 名字比的是 name_key(ASCII 已转小写);注释要不分大小写:SQLite 的 LIKE 本来就不分(ASCII),PostgreSQL 分
or_(SourceObject.name_key.contains(key, autoescape=True),
SourceObject.comment.contains(text, autoescape=True)))
SourceObject.comment.icontains(text, autoescape=True)))
total = int((await session.execute(select(func.count()).select_from(SourceObject).where(*filt))).scalar() or 0)
rows = (await session.execute(
select(SourceObject.name, SourceObject.name_key, SourceObject.kind, SourceObject.comment,