mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-25 21:20:32 +03:00
Empty lists correctly roundtrip.
This commit is contained in:
parent
b5ef5ef21d
commit
89e4d4c7bb
1
NEWS-2.3
1
NEWS-2.3
|
@ -5,6 +5,7 @@ What's new in psycopg 2.3.2
|
|||
missing encodings: EUC_CN, EUC_JIS_2004, ISO885910, ISO885916,
|
||||
LATIN10, SHIFT_JIS_2004.
|
||||
- Dropped repeated dictionary lookups with unicode query/parameters.
|
||||
- Empty lists correctly roundtrip Python -> PostgreSQL -> Python.
|
||||
|
||||
|
||||
What's new in psycopg 2.3.1
|
||||
|
|
|
@ -45,7 +45,7 @@ list_quote(listObject *self)
|
|||
|
||||
/* empty arrays are converted to NULLs (still searching for a way to
|
||||
insert an empty array in postgresql */
|
||||
if (len == 0) return Text_FromUTF8("'{}'");
|
||||
if (len == 0) return Bytes_FromString("'{}'::text[]");
|
||||
|
||||
tmp = PyTuple_New(len);
|
||||
|
||||
|
|
|
@ -126,11 +126,12 @@ class TypesBasicTests(unittest.TestCase):
|
|||
self.failUnless(str(buf2) == s, "wrong binary quoting")
|
||||
|
||||
def testArray(self):
|
||||
s = self.execute("SELECT %s AS foo", ([],))
|
||||
self.failUnlessEqual(s, [])
|
||||
s = self.execute("SELECT %s AS foo", ([[1,2],[3,4]],))
|
||||
self.failUnless(s == [[1,2],[3,4]], "wrong array quoting " + str(s))
|
||||
self.failUnlessEqual(s, [[1,2],[3,4]])
|
||||
s = self.execute("SELECT %s AS foo", (['one', 'two', 'three'],))
|
||||
self.failUnless(s == ['one', 'two', 'three'],
|
||||
"wrong array quoting " + str(s))
|
||||
self.failUnlessEqual(s, ['one', 'two', 'three'])
|
||||
|
||||
def testTypeRoundtripBinary(self):
|
||||
o1 = buffer("".join(map(chr, range(256))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user