empty string in composite data types

Поиск
Список
Период
Сортировка
От Christian von Kietzell
Тема empty string in composite data types
Дата
Msg-id 1354536908.4153.6.camel@junction.dune
обсуждение исходный текст
Ответы Re: empty string in composite data types  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
Hi,

I noticed some (imho) odd behaviour while using composite data types.
Empty strings will be returned as None instead of '' in Python.

For example:

sql> CREATE TYPE testtype AS (id INT, label TEXT);

python> import psycopg2
python> import psycopg2.extras
python> db = psycopg2.connect(...)
python> caster = psycopg2.extras.register_composite('testtype', db)
python> cursor = db.cursor()
python> cursor.execute("SELECT (1, '')::testtype")
python> cursor.fetchone()[0]
testtype(id=1, label=None)

Is this behaviour intended? Or is there some flag I don't know about (I
have found none) that gives me empty strings instead?

Any help would be appreciated.


Cheers,
  Chris



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

Предыдущее
От: Idan Kamara
Дата:
Сообщение: Re: cursor.executemany generates multiple INSERTs
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: empty string in composite data types