comparison sat/memory/sqla.py @ 3638:257135d5c5c2

core (memory/sqla): fix key/value inversion in self.profiles
author Goffi <goffi@goffi.org>
date Wed, 01 Sep 2021 15:24:59 +0200
parents 9e1a993ad1bf
children 9ae6ec74face
comparison
equal deleted inserted replaced
3637:51983c55c5b6 3638:257135d5c5c2
237 """ 237 """
238 async with self.session() as session: 238 async with self.session() as session:
239 profile = Profile(name=name) 239 profile = Profile(name=name)
240 async with session.begin(): 240 async with session.begin():
241 session.add(profile) 241 session.add(profile)
242 self.profiles[profile.id] = profile.name 242 self.profiles[profile.name] = profile.id
243 if component_ep is not None: 243 if component_ep is not None:
244 async with session.begin(): 244 async with session.begin():
245 component = Component(profile=profile, entry_point=component_ep) 245 component = Component(profile=profile, entry_point=component_ep)
246 session.add(component) 246 session.add(component)
247 self.components[profile.id] = component_ep 247 self.components[profile.id] = component_ep
256 async with self.session() as session: 256 async with self.session() as session:
257 result = await session.execute(select(Profile).where(Profile.name == name)) 257 result = await session.execute(select(Profile).where(Profile.name == name))
258 profile = result.scalar() 258 profile = result.scalar()
259 await session.delete(profile) 259 await session.delete(profile)
260 await session.commit() 260 await session.commit()
261 del self.profiles[profile.id] 261 del self.profiles[profile.name]
262 if profile.id in self.components: 262 if profile.id in self.components:
263 del self.components[profile.id] 263 del self.components[profile.id]
264 log.info(_("Profile {name!r} deleted").format(name = name)) 264 log.info(_("Profile {name!r} deleted").format(name = name))
265 265
266 ## Params 266 ## Params