#2217 fix ambiguous table references
This commit is contained in:
@@ -228,28 +228,28 @@ class PostQueryBuilder
|
||||
|
||||
if q[:commenter_ids]
|
||||
q[:commenter_ids].each do |commenter_id|
|
||||
relation = relation.where(:id => Comment.where("creator_id = ?", commenter_id).select("post_id").uniq)
|
||||
relation = relation.where("posts.id IN (?)", Comment.where("creator_id = ?", commenter_id).select("post_id").uniq)
|
||||
end
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if q[:noter_ids]
|
||||
q[:noter_ids].each do |noter_id|
|
||||
relation = relation.where(:id => Note.where("creator_id = ?", noter_id).select("post_id").uniq)
|
||||
relation = relation.where("posts.id IN (?)", Note.where("creator_id = ?", noter_id).select("post_id").uniq)
|
||||
end
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if q[:note_updater_ids]
|
||||
q[:note_updater_ids].each do |note_updater_id|
|
||||
relation = relation.where(:id => NoteVersion.where("updater_id = ?", note_updater_id).select("post_id").uniq)
|
||||
relation = relation.where("posts.id IN (?)", NoteVersion.where("updater_id = ?", note_updater_id).select("post_id").uniq)
|
||||
end
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if q[:artcomm_ids]
|
||||
q[:artcomm_ids].each do |artcomm_id|
|
||||
relation = relation.where(:id => ArtistCommentaryVersion.where("updater_id = ?", artcomm_id).select("post_id").uniq)
|
||||
relation = relation.where("posts.id IN (?)", ArtistCommentaryVersion.where("updater_id = ?", artcomm_id).select("post_id").uniq)
|
||||
end
|
||||
has_constraints!
|
||||
end
|
||||
@@ -314,7 +314,8 @@ class PostQueryBuilder
|
||||
|
||||
if q[:ordfav].present?
|
||||
user_id = q[:ordfav].to_i
|
||||
relation = relation.joins(:favorites).where("favorites.user_id % 100 = ? and favorites.user_id = ?", user_id % 100, user_id).order("favorites.id DESC")
|
||||
relation = relation.joins("INNER JOIN favorites ON favorites.post_id = posts.id")
|
||||
relation = relation.where("favorites.user_id % 100 = ? and favorites.user_id = ?", user_id % 100, user_id).order("favorites.id DESC")
|
||||
end
|
||||
|
||||
if q[:order] == "rank"
|
||||
@@ -361,10 +362,12 @@ class PostQueryBuilder
|
||||
relation = relation.order("posts.last_noted_at ASC NULLS FIRST, posts.id DESC")
|
||||
|
||||
when "artcomm"
|
||||
relation = relation.joins(:artist_commentary).order("artist_commentaries.updated_at DESC, posts.id DESC")
|
||||
relation = relation.joins("INNER JOIN artist_commentaries ON artist_commentaries.post_id = posts.id")
|
||||
relation = relation.order("artist_commentaries.updated_at DESC, posts.id DESC")
|
||||
|
||||
when "artcomm_asc"
|
||||
relation = relation.joins(:artist_commentary).order("artist_commentaries.updated_at ASC, posts.id DESC")
|
||||
relation = relation.joins("INNER JOIN artist_commentaries ON artist_commentaries.post_id = posts.id")
|
||||
relation = relation.order("artist_commentaries.updated_at ASC, posts.id DESC")
|
||||
|
||||
when "mpixels", "mpixels_desc"
|
||||
# Use "w*h/1000000", even though "w*h" would give the same result, so this can use
|
||||
|
||||
Reference in New Issue
Block a user