Index: src/com/ziclix/python/sql/DataHandler.java =================================================================== --- src/com/ziclix/python/sql/DataHandler.java (revision 7288) +++ src/com/ziclix/python/sql/DataHandler.java (working copy) @@ -293,8 +293,7 @@ break; case Types.NULL: - obj = Py.None; - break; + return Py.None; // NB *NOT* obj = Py.None; break. We've bypassed set.getXxxx(), so we haven't met the pre-condition for calling set.wasNull() as happens after this switch block. case Types.OTHER: case Types.JAVA_OBJECT: @@ -409,8 +408,7 @@ break; case Types.NULL: - obj = Py.None; - break; + return Py.None; // NB *NOT* obj = Py.None; break. We've bypassed set.getXxxx(), so we haven't met the pre-condition for calling set.wasNull() as happens after this switch block. case Types.OTHER: obj = Py.java2py(stmt.getObject(col)); Index: Lib/test/zxjdbc/zxtest.py =================================================================== --- Lib/test/zxjdbc/zxtest.py (revision 7288) +++ Lib/test/zxjdbc/zxtest.py (working copy) @@ -109,6 +109,20 @@ finally: c.close() + def testNullReturnQuery(self): + """testing that a resultset containing just a NULL value doesn't break.""" + c = self.cursor() + try: + c.execute("insert into zxtesting (id, name, state) values (100, NULL, 'xx')") + self.db.commit() + c.execute("select name from zxtesting where id = 100"); + f = c.fetchall() + assert len(f) == 1, "expecting one row" + data = f[0] + assert data[0] is None, "expecting None/NULL returned, was %r" % (data,) + finally: + c.close() + def _test_preparedstatement(self, dynamic): c = self.cursor(dynamic) try: