Python - Документация

Логика

(VotingAchievement.uuid == nomination_id) if nomination_id else True ~ VotingAchievement.uuid

Alchemy

nominations = await self._session.execute( select(VotingAchievement).where( ~VotingAchievement.is_deleted, VotingAchievement.is_published, (VotingAchievement.uuid == nomination_id) if nomination_id else True, ).order_by(VotingAchievement.position).options( selectinload(VotingAchievement.icon), selectinload(VotingAchievement.preview) ) ) for nomination in nominations.scalars().all(): ...

Ссылки