使用 Hstore 存储为哈希表,保存后在哈希中排序错误
class Service < ActiveRecord::Base
serialize :properties, ActiveRecord::Coders::Hstore
end
service = Service.new
service.properties = { "aaa" => 1, "zz" => 2, "cc" => 3, "d" => 4 }
#=> { "aaa" => 1, "zz" => 2, "cc" => 3, "d" => 4 }
service.save
reload!
service = Service.find(:id)
service.properties
#=> { "d" => "4", "cc" => "3", "zz" => 2, "aaa" => 1 }
Bug::: wrong ordering after save
是不是因为在序列化之后它按树排序。有任何想法或任何人以前遇到过这个问题吗?提前致谢。