Bug fix in persistence CityObject

This commit is contained in:
Guille Gutierrez 2023-11-17 08:16:19 +01:00
parent 5fa55ea79f
commit 601058fc5e

View File

@ -142,12 +142,12 @@ class CityObject(Repository):
try:
# search by name first
with Session(self.engine) as session:
city_object = session.execute(select(Model).where(Model.name == name, Model.city_id in city_ids)).first()
city_object = session.execute(select(Model).where(Model.name == name, Model.city_id.in_(tuple(city_ids)))).first()
if city_object is not None:
return city_object[0]
# name not found, so search by alias instead
city_objects = session.execute(
select(Model).where(Model.aliases.contains(name), Model.city_id in city_ids)
select(Model).where(Model.aliases.contains(name), Model.city_id.in_(tuple(city_ids)))
).all()
for city_object in city_objects:
aliases = city_object[0].aliases.replace('{', '').replace('}', '').split(',')