Re: 'text' instead of 'unknown' in Postgres 10

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 'text' instead of 'unknown' in Postgres 10
Date: 2017-02-07 14:59:32
Message-ID: a55b6a41-7942-312d-1471-1668e8855b8d@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02/07/2017 03:14 PM, Daniele Varrazzo wrote:
> In psycopg '{}'::unknown is treated specially as an empty array and
> converted into an empty list, which allows empty lists to be passed to
> the server as arrays and returned back to python. Without the special
> case, empty lists behave differently from non-empty ones. It seems
> this behaviour cannot be maintained on PG 10 and instead users need to
> specify some form of cast for their placeholder. Previously this would
> have worked "as expected" and the 4th argument would have been an
> empty list:
>
> cur.execute("SELECT %s, %s, %s, %s", (['x'], [42], [date(2017,1,1)],
> [])); cur.fetchone()
> (['x'], [42], [datetime.date(2017, 1, 1)], '{}')

As Tom wrote this is the result of an intentional change, but no matter
if that change is a good thing or not the above behavior sounds rather
fragile. To me it does not seem safe to by default just assume that '{}'
means the empty array, it might also have been intended to be the Python
string "{}", the empty JSON object, or entirely something different.

Andreas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2017-02-07 15:04:49 Re: Cannot shutdown subscriber after DROP SUBSCRIPTION
Previous Message Pavel Raiskup 2017-02-07 14:55:32 [PATCH] configure-time knob to set default ssl ciphers