Fixed bug 688290 "NULL values with converters error on fetch."

master
baztian 2010-12-12 20:35:07 +01:00
parent 32c64c47c7
commit 83fede1f8d
4 changed files with 12 additions and 10 deletions

View File

@ -266,6 +266,7 @@ class Cursor(object):
for col in range(1, self._meta.getColumnCount() + 1): for col in range(1, self._meta.getColumnCount() + 1):
sqltype = self._meta.getColumnType(col) sqltype = self._meta.getColumnType(col)
v = self._rs.getObject(col) v = self._rs.getObject(col)
if v:
converter = _converters.get(sqltype) converter = _converters.get(sqltype)
if converter: if converter:
v = converter(v) v = converter(v)

View File

@ -2,6 +2,7 @@ create table konto (
"KONTO_ID" TIMESTAMP default CURRENT_TIMESTAMP not null, "KONTO_ID" TIMESTAMP default CURRENT_TIMESTAMP not null,
"KONTO_NR" INTEGER not null, "KONTO_NR" INTEGER not null,
"SALDO" DECIMAL default 0.0 not null, "SALDO" DECIMAL default 0.0 not null,
"SPERRE" DECIMAL,
primary key ("KONTO_ID") primary key ("KONTO_ID")
); );

View File

@ -1,2 +1,2 @@
insert into Konto values ('2009-09-10 14:15:22.123456', 18, 12.4); insert into Konto values ('2009-09-10 14:15:22.123456', 18, 12.4, null);
insert into Konto values ('2009-09-11 14:15:22.123456', 19, 12.9); insert into Konto values ('2009-09-11 14:15:22.123456', 19, 12.9, 1);

View File

@ -93,20 +93,20 @@ class IntegrationTest(TestCase):
cursor = self.conn.cursor() cursor = self.conn.cursor()
cursor.execute("select * from konto") cursor.execute("select * from konto")
result = cursor.fetchall() result = cursor.fetchall()
assert [(u'2009-09-10 14:15:22.123456', 18, 12.4), assert [(u'2009-09-10 14:15:22.123456', 18, 12.4, None),
(u'2009-09-11 14:15:22.123456', 19, 12.9)] == result (u'2009-09-11 14:15:22.123456', 19, 12.9, 1)] == result
def test_execute_and_fetch_parameter(self): def test_execute_and_fetch_parameter(self):
cursor = self.conn.cursor() cursor = self.conn.cursor()
cursor.execute("select * from konto where konto_nr = ?", 18) cursor.execute("select * from konto where konto_nr = ?", 18)
result = cursor.fetchall() result = cursor.fetchall()
assert [(u'2009-09-10 14:15:22.123456', 18, 12.4)] == result assert [(u'2009-09-10 14:15:22.123456', 18, 12.4, None)] == result
def test_execute_and_fetchone(self): def test_execute_and_fetchone(self):
cursor = self.conn.cursor() cursor = self.conn.cursor()
cursor.execute("select * from konto order by konto_nr") cursor.execute("select * from konto order by konto_nr")
result = cursor.fetchone() result = cursor.fetchone()
assert (u'2009-09-10 14:15:22.123456', 18, 12.4) == result assert (u'2009-09-10 14:15:22.123456', 18, 12.4, None) == result
def test_execute_reset_description_without_execute_result(self): def test_execute_reset_description_without_execute_result(self):
"""Excpect the descriptions property being reset when no query """Excpect the descriptions property being reset when no query
@ -130,7 +130,7 @@ class IntegrationTest(TestCase):
cursor = self.conn.cursor() cursor = self.conn.cursor()
cursor.execute("select * from konto order by konto_nr") cursor.execute("select * from konto order by konto_nr")
result = cursor.fetchmany() result = cursor.fetchmany()
assert [(u'2009-09-10 14:15:22.123456', 18, 12.4)] == result assert [(u'2009-09-10 14:15:22.123456', 18, 12.4, None)] == result
def test_executemany(self): def test_executemany(self):
cursor = self.conn.cursor() cursor = self.conn.cursor()