dabo Commit
Revision 4970
Date: 2009-01-25 16:18:48 -0800 (Sun, 25 Jan 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/4970
Changed:
U trunk/dabo/db/dDataSet.py
Log:
Added some code to handle null values in the filter() method. The sqlite dbapi
adapter doesn't seem to work well with None/null; this at least enables basic
querying on null status.
Diff:
Modified: trunk/dabo/db/dDataSet.py
===================================================================
--- trunk/dabo/db/dDataSet.py 2009-01-25 22:59:26 UTC (rev 4969)
+++ trunk/dabo/db/dDataSet.py 2009-01-26 00:18:48 UTC (rev 4970)
@@ -151,7 +151,7 @@
return self
op = op.strip().lower()
if op in ("=", "!=", ">", "<", ">=", "<="):
- clause = "%s ?" % op
+ clause = " %s ?" % op
else:
opDict = {"eq": " = ?",
"equals": " = ?",
@@ -177,8 +177,20 @@
param = "%%%s%%" % expr
else:
param = expr
- stmnt = "select * from dataset where %s %s" % (fld, clause)
- ret = self.execute(stmnt, (param, ))
+ # sqlite doesn't handle None parameter correctly, so fudge it
here
+ if param is None:
+ if clause == " = ?":
+ stmnt = "select * from dataset where %s is
null" % fld
+ elif clause == " != ?":
+ stmnt = "select * from dataset where %s is not
null" % fld
+ else:
+ # The only cases that make sense are equals or
not equals. For anything
+ # else, just return the original
+ return self
+ ret = self.execute(stmnt)
+ else:
+ stmnt = "select * from dataset where %s %s" % (fld,
clause)
+ ret = self.execute(stmnt, (param, ))
ret._sourceDataSet = self
return ret
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]