lazy=joined for Device.owner

This commit is contained in:
Jörn-Michael Miehe 2022-04-05 01:26:48 +00:00
parent c94e07fbac
commit 143e9a9fa9
2 changed files with 6 additions and 5 deletions

View file

@ -56,6 +56,9 @@ class Device(DeviceRead, table=True):
# might be a future problem? # might be a future problem?
owner: User = Relationship( owner: User = Relationship(
back_populates="devices", back_populates="devices",
sa_relationship_kwargs={
"lazy": "joined",
},
) )
@classmethod @classmethod

View file

@ -301,11 +301,9 @@ if __name__ == "__main__":
Connection.connect(current_config.db.uri) Connection.connect(current_config.db.uri)
if (device := Device.get(1)) is not None: if (device := Device.get(1)) is not None:
with Connection.session as db: client = easy_rsa.issue(
db.add(device) dn=DistinguishedName.build(device)
dn = DistinguishedName.build(device) )
client = easy_rsa.issue(dn=dn)
for cert in (ca, server, client): for cert in (ca, server, client):
if cert is not None: if cert is not None: