RubyonRails pg::invalidtextrepresentation:错误:数组文字格式错误

b5buobof  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(342)

我有一个带有jsonb列的下表概要文件
项目类型对象更改“项目”[{“客户id”:[1,5],“其他id”:[1},{“客户id”:[4,5],“其他id”:2}],“项目”[{“客户id”:[3,6],“其他id”:3},{“客户id”:[3,5],“其他id”:[2}]
我有以下查询解决方案

  1. SELECT distinct profiles.*
  2. FROM
  3. profiles,
  4. jsonb_to_recordset(profiles.object_changes) AS changes(customer_id integer[], other_id integer)
  5. WHERE 5 = ANY(changes.customer_id);

但是当我运行我的代码时,我得到了这个错误

  1. ActiveRecord::StatementInvalid:
  2. PG::InvalidTextRepresentation: ERROR: malformed array literal: "[1, 5]"
  3. DETAIL: Missing "=" after array dimensions.
  4. : SELECT distinct profiles.*
  5. FROM
  6. profiles,
  7. jsonb_to_recordset(profiles.object_changes) AS changes(customer_id integer[], other_id integer)
  8. WHERE '5' = ANY(changes.customer_id);

我如何解决这个问题?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题