在 PostgreSQL 数据库中的 hstore 列中,我知道可以使用类似下面这样的“LIKE”查询来搜索包含特定字符串的名称(在 Ruby on Rails 中):
Product.where("hstore_data -> 'author' LIKE '%billy%'")
我尝试对jsonb列类型使用这种方法,但是出现了以下错误:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: operator does not exist: jsonb ~~ unknown
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. : SELECT "products".* FROM "products" WHERE (jsonb_data -> 'author' LIKE '%billy%')
有没有一种方法可以正确地在jsonb列类型中使用“LIKE”?