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 1kc5v1-0003Sf-L4 for psycopg@arkaria.postgresql.org; Mon, 09 Nov 2020 12:05:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kc5v0-0005WO-FQ for psycopg@arkaria.postgresql.org; Mon, 09 Nov 2020 12:05:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kc5v0-0005WG-Ai for psycopg@lists.postgresql.org; Mon, 09 Nov 2020 12:05:06 +0000 Received: from mail.dndg.it ([178.32.136.2]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kc5ux-00044a-Vc for psycopg@lists.postgresql.org; Mon, 09 Nov 2020 12:05:05 +0000 Received: from [192.168.1.159] (93-40-251-202.ip41.fastwebnet.it [93.40.251.202]) by mail.dndg.it (Postfix) with ESMTPSA id 8BBACA0C1D for ; Mon, 9 Nov 2020 12:07:40 +0000 (UTC) Subject: Re: psycopg3 and adaptation choices To: psycopg@lists.postgresql.org References: <2b9859f0-0964-2baa-b6bc-13f975ae0f67@aklaver.com> <88fb7a7e-a182-a816-c1a7-8a1f54b65215@aklaver.com> <4830fb8d-fa57-e0f8-0e4f-a96ed040dede@dndg.it> From: Federico Di Gregorio Organization: DNDG srl Message-ID: <1546497c-ff41-9bd0-b4d7-931bd305caac@dndg.it> Date: Mon, 9 Nov 2020 13:05:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,NICE_REPLY_A, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 09/11/20 13:00, Daniele Varrazzo wrote: > On Mon, 9 Nov 2020 at 06:57, Federico Di Gregorio wrote: [snip] >> IMHO, oid is a bad idea >> because it has a very specific semantic and the error messages generated >> by PostgreSQL will be more confusing. > > I'm not sure I understand this. At the moment, the oids are something > that don't really surface to the end-users, who are not required to > use them explicitly and shouldn't be seen in the error messages. For > instance the query above might results in a call: > > >>> from psycopg3.oids import builtins > >>> builtins["numeric"].oid > 1700 > > >>> res = conn.pgconn.exec_params(b"select '[]'::jsonb -> $1", > [b"1"], [1700]) > >>> res.status > > > >>> print(res.error_message.decode("utf8")) > ERROR: operator does not exist: jsonb -> numeric > LINE 1: select '[]'::jsonb -> $1 > ^ > HINT: No operator matches the given name and argument types. You > might need to add explicit type casts. > > So the oid is only used internally, in the mapping python type -> > exec_params() types array, the 1700 shouldn't surface anywhere. > > Maybe I'm misunderstanding your concern: can you tell me better? My fault. I misread and though you wanted to use OID as *the* type to pass to PostggreSQL for numbers. federico