运算符不存在:json = 未知

Siv*_*r K -1 postgresql json

这是我正在尝试做的一个例子,

SELECT *
FROM ( VALUES ('{"a":1}'::json) )
  AS t(data)
WHERE data = '{"a":1}'::json;
Run Code Online (Sandbox Code Playgroud)

但它给了我这个错误,

ERROR:  operator does not exist: json = json
LINE 4: WHERE data = '{"a":1}'::json;
                   ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

Cra*_*ger 5

test=> SELECT '{"x":1}'::json = '{"y":1}'::json;
ERROR:  operator does not exist: json = json
LINE 1: SELECT '{"x":1}'::json = '{"y":1}'::json;
                               ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

对比

test=> SELECT '{"x":1}'::jsonb = '{"y":1}'::jsonb;
 ?column? 
----------
 f
(1 row)
Run Code Online (Sandbox Code Playgroud)

没有=运算符json。那是因为它只存储原始 json 文本,并且不清楚在这种情况下究竟相等是什么意思:json 文本是否相同,或者 json 内容在逻辑上是否相同?如果对象中有重复的键,并且其中一个是相等的,但一个不是,那又会怎样呢?

jsonbPostgreSQL 9.4 中新的二进制存储类型仅存储 json 数据的逻辑结构,并具有相等运算符。