From 143e9a9fa98ec8d916071da1263f6dcf020fce0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Tue, 5 Apr 2022 01:26:48 +0000 Subject: [PATCH] lazy=joined for Device.owner --- api/kiwi_vpn_api/db/device.py | 3 +++ api/kiwi_vpn_api/easyrsa.py | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/kiwi_vpn_api/db/device.py b/api/kiwi_vpn_api/db/device.py index 46750cd..1b98122 100644 --- a/api/kiwi_vpn_api/db/device.py +++ b/api/kiwi_vpn_api/db/device.py @@ -56,6 +56,9 @@ class Device(DeviceRead, table=True): # might be a future problem? owner: User = Relationship( back_populates="devices", + sa_relationship_kwargs={ + "lazy": "joined", + }, ) @classmethod diff --git a/api/kiwi_vpn_api/easyrsa.py b/api/kiwi_vpn_api/easyrsa.py index 4c082dd..e86e60e 100644 --- a/api/kiwi_vpn_api/easyrsa.py +++ b/api/kiwi_vpn_api/easyrsa.py @@ -301,11 +301,9 @@ if __name__ == "__main__": Connection.connect(current_config.db.uri) if (device := Device.get(1)) is not None: - with Connection.session as db: - db.add(device) - dn = DistinguishedName.build(device) - - client = easy_rsa.issue(dn=dn) + client = easy_rsa.issue( + dn=DistinguishedName.build(device) + ) for cert in (ca, server, client): if cert is not None: