Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10
От | Andreas Karlsson |
---|---|
Тема | Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10 |
Дата | |
Msg-id | a55b6a41-7942-312d-1471-1668e8855b8d@proxel.se обсуждение исходный текст |
Ответ на | [HACKERS] 'text' instead of 'unknown' in Postgres 10 (Daniele Varrazzo <daniele.varrazzo@gmail.com>) |
Ответы |
Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10
|
Список | 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
В списке pgsql-hackers по дате отправления: