mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 00:11:59 +00:00
PostgreSQL 上和 SQLite 一致的两处:知识库统计的 sum 转成整数(PostgreSQL 的 sum 交回 numeric,驱动给 Decimal);对象索引按注释搜索不分大小写(SQLite 的 LIKE 对 ASCII 本来就不分,PostgreSQL 分,改用 icontains)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -399,7 +399,8 @@ async def list_collections(session: AsyncSession) -> list[dict[str, Any]]:
|
||||
func.sum(Document.chunk_count),
|
||||
).group_by(Document.collection)
|
||||
)
|
||||
# sum 在 PostgreSQL 上给的是 numeric(驱动交回 Decimal),SQLite 给整数:一律转成 int
|
||||
return [
|
||||
{"collection": name, "documents": docs, "chunks": chunks or 0}
|
||||
{"collection": name, "documents": int(docs), "chunks": int(chunks or 0)}
|
||||
for name, docs, chunks in rows
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user