diff --git a/hub/persistence/repositories/application.py b/hub/persistence/repositories/application.py index 7df3cc9d..91d720ec 100644 --- a/hub/persistence/repositories/application.py +++ b/hub/persistence/repositories/application.py @@ -43,7 +43,6 @@ class Application(Repository): try: application = Model(name=name, description=description, application_uuid=application_uuid) self.session.add(application) - self.session.flush() self.session.commit() return application except SQLAlchemyError as err: @@ -76,20 +75,24 @@ class Application(Repository): """ try: self.session.query(Model).filter(Model.application_uuid == application_uuid).delete() + self.session.flush() self.session.commit() except SQLAlchemyError as err: logger.error(f'Error while deleting application: {err}') - def get_by_uuid(self, application_uuid: str) -> Model: + def get_by_uuid(self, application_uuid: str) -> Union[Model, None]: """ Fetch Application based on the application uuid :param application_uuid: the application uuid - :return: Application with the provided application_uuid + :return: Application with the provided application_uuid or None """ try: - return self.session.execute(select(Model).where( + result_set = self.session.execute(select(Model).where( Model.application_uuid == application_uuid) - ).first()[0] + ).first() + if result_set is None: + return None + return result_set[0] except SQLAlchemyError as err: logger.error(f'Error while fetching application by application_uuid: {err}') diff --git a/requirements.txt b/requirements.txt index 2847b47c..4f16116c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ xmltodict numpy -trimesh +trimesh[all]==3.12.0 pyproj pandas requests