mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FIX: order by op_likes leads to broken browsing
This commit is contained in:
parent
744f1fd287
commit
d28d8a1f85
|
@ -1,5 +1,6 @@
|
|||
# Speeds up #pluck so its about 2.2x faster, importantly makes pluck avoid creation of a slew
|
||||
# of AR objects
|
||||
#
|
||||
|
||||
require_dependency 'sql_builder'
|
||||
|
||||
|
@ -34,22 +35,10 @@ class ActiveRecord::Relation
|
|||
# end
|
||||
|
||||
class ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
||||
if Rails.version >= "4.2.0"
|
||||
def select_raw(arel, name = nil, binds = [], &block)
|
||||
arel, binds = binds_from_relation arel, binds
|
||||
sql = to_sql(arel, binds)
|
||||
execute_and_clear(sql, name, binds, &block)
|
||||
end
|
||||
else
|
||||
|
||||
def select_raw(arel, name = nil, binds = [], &block)
|
||||
arel, binds = binds_from_relation arel, binds
|
||||
sql = to_sql(arel, binds)
|
||||
|
||||
result = without_prepared_statement?(binds) ? exec_no_cache(sql, 'SQL', binds) :
|
||||
exec_cache(sql, 'SQL', binds)
|
||||
yield result, nil
|
||||
end
|
||||
def select_raw(arel, name = nil, binds = [], &block)
|
||||
arel, binds = binds_from_relation arel, binds
|
||||
sql = to_sql(arel, binds)
|
||||
execute_and_clear(sql, name, binds, &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -66,7 +55,6 @@ class ActiveRecord::Relation
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
if has_include?(cols.first)
|
||||
construct_relation_for_association_calculations.pluck(*cols)
|
||||
else
|
||||
|
@ -76,7 +64,7 @@ class ActiveRecord::Relation
|
|||
columns_hash.key?(cn) ? arel_table[cn] : cn
|
||||
}
|
||||
|
||||
conn.select_raw(relation) do |result,_|
|
||||
conn.select_raw(relation, nil, relation.arel.bind_values + bind_values) do |result,_|
|
||||
result.type_map = SqlBuilder.pg_type_map
|
||||
result.nfields == 1 ? result.column_values(0) : result.values
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ describe RandomTopicSelector do
|
|||
end
|
||||
|
||||
it 'can correctly backfill' do
|
||||
category = Fabricate(:category)
|
||||
category = Fabricate(:category, sort_order: 'op_likes')
|
||||
t1 = Fabricate(:topic, category_id: category.id)
|
||||
_t2 = Fabricate(:topic, category_id: category.id, visible: false)
|
||||
_t3 = Fabricate(:topic, category_id: category.id, deleted_at: 1.minute.ago)
|
||||
|
|
Loading…
Reference in New Issue
Block a user