Hello everyone!
I'm trying to implement deferred property loading using select():
summaries = select(
[
func.max(transactions.c.processed_at).label('last_used'),
func.count(transactions.c.id).label('times_used'),
],
from_obj=[transactions],
).alias('summaries')
account_mapper = mapper(Account, accounts,
properties={
'last_used': deferred(summaries.c.last_used, group='summary'),
'times_used': deferred(summaries.c.times_used, group='summary')}
)
How do I specify where clause for summaries?
I tried to add the following to property list:
'account_id': [accounts.c.id, transactions.c.account_id],
but that raised an exception:
InvalidRequestError: Given column 'transactions.account_id', attached
to table 'transactions', failed to locate a corresponding column from
table 'accounts'
I couldn't find solution other than giving up using properties and
calling that select directly. But it doesn't feel right and it seems
like all it needs is a small addition to make it doing right job.
Any help is greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---