Actually correct grouping of ANDs and ORs in the SQL

This commit is contained in:
Asaf Gartner 2024-07-06 10:46:56 +03:00
parent f47a4617bc
commit 36aec19898
1 changed files with 2 additions and 2 deletions

View File

@ -141,13 +141,13 @@ func FetchTimeline(
JOIN project ON project.id = post.project_id
WHERE
post.deleted = false AND thread.deleted = false
AND $? = true OR project.id = $? OR (
AND ($? = true OR project.id = $? OR (
project.lifecycle = ANY($?) AND NOT project.hidden
AND (SELECT bool_or(user_project.user_id = $?) OR bool_and(hmn_user.status = $?)
FROM user_project
JOIN hmn_user ON hmn_user.id = user_project.user_id
WHERE user_project.project_id = project.id) = true
)
))
`,
currentUserIsAdmin,
models.HMNProjectID,