distinct-fix

This commit is contained in:
2025-05-30 08:51:24 +03:00
parent 1223c1d278
commit d917d63bf2
4 changed files with 9 additions and 7 deletions

View File

@@ -79,7 +79,9 @@ def get_reactions_with_stat(q, limit=10, offset=0):
>>> get_reactions_with_stat(q, 10, 0) # doctest: +SKIP
[{'id': 1, 'body': 'Текст комментария', 'stat': {'rating': 5, 'comments_count': 3}, ...}]
"""
q = q.distinct().limit(limit).offset(offset)
# Убираем distinct() поскольку GROUP BY уже обеспечивает уникальность,
# а distinct() вызывает ошибку PostgreSQL с JSON полями
q = q.limit(limit).offset(offset)
reactions = []
with local_session() as session: