fix missing join in full post query
This commit is contained in:
parent
77b8172676
commit
06799a5088
@ -163,7 +163,25 @@ class Topics(Model):
|
|||||||
class Threads(Model):
|
class Threads(Model):
|
||||||
table = "threads"
|
table = "threads"
|
||||||
|
|
||||||
|
def get_posts(self, limit, offset):
|
||||||
|
q = Posts.FULL_POSTS_QUERY + " WHERE posts.thread_id = ? ORDER BY posts.created_at ASC LIMIT ? OFFSET ?"
|
||||||
|
return db.query(q, self.id, limit, offset)
|
||||||
|
|
||||||
class Posts(Model):
|
class Posts(Model):
|
||||||
|
FULL_POSTS_QUERY = """
|
||||||
|
SELECT
|
||||||
|
posts.id, posts.created_at, post_history.content, post_history.edited_at, users.username, users.status, avatars.file_path AS avatar_path, posts.thread_id, users.id AS user_id, post_history.original_markup, users.signature_rendered, threads.slug AS thread_slug, threads.is_locked AS thread_is_locked
|
||||||
|
FROM
|
||||||
|
posts
|
||||||
|
JOIN
|
||||||
|
post_history ON posts.current_revision_id = post_history.id
|
||||||
|
JOIN
|
||||||
|
users ON posts.user_id = users.id
|
||||||
|
JOIN
|
||||||
|
threads ON posts.thread_id = threads.id
|
||||||
|
LEFT JOIN
|
||||||
|
avatars ON users.avatar_id = avatars.id"""
|
||||||
|
|
||||||
table = "posts"
|
table = "posts"
|
||||||
|
|
||||||
class PostHistory(Model):
|
class PostHistory(Model):
|
||||||
|
Loading…
Reference in New Issue
Block a user