Commit c37cd45e authored by Ivanq's avatar Ivanq

Repo: Rewrite getIssueComments() to make UNION ALL work

parent f3889d10
......@@ -180,9 +180,36 @@ class Repository {
}
getIssueComments(id, jsonId) {
return this.zeroDB.query("\
SELECT issues.id AS issue_id, -1 AS id, issues.body AS body, issues.date_added AS date_added, issues.json_id AS issue_json_id, issues.json_id AS json_id, json.cert_user_id AS cert_user_id FROM issues, json WHERE issues.json_id = json.json_id AND issues.json_id = :jsonId AND issues.id = :id\
SELECT\
-1 AS id,\
issues.body AS body,\
issues.date_added AS date_added,\
issues.json_id AS json_id,\
json.cert_user_id AS cert_user_id,\
issues.id AS issue_id,\
issues.json_id AS issue_json_id\
FROM issues, json\
WHERE\
issues.json_id = json.json_id AND\
issues.json_id = :jsonId\
AND issues.id = :id\
\
UNION ALL\
SELECT issue_comments.*, json.cert_user_id AS cert_user_id FROM issue_comments, json WHERE issue_comments.json_id = json.json_id AND issue_comments.json_id = :jsonId AND issue_comments.issue_id = :id\
\
SELECT\
issue_comments.id AS id,\
issue_comments.body AS body,\
issue_comments.date_added AS date_added,\
issue_comments.json_id AS json_id,\
json.cert_user_id AS cert_user_id,\
issue_comments.issue_id AS issue_id,\
issue_comments.issue_json_id AS issue_json_id\
FROM issue_comments, json\
WHERE\
issue_comments.json_id = json.json_id AND\
issue_comments.json_id = :jsonId AND\
issue_comments.issue_id = :id\
\
ORDER BY date_added ASC\
", {
jsonId: jsonId,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment