Re: psycopg3 and adaptation choices

From: Federico Di Gregorio <fog(at)dndg(dot)it>
To: psycopg(at)lists(dot)postgresql(dot)org
Subject: Re: psycopg3 and adaptation choices
Date: 2020-11-09 12:05:00
Message-ID: 1546497c-ff41-9bd0-b4d7-931bd305caac@dndg.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 09/11/20 13:00, Daniele Varrazzo wrote:
> On Mon, 9 Nov 2020 at 06:57, Federico Di Gregorio <fog(at)dndg(dot)it> 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
> <ExecStatus.FATAL_ERROR: 7>
>
> >>> 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

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Vladimir Ryabtsev 2020-11-10 01:06:13 Re: psycopg3 and adaptation choices
Previous Message Daniele Varrazzo 2020-11-09 12:00:55 Re: psycopg3 and adaptation choices