Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: set the func.coalesce() second paramter default value #21239 (#21240)

YoungLHb8b9c3a783f5
diff --git a/api/models/dataset.py b/api/models/dataset.py
index ad43d6f3714..1ec27203a07 100644
--- a/api/models/dataset.py
+++ b/api/models/dataset.py
@@ -140,7 +140,7 @@ class Dataset(Base):
def word_count(self):
return (
db.session.query(Document)
- .with_entities(func.coalesce(func.sum(Document.word_count)))
+ .with_entities(func.coalesce(func.sum(Document.word_count), 0))
.filter(Document.dataset_id == self.id)
.scalar()
)
@@ -448,7 +448,7 @@ class Document(Base):
def hit_count(self):
return (
db.session.query(DocumentSegment)
- .with_entities(func.coalesce(func.sum(DocumentSegment.hit_count)))
+ .with_entities(func.coalesce(func.sum(DocumentSegment.hit_count), 0))
.filter(DocumentSegment.document_id == self.id)
.scalar()
)