diff --git a/IPython/parallel/controller/sqlitedb.py b/IPython/parallel/controller/sqlitedb.py index 8b5d724..7c3f159 100644 --- a/IPython/parallel/controller/sqlitedb.py +++ b/IPython/parallel/controller/sqlitedb.py @@ -293,7 +293,7 @@ class SQLiteDB(BaseDB): op, join = op if value is None and op in null_operators: - expr = "%s %s"%null_operators[op] + expr = "%s %s" % (name, null_operators[op]) else: expr = "%s %s ?"%(name, op) if isinstance(value, (tuple,list)): @@ -308,7 +308,7 @@ class SQLiteDB(BaseDB): else: # it's an equality check if sub_check is None: - expressions.append("%s IS NULL") + expressions.append("%s IS NULL" % name) else: expressions.append("%s = ?"%name) args.append(sub_check) diff --git a/IPython/parallel/tests/test_db.py b/IPython/parallel/tests/test_db.py index 3bdc1e9..66a4057 100644 --- a/IPython/parallel/tests/test_db.py +++ b/IPython/parallel/tests/test_db.py @@ -170,6 +170,18 @@ class TestDictBackend(TestCase): self.db.drop_matching_records(query) recs = self.db.find_records(query) self.assertEquals(len(recs), 0) + + def test_null(self): + """test None comparison queries""" + msg_ids = self.load_records(10) + + query = {'msg_id' : None} + recs = self.db.find_records(query) + self.assertEquals(len(recs), 0) + + query = {'msg_id' : {'$ne' : None}} + recs = self.db.find_records(query) + self.assertTrue(len(recs) >= 10) class TestSQLiteBackend(TestDictBackend):