[Checkins] SVN: Products.ZCatalog/trunk/ Fixed bug in date range index, which would omit objects exactly matching the query term if a resultset was provided.
Hanno Schlichting
hannosch at hannosch.eu
Fri Apr 1 07:02:40 EDT 2011
Log message for revision 121191:
Fixed bug in date range index, which would omit objects exactly matching the query term if a resultset was provided.
Changed:
U Products.ZCatalog/trunk/CHANGES.txt
U Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
U Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt 2011-04-01 10:32:10 UTC (rev 121190)
+++ Products.ZCatalog/trunk/CHANGES.txt 2011-04-01 11:02:40 UTC (rev 121191)
@@ -4,6 +4,9 @@
2.13.8 (unreleased)
-------------------
+- Fixed bug in date range index, which would omit objects exactly matching the
+ query term if a resultset was provided.
+
- Fixed the BooleanIndex to not index objects without the cataloged attribute.
2.13.7 (2011-02-15)
Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py 2011-04-01 10:32:10 UTC (rev 121190)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py 2011-04-01 11:02:40 UTC (rev 121191)
@@ -309,10 +309,10 @@
return (result, (self._since_field, self._until_field))
else:
# Compute the inverse and subtract from res
- until_only = multiunion(self._until_only.values(None, term))
- since_only = multiunion(self._since_only.values(term))
- until = multiunion(self._until.values(None, term))
- since = multiunion(self._since.values(term))
+ until_only = multiunion(self._until_only.values(None, term - 1))
+ since_only = multiunion(self._since_only.values(term + 1))
+ until = multiunion(self._until.values(None, term - 1))
+ since = multiunion(self._since.values(term + 1))
result = multiunion([until_only, since_only, until, since])
if REQUEST is not None and catalog is not None:
Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py 2011-04-01 10:32:10 UTC (rev 121190)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py 2011-04-01 11:02:40 UTC (rev 121191)
@@ -214,11 +214,20 @@
results, used = index._apply_index({'work': 11})
self.assertEqual(set(results), set([0, 1, 2, 3, 5, 6]))
+ # also for _since_only
+ results, used = index._apply_index({'work': 10})
+ self.assertEqual(set(results), set([0, 1, 2, 3, 5, 6]))
+
# the specified value is included with a large resultset
results, used = index._apply_index({'work': 11},
resultset=IISet(range(len(dummies))))
self.assertEqual(set(results), set([0, 1, 2, 3, 5, 6]))
+ # this also works for _since_only
+ results, used = index._apply_index({'work': 10},
+ resultset=IISet(range(len(dummies))))
+ self.assertEqual(set(results), set([0, 1, 2, 3, 5, 6]))
+
# the specified value is included with a small resultset
results, used = index._apply_index({'work': 11},
resultset=IISet([0, 5, 7]))
More information about the checkins
mailing list