aliased-union-fix
All checks were successful
Deploy on push / deploy (push) Successful in 26s

This commit is contained in:
2024-05-18 16:16:09 +03:00
parent 5fe51e03bb
commit b7dbaa6e73
2 changed files with 11 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
from sqlalchemy import and_, distinct, func, join, select, CompoundSelect
from sqlalchemy import and_, distinct, func, join, select
from sqlalchemy.orm import aliased
from orm.author import Author, AuthorFollower
@@ -181,12 +181,10 @@ def get_with_stat(q):
records = []
try:
with local_session() as session:
# Convert the CompoundSelect object to a Query object
if isinstance(q, CompoundSelect):
q = session.query().from_statement(q)
# detect author
is_author = f"{q}".lower().startswith("select author")
# Add stat columns to the query
q = add_author_stat_columns(q) if is_author else add_topic_stat_columns(q)
# execute query