Commit 6bcf569d by liyijie

fix: 修复postgresql jsonb order的字段

parent 745029c0
...@@ -294,7 +294,7 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -294,7 +294,7 @@ class SimpleController::BaseController < ::InheritedResources::Base
order_array = Array(params.dig(:q, :jorder)) order_array = Array(params.dig(:q, :jorder))
sql= order_array.map do |order_string| sql= order_array.map do |order_string|
_attr, _order = order_string.split(' ') _attr, _order = order_string.split(' ')
_jsonb_attr = _attr.split('.').map { |a| "'#{a}'"}.join('->') _jsonb_attr = _attr.split('.').map.with_index { |a, index| index == 0 ? a : "'#{a}'"}.join('->')
"#{_jsonb_attr} #{_order}" "#{_jsonb_attr} #{_order}"
end.join(', ') end.join(', ')
association = association.order(Arel.sql(sql)) association = association.order(Arel.sql(sql))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment