Closed g1itch closed 10 years ago
I think a solution may be like this
diff --git a/twistar/utils.py b/twistar/utils.py
index 91e7ee1..8b5c1f1 100644
--- a/twistar/utils.py
+++ b/twistar/utils.py
@@ -67,7 +67,8 @@ def dictToWhere(attrs, joiner="AND"):
if len(attrs) == 0:
return None
- wheres = map(lambda name: "(%s = ?)" % name, attrs.keys())
+ wheres = ["(%s = ?)" % key if val else "(%s IS ?)" % key
+ for key, val in attrs.iteritems()]
return [(" %s " % joiner).join(wheres)] + attrs.values()
Great catch! Thanks!
The statement should be
IS NULL
for None value, not= NULL
. As a resultBDObject.findBy()
returns[]
in that case. The following test succeeds if name is a string: