diff --git a/commons/data_access_layer/cosmos_db.py b/commons/data_access_layer/cosmos_db.py index 2b1dee9d..541a4786 100644 --- a/commons/data_access_layer/cosmos_db.py +++ b/commons/data_access_layer/cosmos_db.py @@ -92,7 +92,7 @@ def __init__( container_id: str, partition_key_attribute: str, mapper: Callable = None, - order_fields: list = [], + order_fields: list = None, custom_cosmos_helper: CosmosDBFacade = None, ): global cosmos_helper @@ -100,7 +100,7 @@ def __init__( if self.cosmos_helper is None: # pragma: no cover raise ValueError("The cosmos_db module has not been initialized!") self.mapper = mapper - self.order_fields = order_fields + self.order_fields = order_fields if order_fields else [] self.container: ContainerProxy = self.cosmos_helper.db.get_container_client( container_id ) @@ -224,14 +224,20 @@ def find( def find_all( self, event_context: EventContext, - conditions: dict = {}, - custom_sql_conditions: List[str] = [], - custom_params: dict = {}, + conditions: dict = None, + custom_sql_conditions: List[str] = None, + custom_params: dict = None, max_count=None, offset=0, visible_only=True, mapper: Callable = None, ): + conditions = conditions if conditions else {} + custom_sql_conditions = ( + custom_sql_conditions if custom_sql_conditions else [] + ) + custom_params = custom_params if custom_params else {} + partition_key_value = self.find_partition_key_value(event_context) max_count = self.get_page_size_or(max_count) params = [ diff --git a/time_tracker_api/time_entries/time_entries_model.py b/time_tracker_api/time_entries/time_entries_model.py index 08360876..0c740cab 100644 --- a/time_tracker_api/time_entries/time_entries_model.py +++ b/time_tracker_api/time_entries/time_entries_model.py @@ -160,12 +160,15 @@ def create_sql_date_range_filter(date_range: dict) -> str: def find_all_entries( self, event_context: EventContext, - conditions: dict = {}, + conditions: dict = None, custom_sql_conditions: List[str] = None, - date_range: dict = {}, + date_range: dict = None, ): - if custom_sql_conditions is None: - custom_sql_conditions = [] + conditions = conditions if conditions else {} + custom_sql_conditions = ( + custom_sql_conditions if custom_sql_conditions else [] + ) + date_range = date_range if date_range else {} custom_sql_conditions.append( self.create_sql_date_range_filter(date_range) @@ -184,11 +187,17 @@ def find_all_entries( def find_all( self, event_context: EventContext, - conditions: dict = {}, - custom_sql_conditions: List[str] = [], - date_range: dict = {}, + conditions: dict = None, + custom_sql_conditions: List[str] = None, + date_range: dict = None, **kwargs, ): + conditions = conditions if conditions else {} + custom_sql_conditions = ( + custom_sql_conditions if custom_sql_conditions else [] + ) + date_range = date_range if date_range else {} + custom_sql_conditions.append( self.create_sql_date_range_filter(date_range) ) @@ -486,7 +495,7 @@ def find_running(self): # self.stop_time_entry_if_was_left_running(time_entry) return time_entry - def get_worked_time(self, args: dict = {}): + def get_worked_time(self, args: dict): event_ctx = self.create_event_context( "read", "Summary of worked time in the current month" )