mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-13 04:26:33 +03:00
Dropped correct roundtrip of empty array
The feature in itself is not extremely useful and instead PostgreSQL is not always able to cast away from text[], which is a regression see (ticket #42).
This commit is contained in:
parent
84352e8cfb
commit
c1fe0b675a
1
NEWS
1
NEWS
|
@ -17,7 +17,6 @@ What's new in psycopg 2.4
|
||||||
missing encodings: EUC_CN, EUC_JIS_2004, ISO885910, ISO885916,
|
missing encodings: EUC_CN, EUC_JIS_2004, ISO885910, ISO885916,
|
||||||
LATIN10, SHIFT_JIS_2004.
|
LATIN10, SHIFT_JIS_2004.
|
||||||
- Dropped repeated dictionary lookups with unicode query/parameters.
|
- Dropped repeated dictionary lookups with unicode query/parameters.
|
||||||
- Empty lists correctly roundtrip Python -> PostgreSQL -> Python.
|
|
||||||
|
|
||||||
* Bug fixes:
|
* Bug fixes:
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ list_quote(listObject *self)
|
||||||
|
|
||||||
/* empty arrays are converted to NULLs (still searching for a way to
|
/* empty arrays are converted to NULLs (still searching for a way to
|
||||||
insert an empty array in postgresql */
|
insert an empty array in postgresql */
|
||||||
if (len == 0) return Bytes_FromString("'{}'::text[]");
|
if (len == 0) return Bytes_FromString("'{}'");
|
||||||
|
|
||||||
tmp = PyTuple_New(len);
|
tmp = PyTuple_New(len);
|
||||||
|
|
||||||
|
|
|
@ -152,13 +152,25 @@ class TypesBasicTests(unittest.TestCase):
|
||||||
self.assertEqual(s, buf2)
|
self.assertEqual(s, buf2)
|
||||||
|
|
||||||
def testArray(self):
|
def testArray(self):
|
||||||
s = self.execute("SELECT %s AS foo", ([],))
|
|
||||||
self.failUnlessEqual(s, [])
|
|
||||||
s = self.execute("SELECT %s AS foo", ([[1,2],[3,4]],))
|
s = self.execute("SELECT %s AS foo", ([[1,2],[3,4]],))
|
||||||
self.failUnlessEqual(s, [[1,2],[3,4]])
|
self.failUnlessEqual(s, [[1,2],[3,4]])
|
||||||
s = self.execute("SELECT %s AS foo", (['one', 'two', 'three'],))
|
s = self.execute("SELECT %s AS foo", (['one', 'two', 'three'],))
|
||||||
self.failUnlessEqual(s, ['one', 'two', 'three'])
|
self.failUnlessEqual(s, ['one', 'two', 'three'])
|
||||||
|
|
||||||
|
def testEmptyArrayRegression(self):
|
||||||
|
# ticket #42
|
||||||
|
import datetime
|
||||||
|
curs = self.conn.cursor()
|
||||||
|
curs.execute("create table array_test (id integer, col timestamp without time zone[])")
|
||||||
|
|
||||||
|
curs.execute("insert into array_test values (%s, %s)", (1, [datetime.date(2011,2,14)]))
|
||||||
|
curs.execute("select col from array_test where id = 1")
|
||||||
|
self.assertEqual(curs.fetchone()[0], [datetime.datetime(2011, 2, 14, 0, 0)])
|
||||||
|
|
||||||
|
curs.execute("insert into array_test values (%s, %s)", (2, []))
|
||||||
|
curs.execute("select col from array_test where id = 2")
|
||||||
|
self.assertEqual(curs.fetchone()[0], [])
|
||||||
|
|
||||||
@testutils.skip_on_python3
|
@testutils.skip_on_python3
|
||||||
def testTypeRoundtripBuffer(self):
|
def testTypeRoundtripBuffer(self):
|
||||||
o1 = buffer("".join(map(chr, range(256))))
|
o1 = buffer("".join(map(chr, range(256))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user