1,035
edits
No edit summary |
|||
Line 193: | Line 193: | ||
.or(Status.where(id: inner_query)) | .or(Status.where(id: inner_query)) | ||
end | end | ||
</syntaxhighlight> | |||
=== Example Query === | |||
<syntaxhighlight lang="sql"> | |||
SELECT "statuses"."id", "statuses"."updated_at" | |||
FROM "statuses" | |||
INNER JOIN "accounts" ON "accounts"."id" = "statuses"."account_id" | |||
WHERE "statuses"."visibility" = $1 | |||
AND "accounts"."suspended_at" IS NULL | |||
AND "accounts"."silenced_at" IS NULL | |||
AND ( | |||
statuses.reply = FALSE | |||
OR statuses.in_reply_to_account_id = statuses.account_id | |||
) | |||
AND ( | |||
"statuses"."reblog_of_id" IS NULL | |||
OR "statuses"."id" IN ( | |||
SELECT DISTINCT ON (reblog_of_id) statuses.id | |||
FROM "statuses" | |||
WHERE "statuses"."deleted_at" IS NULL | |||
AND "statuses"."id" IN ( | |||
SELECT "statuses"."id" FROM "statuses" | |||
WHERE "statuses"."deleted_at" IS NULL | |||
AND "statuses"."id" < 111819125737828654 | |||
ORDER BY "statuses"."id" DESC | |||
LIMIT $2 | |||
) | |||
ORDER BY "statuses"."reblog_of_id" DESC, "statuses"."id" DESC | |||
) | |||
) | |||
AND ( | |||
"statuses"."local" = $3 | |||
OR "statuses"."uri" IS NULL | |||
) | |||
AND "statuses"."deleted_at" IS NULL | |||
AND 1=1 | |||
AND "statuses"."id" < 111813463418866657 | |||
ORDER BY "statuses"."id" DESC LIMIT $4 | |||
[["visibility", 0], ["LIMIT", 100], ["local", true], ["LIMIT", 20]] | |||
</syntaxhighlight> | </syntaxhighlight> | ||