mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
parent
02ffb7423a
commit
9a031db8b9
1
NEWS
1
NEWS
|
@ -33,6 +33,7 @@ What's new in psycopg 2.4.5
|
||||||
- Discard any result produced by 'executemany()' (ticket #133).
|
- Discard any result produced by 'executemany()' (ticket #133).
|
||||||
- Fixed pickling of FixedOffsetTimezone objects (ticket #135).
|
- Fixed pickling of FixedOffsetTimezone objects (ticket #135).
|
||||||
- Release the GIL around PQgetResult calls after COPY (ticket #140).
|
- Release the GIL around PQgetResult calls after COPY (ticket #140).
|
||||||
|
- Fixed empty strings handling in composite caster (ticket #141).
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.4.5
|
What's new in psycopg 2.4.5
|
||||||
|
|
|
@ -852,9 +852,9 @@ class CompositeCaster(object):
|
||||||
for m in self._re_tokenize.finditer(s):
|
for m in self._re_tokenize.finditer(s):
|
||||||
if m is None:
|
if m is None:
|
||||||
raise psycopg2.InterfaceError("can't parse type: %r" % s)
|
raise psycopg2.InterfaceError("can't parse type: %r" % s)
|
||||||
if m.group(1):
|
if m.group(1) is not None:
|
||||||
rv.append(None)
|
rv.append(None)
|
||||||
elif m.group(2):
|
elif m.group(2) is not None:
|
||||||
rv.append(self._re_undouble.sub(r"\1", m.group(2)))
|
rv.append(self._re_undouble.sub(r"\1", m.group(2)))
|
||||||
else:
|
else:
|
||||||
rv.append(m.group(3))
|
rv.append(m.group(3))
|
||||||
|
|
|
@ -501,6 +501,7 @@ class AdaptTypeTestCase(unittest.TestCase):
|
||||||
self.assertEqual(CompositeCaster.tokenize(s), v)
|
self.assertEqual(CompositeCaster.tokenize(s), v)
|
||||||
|
|
||||||
ok("(,)", [None, None])
|
ok("(,)", [None, None])
|
||||||
|
ok('(,"")', [None, ''])
|
||||||
ok('(hello,,10.234,2010-11-11)', ['hello', None, '10.234', '2010-11-11'])
|
ok('(hello,,10.234,2010-11-11)', ['hello', None, '10.234', '2010-11-11'])
|
||||||
ok('(10,"""")', ['10', '"'])
|
ok('(10,"""")', ['10', '"'])
|
||||||
ok('(10,",")', ['10', ','])
|
ok('(10,",")', ['10', ','])
|
||||||
|
@ -555,6 +556,26 @@ class AdaptTypeTestCase(unittest.TestCase):
|
||||||
self.assertEqual(v.astring, "hello")
|
self.assertEqual(v.astring, "hello")
|
||||||
self.assertEqual(v.adate, date(2011,1,2))
|
self.assertEqual(v.adate, date(2011,1,2))
|
||||||
|
|
||||||
|
@skip_if_no_composite
|
||||||
|
def test_empty_string(self):
|
||||||
|
# issue #141
|
||||||
|
self._create_type("type_ss", [('s1', 'text'), ('s2', 'text')])
|
||||||
|
curs = self.conn.cursor()
|
||||||
|
psycopg2.extras.register_composite("type_ss", curs)
|
||||||
|
|
||||||
|
def ok(t):
|
||||||
|
curs.execute("select %s::type_ss", (t,))
|
||||||
|
rv = curs.fetchone()[0]
|
||||||
|
self.assertEqual(t, rv)
|
||||||
|
|
||||||
|
ok(('a', 'b'))
|
||||||
|
ok(('a', ''))
|
||||||
|
ok(('', 'b'))
|
||||||
|
ok(('a', None))
|
||||||
|
ok((None, 'b'))
|
||||||
|
ok(('', ''))
|
||||||
|
ok((None, None))
|
||||||
|
|
||||||
@skip_if_no_composite
|
@skip_if_no_composite
|
||||||
def test_cast_nested(self):
|
def test_cast_nested(self):
|
||||||
self._create_type("type_is",
|
self._create_type("type_is",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user