aliased-author-fix
All checks were successful
Deploy on push / deploy (push) Successful in 2m12s

This commit is contained in:
Untone 2024-02-25 19:44:33 +03:00
parent 9ea10ba5c1
commit c7fe7f458c

View File

@ -44,9 +44,10 @@ async def get_author(_, _info, slug='', author_id=None):
try: try:
if slug: if slug:
with local_session() as session: with local_session() as session:
q = select(Author).filter(Author.slug == slug) aliased_author = aliased(Author)
q = select(aliased_author).filter(Author.slug == slug)
[author] = session.execute(q) [author] = session.execute(q)
author_id = author.id author_id = aliased_author.id
if author_id: if author_id:
cache = await redis.execute('GET', f'id:{author_id}:author') cache = await redis.execute('GET', f'id:{author_id}:author')
if not cache: if not cache: