val = cur.fetchone()[0]
self.assertEqual(val, 60)
+ def test_aggr_no_match(self):
+ cur = self.con.execute("select mysum(i) from (select 1 as i) where i == 0")
+ val = cur.fetchone()[0]
+ self.assertIsNone(val)
+
class AuthorizerTests(unittest.TestCase):
@staticmethod
def authorizer_cb(action, arg1, arg2, dbname, source):
threadstate = PyGILState_Ensure();
- aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
- if (!*aggregate_instance) {
+ aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, 0);
+ if (aggregate_instance == NULL) {
+ /* No rows matched the query; the step handler was never called. */
+ goto error;
+ }
+ else if (!*aggregate_instance) {
/* this branch is executed if there was an exception in the aggregate's
* __init__ */