有没有其他方法可以匹配PostgreSQL(版本9.3)json对象中的布尔值而不将其转换为字符串?
我的意思是: 表格在其jsoncolumn列中包含以下对象:
'{"path":"mypath", "exists": true}'
以下查询检索记录(请注意,
exists
值是作为文本使用->>
获取的):select * from thetable where jsoncolumn ->> 'exists' = 'true';
并且这一个不会:
select * from thetable where jsoncolumn -> 'exists' = true;
我想知道是否有更合适的方法进行布尔比较?
(jsoncolumn -> 'exists')::boolean = true
? - user330315