Bug correction in persistence

This commit is contained in:
Guille Gutierrez 2023-10-27 10:28:20 +02:00
parent 6332519e12
commit 6aafda7f42
2 changed files with 4 additions and 6 deletions

View File

@ -122,10 +122,9 @@ class DBControl:
) )
if result_sets is None: if result_sets is None:
continue continue
results[scenario_name] = []
for result_set in result_sets: for result_set in result_sets:
city_id = result_set[0].id city_id = result_set[0].id
results[scenario_name] = []
for building_name in scenario[scenario_name]: for building_name in scenario[scenario_name]:
_building = self._city_object.get_by_name_or_alias_and_city(building_name, city_id) _building = self._city_object.get_by_name_or_alias_and_city(building_name, city_id)
if _building is None: if _building is None:

View File

@ -112,9 +112,9 @@ class City(Repository):
try: try:
with Session(self.engine) as session: with Session(self.engine) as session:
result_set = session.execute(select(Model).where(Model.user_id == user_id, result_set = session.execute(select(Model).where(Model.user_id == user_id,
Model.application_id == application_id, Model.application_id == application_id,
Model.scenario == scenario Model.scenario == scenario
)).all() )).all()
return result_set return result_set
except SQLAlchemyError as err: except SQLAlchemyError as err:
logging.error('Error while fetching city by name %s', err) logging.error('Error while fetching city by name %s', err)
@ -136,4 +136,3 @@ class City(Repository):
except SQLAlchemyError as err: except SQLAlchemyError as err:
logging.error('Error while fetching city by name %s', err) logging.error('Error while fetching city by name %s', err)
raise SQLAlchemyError from err raise SQLAlchemyError from err