Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10
Дата
Msg-id CA+mi_8Yr1y7zG05NX9QDf4EjK9C50B8T-6rmV1h14pXG93kkfA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10  (Andreas Karlsson <andreas@proxel.se>)
Список pgsql-hackers
On Tue, Feb 7, 2017 at 2:59 PM, Andreas Karlsson <andreas@proxel.se> wrote:
> 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.

Yes, it could be actually the case to drop it. The case for it is
quite thin anyway: if something comes from a query it will usually
have a type attached.

-- Daniele



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: [HACKERS] pg_restore is broken on 9.2 version.
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] [COMMITTERS] pgsql: Release note updates.