false } 我想获取所有ignore字段为true的记录: @user.posts.where("in-6ren">
gpt4 book ai didi

ruby-on-rails - PG::UndefinedFunction: 错误:运算符不存在:文本 = bool 值

转载 作者:行者123 更新时间:2023-11-29 12:48:43 25 4
gpt4 key购买 nike

有一个具有以下结构的 JSONB information 字段:

{
"ignore"=>false
}

我想获取所有ignore字段为true的记录:

@user.posts.where("information ->> 'ignore' = TRUE")

这一行抛出一个错误:

PG::UndefinedFunction: ERROR:  operator does not exist: text = boolean

而且我在 Google 中找不到任何内容。我们到处都在谈论文本含义。但是没有关于 bool 值的内容。

最佳答案

您必须将 information->>'ignore' 的结果转换为 bool 值:

@user.posts.where("(information ->> 'ignore')::boolean = TRUE")

关于ruby-on-rails - PG::UndefinedFunction: 错误:运算符不存在:文本 = bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59009367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com