无法按“0000000000000”jsonb 列进行过滤

Can not filter by '0000000000000' jsonb column

数据为jsonb类型

这个查询有效

select id, modified_at, data,states from order where  data->'id' = '2100000044078'

不错

但这行不通

select id, modified_at, data,states from shop_order where  data->'id' = '0000000000000'

错误:

LINE 2: ..., data,states from order where  data->'id' = '000000000...
                                                             ^
DETAIL:  Token "0000000000000" is invalid.
CONTEXT:  JSON data, line 1: 0000000000000
SQL state: 22P02
Character: 161

-> returns 一个 jsonb 值,但您正试图将其与文本列进行比较。因此 Postgres 尝试将右侧的值转换为 jsonb.

使用 ->> 运算符代替 returns 值作为 text

where data->>'id' = '0000000000000'