Fix unqualified column references.
Fix various places to avoid unqualified column references to prevent any potential ambiguous column errors.
This commit is contained in:
@@ -65,7 +65,7 @@ class Comment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_last_commented_at_on_destroy
|
def update_last_commented_at_on_destroy
|
||||||
other_comments = Comment.where("post_id = ? and id <> ?", post_id, id).order("id DESC")
|
other_comments = Comment.where("post_id = ? and id <> ?", post_id, id).order(id: :desc)
|
||||||
if other_comments.count == 0
|
if other_comments.count == 0
|
||||||
Post.where(:id => post_id).update_all(:last_commented_at => nil)
|
Post.where(:id => post_id).update_all(:last_commented_at => nil)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class ForumPost < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_topic_updated_at_on_delete
|
def update_topic_updated_at_on_delete
|
||||||
max = ForumPost.where(:topic_id => topic.id, :is_deleted => false).order("updated_at desc").first
|
max = ForumPost.where(topic_id: topic.id, is_deleted: false).order(updated_at: :desc).first
|
||||||
if max
|
if max
|
||||||
ForumTopic.where(:id => topic.id).update_all(["updated_at = ?, updater_id = ?", max.updated_at, max.updater_id])
|
ForumTopic.where(:id => topic.id).update_all(["updated_at = ?, updater_id = ?", max.updated_at, max.updater_id])
|
||||||
end
|
end
|
||||||
@@ -140,7 +140,7 @@ class ForumPost < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_topic_updated_at_on_destroy
|
def update_topic_updated_at_on_destroy
|
||||||
max = ForumPost.where(:topic_id => topic.id, :is_deleted => false).order("updated_at desc").first
|
max = ForumPost.where(topic_id: topic.id, is_deleted: false).order(updated_at: :desc).first
|
||||||
if max
|
if max
|
||||||
ForumTopic.where(:id => topic.id).update_all(["response_count = response_count - 1, updated_at = ?, updater_id = ?", max.updated_at, max.updater_id])
|
ForumTopic.where(:id => topic.id).update_all(["response_count = response_count - 1, updated_at = ?, updater_id = ?", max.updated_at, max.updater_id])
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
class NewsUpdate < ApplicationRecord
|
class NewsUpdate < ApplicationRecord
|
||||||
belongs_to :creator, class_name: "User"
|
belongs_to :creator, class_name: "User"
|
||||||
belongs_to_updater
|
belongs_to_updater
|
||||||
scope :recent, -> {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)}
|
scope :recent, -> {where("created_at >= ?", 2.weeks.ago).order(created_at: :desc).limit(5)}
|
||||||
|
|
||||||
def self.visible(user)
|
def self.visible(user)
|
||||||
if user.is_admin?
|
if user.is_admin?
|
||||||
|
|||||||
@@ -983,11 +983,11 @@ class Post < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def random_up(key)
|
def random_up(key)
|
||||||
where("md5 < ?", key).reorder("md5 desc").first
|
where("md5 < ?", key).reorder(md5: :desc).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def random_down(key)
|
def random_down(key)
|
||||||
where("md5 >= ?", key).reorder("md5 asc").first
|
where("md5 >= ?", key).reorder(md5: :asc).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def sample(query, sample_size)
|
def sample(query, sample_size)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class SavedSearch < ApplicationRecord
|
|||||||
def labels_for(user_id)
|
def labels_for(user_id)
|
||||||
SavedSearch
|
SavedSearch
|
||||||
.where(user_id: user_id)
|
.where(user_id: user_id)
|
||||||
.order("label")
|
.order(label: :asc)
|
||||||
.pluck(Arel.sql("distinct unnest(labels) as label"))
|
.pluck(Arel.sql("distinct unnest(labels) as label"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -295,11 +295,11 @@ class Tag < ApplicationRecord
|
|||||||
|
|
||||||
case params[:order]
|
case params[:order]
|
||||||
when "name"
|
when "name"
|
||||||
q = q.order("name")
|
q = q.order(name: :asc)
|
||||||
when "date"
|
when "date"
|
||||||
q = q.order("id desc")
|
q = q.order(id: :desc)
|
||||||
when "count"
|
when "count"
|
||||||
q = q.order("post_count desc")
|
q = q.order(post_count: :desc)
|
||||||
when "similarity"
|
when "similarity"
|
||||||
q = q.order_similarity(params[:fuzzy_name_matches]) if params[:fuzzy_name_matches].present?
|
q = q.order_similarity(params[:fuzzy_name_matches]) if params[:fuzzy_name_matches].present?
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -657,13 +657,13 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
case params[:order]
|
case params[:order]
|
||||||
when "name"
|
when "name"
|
||||||
q = q.order("name")
|
q = q.order(name: :asc)
|
||||||
when "post_upload_count"
|
when "post_upload_count"
|
||||||
q = q.order("post_upload_count desc")
|
q = q.order(post_upload_count: :desc)
|
||||||
when "note_count"
|
when "note_count"
|
||||||
q = q.order("note_update_count desc")
|
q = q.order(note_update_count: :desc)
|
||||||
when "post_update_count"
|
when "post_update_count"
|
||||||
q = q.order("post_update_count desc")
|
q = q.order(post_update_count: :desc)
|
||||||
else
|
else
|
||||||
q = q.apply_default_order(params)
|
q = q.apply_default_order(params)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class WikiPage < ApplicationRecord
|
|||||||
|
|
||||||
case params[:order]
|
case params[:order]
|
||||||
when "title"
|
when "title"
|
||||||
q = q.order("title")
|
q = q.order(title: :asc)
|
||||||
when "post_count"
|
when "post_count"
|
||||||
q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags)
|
q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags)
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user