Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Optimized the get_by_id method to resolve the issue of missing exceptions and improve query performance (#6320)

lgphone7f80d7304d1c
diff --git a/api/db/services/common_service.py b/api/db/services/common_service.py
index 184f30d5c6..75bc1a6f47 100644
--- a/api/db/services/common_service.py
+++ b/api/db/services/common_service.py
@@ -225,11 +225,10 @@ class CommonService:
# pid: Record ID
# Returns:
# Tuple of (success, record)
- try:
- obj = cls.model.query(id=pid)[0]
+ obj = cls.model.get_or_none(cls.model.id == pid)
+ if obj:
return True, obj
- except Exception:
- return False, None
+ return False, None
@classmethod
@DB.connection_context()