sql - Ruby on Rails PG::InvalidTextRepresentation: ERROR: malformed array literal
问题描述
我有下表配置文件与 jsonb 列
物品种类 | object_changes |
---|---|
“物品” | [{"customer_id": [1, 5], "other_id": 1}, {"customer_id": [4, 5], "other_id": 2}] |
“物品” | [{"customer_id": [3, 6], "other_id": 3}, {"customer_id": [3, 5], "other_id": 2}] |
我有以下查询解决方案
SELECT distinct profiles.*
FROM
profiles,
jsonb_to_recordset(profiles.object_changes) AS changes(customer_id integer[], other_id integer)
WHERE 5 = ANY(changes.customer_id);
但是当我运行我的代码时,我得到了这个错误
ActiveRecord::StatementInvalid:
PG::InvalidTextRepresentation: ERROR: malformed array literal: "[1, 5]"
DETAIL: Missing "=" after array dimensions.
: SELECT distinct profiles.*
FROM
profiles,
jsonb_to_recordset(profiles.object_changes) AS changes(customer_id integer[], other_id integer)
WHERE '5' = ANY(changes.customer_id);
我该如何解决这个问题?
解决方案
推荐阅读
- java - Java桌面客户端nodejs服务器使用socketio,socket未连接
- python - 将字符串的 TFIDF 相似度计算为 2 个 Pandas 列,并在新列中输出相似度得分
- react-native - WatermelonDB w ReactNative:如何在模型中正确使用@actions?
- sql - 将 oracle sql listagg 函数转换为 Bigquery
- python - 将 SQDIFF 与“滑动窗口视图”匹配的 NumPy 模板
- apache-spark - pySpark writerStream 未在 Jupyter Lab 中向控制台显示输出
- progressive-web-apps - 在运行相同 PWA 的两个离线设备之间同步数据
- python - 如何使用 Update_By_Query 在 Python Elastic Search 的多个文档中更新作为字段对象的字段?
- hardware-design - LT spice Simulation AD8220 显示一些奇怪的结果,我不知道为什么
- docker - 当 Logstash 容器尝试连接时 Elasticsearch 容器关闭