Explorar o código

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

- fetch_one 返回 None 时安全处理,total_rows 默认为 0
- total_rows 为 0 时提前返回,避免不必要的循环
Sherlock hai 2 días
pai
achega
539b1851b5
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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: