我正在尝试使用 rails 中的 jsonb 列进行排序:
Stat.order("data ->'likes'->'followed_by' ASC")
我不断收到此错误返回。
PG::UndefinedFunction: ERROR: could not identify an ordering operator for type json
我不知道这是我的格式吗?follow_by 属性是一个 int。
谢谢!
我正在尝试使用 rails 中的 jsonb 列进行排序:
Stat.order("data ->'likes'->'followed_by' ASC")
我不断收到此错误返回。
PG::UndefinedFunction: ERROR: could not identify an ordering operator for type json
我不知道这是我的格式吗?follow_by 属性是一个 int。
谢谢!
我不确定,但根据http://www.postgresql.org/docs/9.3/static/functions-json.html
->
“获取 JSON 对象字段”->>
“将 JSON 对象字段作为文本获取”所以也许activerecord不能排序field
但可以排序text
?
尝试:Stat.order("data ->'likes'->>'followed_by' ASC")