mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 09:33:39 +08:00
FIX: Preserve custom field array order (#24491)
This commit is contained in:
parent
1f69e806a0
commit
8fd86fbdf7
|
@ -72,6 +72,7 @@ module HasCustomFields
|
||||||
|
|
||||||
klass
|
klass
|
||||||
.where(foreign_key => ids, :name => allowed_fields)
|
.where(foreign_key => ids, :name => allowed_fields)
|
||||||
|
.order(:id)
|
||||||
.pluck(foreign_key, :name, :value)
|
.pluck(foreign_key, :name, :value)
|
||||||
.each do |cf|
|
.each do |cf|
|
||||||
result[cf[0]] ||= {}
|
result[cf[0]] ||= {}
|
||||||
|
@ -111,6 +112,7 @@ module HasCustomFields
|
||||||
|
|
||||||
"#{name}CustomField"
|
"#{name}CustomField"
|
||||||
.constantize
|
.constantize
|
||||||
|
.order(:id)
|
||||||
.where("#{fk} in (?)", map.keys)
|
.where("#{fk} in (?)", map.keys)
|
||||||
.where("name in (?)", fields)
|
.where("name in (?)", fields)
|
||||||
.pluck(fk, :name, :value)
|
.pluck(fk, :name, :value)
|
||||||
|
@ -301,7 +303,7 @@ module HasCustomFields
|
||||||
def refresh_custom_fields_from_db
|
def refresh_custom_fields_from_db
|
||||||
target = HashWithIndifferentAccess.new
|
target = HashWithIndifferentAccess.new
|
||||||
_custom_fields
|
_custom_fields
|
||||||
.order("id asc")
|
.order(:id)
|
||||||
.pluck(:name, :value)
|
.pluck(:name, :value)
|
||||||
.each { |key, value| self.class.append_custom_field(target, key, value) }
|
.each { |key, value| self.class.append_custom_field(target, key, value) }
|
||||||
@custom_fields_orig = target
|
@custom_fields_orig = target
|
||||||
|
|
Loading…
Reference in New Issue
Block a user