Parcourir la source

Searching for bug

ogert il y a 4 ans
Parent
commit
c9b3587a76
1 fichiers modifiés avec 5 ajouts et 3 suppressions
  1. 5 3
      cdplib/db_handlers/MongodbHandler.py

+ 5 - 3
cdplib/db_handlers/MongodbHandler.py

@@ -444,12 +444,14 @@ class MongodbHandler:
         try:
 
             if attribute == None or attribute_value == None:
-                data = self._database[collection_name].find({},{'_id': return_id}).sort(sort_label, direction).limit(limit)
+                query = {}
+                data = self._database[collection_name].find(query,{'_id': return_id}).sort(sort_label, direction).limit(limit)
             else:
-                data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, {'_id': return_id}).sort(sort_label, direction).limit(limit)
+                query = {attribute: {comparison_operator: attribute_value}}
+                data = self._database[collection_name].find(query, {'_id': return_id}).sort(sort_label, direction).limit(limit)
 
             print('THIS IS THE DATA', list(data))
-            if len(list(data)) == 0:
+            if data.collection.count_documents(query) == 0:
                 self._log.warning('No data was found for the query')
                 return None