BUG #11178: JSONB : The NOT operator applies to the <@ operator, even after casting to ::bool

Поиск
Список
Период
Сортировка
От cpronovost@innvue.com
Тема BUG #11178: JSONB : The NOT operator applies to the <@ operator, even after casting to ::bool
Дата
Msg-id 20140815211138.2543.16364@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #11178: JSONB : The NOT operator applies to the <@ operator, even after casting to ::bool  (David G Johnston <david.g.johnston@gmail.com>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      11178
Logged by:          Christian Pronovost
Email address:      cpronovost@innvue.com
PostgreSQL version: 9.4beta2
Operating system:   Windows 7 Pro SP1
Description:

When using the <@ operator in conjunction with the NOT operator on a jsonb
column, the NOT reverse the <@ operator(becomes a @>).

However, when casting the result of the <@ operation to a ::bool, the NOT
operator stills applies to the <@ operator, rather than the ::bool.

Note: the NOT operator will apply to the ::bool if it is casted to ::text
prior to ::bool.(See complete example below)

Is the ::bool cast ignored since the operation already returns a boolean?
(causing the NOT operator to apply to the jsonb <@ Operator instead?)

Regards,
Chris




CREATE TABLE "TestJsonb"
(
  testcolumn jsonb
)
WITH (
  OIDS=FALSE
);
ALTER TABLE "TestJsonb"
  OWNER TO postgres;

INSERT INTO "TestJsonb" VALUES ('{"ID":"1"}')

SELECT testcolumn->'ID' <@ '["1"]' FROM "TestJsonb" --Returns true (as
expected)
SELECT NOT(testcolumn->'ID' <@ '["1"]') FROM "TestJsonb" --Returns false (as
expected)

SELECT testcolumn->'ID' <@ '["2"]' FROM"TestJsonb" --Returns false (as
expected)
SELECT NOT((testcolumn->'ID' <@ '["2"]')::bool) FROM "TestJsonb" --Returns
false (not as expected, seems to change the '<@' operator to '@>')

SELECT NOT((testcolumn->'ID' <@ '["2"]')::text)::bool FROM "TestJsonb"
--Returns true (as expected)

В списке pgsql-bugs по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: Postgresql on windows SSL.
Следующее
От: David G Johnston
Дата:
Сообщение: Re: BUG #11178: JSONB : The NOT operator applies to the <@ operator, even after casting to ::bool