Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nez4l-0005WH-GE for pgsql-bugs@arkaria.postgresql.org; Thu, 14 Apr 2022 12:59:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nez4j-00084P-7j for pgsql-bugs@arkaria.postgresql.org; Thu, 14 Apr 2022 12:59:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nez4i-00084F-Tl for pgsql-bugs@lists.postgresql.org; Thu, 14 Apr 2022 12:59:52 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nez4f-0003qk-Gx for pgsql-bugs@lists.postgresql.org; Thu, 14 Apr 2022 12:59:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Reply-To: Message-ID:Subject:To:Sender:From:Date:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BzuFmDS4oot5amAxde/vIl0a9AAnIRUG9ue4Zm9NSqg=; b=aKS2cYD9+wGsY4shZue6GHQQMq 7Sb121sf2pesCwsIuGPbhxd9/Ll/Yp9C7i6Ms7B4jjXnlucLpzvTg554F6gYnvy9SQMfzIAWsPd53 fwSii5i1Te1YHSvqNSKSwKbMktvDdOscvaOL0vLDDn0R9rp5q25ArpUjMeATsNiPjWHw=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1nez4d-0003a3-4j for pgsql-bugs@lists.postgresql.org; Thu, 14 Apr 2022 14:59:47 +0200 Date: Thu, 14 Apr 2022 14:59:47 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: PostgreSQL mailing lists Subject: Misleading docs for SQL/JSON Message-ID: <20220414125947.GA8532@depesz.com> Reply-To: depesz@depesz.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, in docs for SQL/JSON, specifically these examples: https://www.postgresql.org/docs/devel/functions-json.html#id-1.5.8.22.7.8.6.6 We can find this: #v+ SELECT JSON_VALUE('"123.45"', '$' RETURNING float); json_value ------------ 123.45 (1 row) SELECT JSON_VALUE('123.45', '$' RETURNING int ERROR ON ERROR); json_value ------------ 123 (1 row) SELECT JSON_VALUE('"03:04 2015-02-01"', '$.datetime("HH24:MI YYYY-MM-DD")' RETURNING date); json_value ------------ 2015-02-01 (1 row) #v- The thing is - none of these queries work: #v+ $ SELECT JSON_VALUE('"123.45"', '$' RETURNING float); ERROR: JSON_VALUE() is not yet implemented for json type LINE 1: SELECT JSON_VALUE('"123.45"', '$' RETURNING float); ^ $ SELECT JSON_VALUE('123.45', '$' RETURNING int ERROR ON ERROR); ERROR: JSON_VALUE() is not yet implemented for json type LINE 1: SELECT JSON_VALUE('123.45', '$' RETURNING int ERROR ON ERROR... ^ $ SELECT JSON_VALUE('"03:04 2015-02-01"', '$.datetime("HH24:MI YYYY-MM-DD")' RETURNING date); ERROR: JSON_VALUE() is not yet implemented for json type LINE 1: SELECT JSON_VALUE('"03:04 2015-02-01"', '$.datetime("HH24:MI... ^ #v- They do work if I'll cast the item to jsonb, though: #v+ $ SELECT JSON_VALUE(jsonb '"03:04 2015-02-01"', '$.datetime("HH24:MI YYYY-MM-DD")' RETURNING date); json_value ──────────── 2015-02-01 (1 row) #v-