Migrating resource.get to new select join

This commit is contained in:
2025-02-14 15:18:19 +01:00
parent aff702156d
commit ff9b59f38c

View File

@@ -102,7 +102,7 @@ class AccountResource:
def select(cls):
split_filter = aliased(Split)
account_filter = aliased(Account)
columns = [Account.id, Account.name, Account.family, Account.type, Account.path ,
columns = [Account.id, Account.name, Account.parent_account_id, Account.family, Account.type, Account.path,
Split.amount.label("opening_balance"), literal_column('"1970-01-01"').label("opening_date")]
return (select(*columns)
.join(Split)
@@ -146,7 +146,7 @@ class AccountResource:
@classmethod
def get(cls, session, account_id):
return session.get(Account, account_id)
return session.exec(cls.select().where(Account.id == account_id)).first()
@classmethod
def update(cls, session, account_db, account_data):