mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 10:23:43 +03:00
parent
791befca18
commit
3e12522bc9
2
NEWS
2
NEWS
|
@ -55,6 +55,8 @@ Other changes:
|
||||||
connection.
|
connection.
|
||||||
- `~connection.set_isolation_level()` will throw an exception if executed
|
- `~connection.set_isolation_level()` will throw an exception if executed
|
||||||
inside a transaction; previously it would have silently rolled it back.
|
inside a transaction; previously it would have silently rolled it back.
|
||||||
|
- Empty arrays no more converted into lists if they don't have a type attached
|
||||||
|
(:ticket:`#506`)
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.6.3
|
What's new in psycopg 2.6.3
|
||||||
|
|
|
@ -191,14 +191,6 @@ typecast_UNKNOWN_cast(const char *str, Py_ssize_t len, PyObject *curs)
|
||||||
Dprintf("typecast_UNKNOWN_cast: str = '%s',"
|
Dprintf("typecast_UNKNOWN_cast: str = '%s',"
|
||||||
" len = " FORMAT_CODE_PY_SSIZE_T, str, len);
|
" len = " FORMAT_CODE_PY_SSIZE_T, str, len);
|
||||||
|
|
||||||
// PostgreSQL returns {} for empty array without explicit type. We convert
|
|
||||||
// that to list in order to handle empty lists.
|
|
||||||
if (len == 2 && str[0] == '{' && str[1] == '}') {
|
|
||||||
return PyList_New(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dprintf("typecast_UNKNOWN_cast: fallback to default cast");
|
|
||||||
|
|
||||||
return typecast_default.cast(str, len, curs);
|
return typecast_default.cast(str, len, curs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,12 +166,14 @@ class TypesBasicTests(ConnectingTestCase):
|
||||||
curs.execute("select col from array_test where id = 2")
|
curs.execute("select col from array_test where id = 2")
|
||||||
self.assertEqual(curs.fetchone()[0], [])
|
self.assertEqual(curs.fetchone()[0], [])
|
||||||
|
|
||||||
def testEmptyArray(self):
|
def testEmptyArrayNoCast(self):
|
||||||
s = self.execute("SELECT '{}' AS foo")
|
s = self.execute("SELECT '{}' AS foo")
|
||||||
self.failUnlessEqual(s, [])
|
self.assertEqual(s, '{}')
|
||||||
s = self.execute("SELECT '{}'::text[] AS foo")
|
|
||||||
self.failUnlessEqual(s, [])
|
|
||||||
s = self.execute("SELECT %s AS foo", ([],))
|
s = self.execute("SELECT %s AS foo", ([],))
|
||||||
|
self.assertEqual(s, '{}')
|
||||||
|
|
||||||
|
def testEmptyArray(self):
|
||||||
|
s = self.execute("SELECT '{}'::text[] AS foo")
|
||||||
self.failUnlessEqual(s, [])
|
self.failUnlessEqual(s, [])
|
||||||
s = self.execute("SELECT 1 != ALL(%s)", ([],))
|
s = self.execute("SELECT 1 != ALL(%s)", ([],))
|
||||||
self.failUnlessEqual(s, True)
|
self.failUnlessEqual(s, True)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user