@@ -161,7 +161,8 @@ getAllUsersQ = selectStar $ from $ table #users
161161getPostsByIdQ :: [PostId] -> Maybe (Query Schema '[] (RowPG PostRowResponse))
162162getPostsByIdQ pIds = case idsToColumn pIds of
163163 Just idQ -> Just $ selectDotStar #posts $ from (subquery (idQ `As` #ids) &
164− innerJoin (subquery $ getPostQ (orderBy [#postElements ! #rowElementOrd & Asc] . orderBy [#posts ! #postRowId & Desc]) id `As` #posts)
164+ innerJoin (subquery $ getPostQ
165+ (orderBy [#postElements ! #rowElementId & Desc, #postElements ! #rowElementOrd & Asc]) id `As` #posts)
165166 (#ids ! #id .== #posts ! #postRowId))
166167 Nothing -> Nothing
167168