Explorar el Código

Add warning message for when no data for the query can be found

ogert hace 5 años
padre
commit
6e3e9c3322
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      cdplib/db_handlers/MongodbHandler.py

+ 4 - 0
cdplib/db_handlers/MongodbHandler.py

@@ -387,6 +387,10 @@ class MongodbHandler:
             else:
                 data = self._database[collection_name].find({attribute: {comparison_operator: attribute_value}}, {'_id': return_id}).sort(sort_label, direction).limit(limit)
             
+            if len(list(data)) == 0:
+                self._log.warning('No data was found for the query')
+                return None
+
         except Exception as error:
             self._log.log_and_raise_error(('An error occured trying to query data from {}, \nError:{}').format(collection_name, error))