Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XIQuh-0000TD-44 for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Aug 2014 23:28:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XIQug-0005G8-I0 for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Aug 2014 23:28:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XIOnG-0002g6-1W for pgsql-bugs@postgresql.org; Fri, 15 Aug 2014 21:12:14 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XIOn5-0007Db-F6 for pgsql-bugs@postgresql.org; Fri, 15 Aug 2014 21:12:12 +0000 MIME-Version: 1.0 Subject: BUG #11178: JSONB : The NOT operator applies to the <@ operator, even after casting to ::bool To: pgsql-bugs@postgresql.org From: cpronovost@innvue.com Date: Fri, 15 Aug 2014 21:11:38 +0000 Message-ID: <20140815211138.2543.16364@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.1 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs