Przeglądaj źródła

fix: 修复 load_data_with_page 的空值和空结果集处理

- fetch_one 返回 None 时安全处理,total_rows 默认为 0
- total_rows 为 0 时提前返回,避免不必要的循环
Sherlock 2 dni temu
rodzic
commit
539b1851b5
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      database/db/mysql.py

+ 5 - 1
database/db/mysql.py

@@ -58,7 +58,11 @@ class MySqlDatabaseHelper:
         query = text(query)
 
         # 获取总行数
-        total_rows = self.fetch_one(count_query, params)[0]
+        result = self.fetch_one(count_query, params)
+        total_rows = result[0] if result is not None else 0
+
+        if total_rows == 0:
+            return data
 
         page = 1
         with tqdm(total=total_rows, desc="Loading data", unit="rows") as pbar: