[Checkins] SVN: hurry.query/trunk/ fix a bug where the NotEq query failed when all items in the index satisfy the NotEq condition.
Paul Carduner
paulcarduner at gmail.com
Mon Sep 29 13:15:45 EDT 2008
Log message for revision 91614:
fix a bug where the NotEq query failed when all items in the index satisfy the NotEq condition.
Changed:
U hurry.query/trunk/CHANGES.txt
U hurry.query/trunk/src/hurry/query/query.txt
U hurry.query/trunk/src/hurry/query/value.py
-=-
Modified: hurry.query/trunk/CHANGES.txt
===================================================================
--- hurry.query/trunk/CHANGES.txt 2008-09-29 17:11:34 UTC (rev 91613)
+++ hurry.query/trunk/CHANGES.txt 2008-09-29 17:15:45 UTC (rev 91614)
@@ -1,6 +1,12 @@
hurry.query changes
===================
+0.9.3 (unreleased)
+------------------
+
+* BUG: NotEq query no longer fails when all values in the index
+ satisfy the NotEq condition.
+
0.9.2 (2006-09-22)
------------------
Modified: hurry.query/trunk/src/hurry/query/query.txt
===================================================================
--- hurry.query/trunk/src/hurry/query/query.txt 2008-09-29 17:11:34 UTC (rev 91613)
+++ hurry.query/trunk/src/hurry/query/query.txt 2008-09-29 17:15:45 UTC (rev 91614)
@@ -319,6 +319,12 @@
>>> displayQuery(value.NotEq(f1, 'a'))
[2, 3, 4, 5]
+If all the items in the catalog satisfy the NotEq condition, the query
+does not crash.
+
+ >>> displayQuery(value.NotEq(f1, 'z'))
+ [1, 2, 3, 4, 5, 6]
+
You can also query for all objects where the value of ``f1`` is in a set of
values:
Modified: hurry.query/trunk/src/hurry/query/value.py
===================================================================
--- hurry.query/trunk/src/hurry/query/value.py 2008-09-29 17:11:34 UTC (rev 91613)
+++ hurry.query/trunk/src/hurry/query/value.py 2008-09-29 17:15:45 UTC (rev 91614)
@@ -38,7 +38,14 @@
def apply(self):
index = self.getIndex()
values = list(index.values())
- values.remove(self.not_value)
+ # the remove method produces a value error when the value to
+ # be removed is not in the list in the first place. Having a
+ # try/except clause is more efficent than first searching the
+ # list for the value to remove.
+ try:
+ values.remove(self.not_value)
+ except ValueError:
+ pass
return index.apply({'any_of': values})
class Between(ValueTerm):
More information about the Checkins
mailing list