Commit 789fdad0 authored by Tres Seaver's avatar Tres Seaver

Made 'and' operator for KeywordIndexes actually restrict results as expected.

Collector #889 -- thanks to 'aroda' for the patch!
parent c00414cf
...@@ -22,6 +22,12 @@ Zope Changes ...@@ -22,6 +22,12 @@ Zope Changes
- Collector #1233: port ZOPE_CONFIG patch from Zope 2.7 to Zope 2.8 - Collector #1233: port ZOPE_CONFIG patch from Zope 2.7 to Zope 2.8
After Zope 2.8.0 b2
Bugs Fixed
- Collector #889: made 'and' operator for KeywordIndexes actually
restrict results as expected (thanks to 'aroda' for the patch!).
Zope 2.8.0 b2 (2005/05/22) Zope 2.8.0 b2 (2005/05/22)
......
...@@ -221,6 +221,33 @@ class TestKeywordIndex( unittest.TestCase ): ...@@ -221,6 +221,33 @@ class TestKeywordIndex( unittest.TestCase ):
finally: finally:
self._ignore_log_errors() self._ignore_log_errors()
def testCollectorIssue889(self) :
# Test that collector issue 889 is solved
values = self._values
nonexistent = 'foo-bar-baz'
self._populateIndex()
# make sure key is not indexed
result = self._index._index.get(nonexistent, self._marker)
assert result is self._marker
# patched _apply_index now works as expected
record = {'foo' : { 'query' : [nonexistent]
, 'operator' : 'and'}
}
self._checkApply(record, [])
record = {'foo' : { 'query' : [nonexistent, 'a']
, 'operator' : 'and'}
}
# and does not break anything
self._checkApply(record, [])
record = {'foo' : { 'query' : ['d']
, 'operator' : 'and'}
}
self._checkApply(record, values[4:5])
record = {'foo' : { 'query' : ['a', 'e']
, 'operator' : 'and'}
}
self._checkApply(record, values[5:7])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestKeywordIndex ) ) suite.addTest( unittest.makeSuite( TestKeywordIndex ) )
......
...@@ -363,10 +363,11 @@ class UnIndex(SimpleItem): ...@@ -363,10 +363,11 @@ class UnIndex(SimpleItem):
else: # not a range search else: # not a range search
for key in record.keys: for key in record.keys:
set=index.get(key, None) set=index.get(key, None)
if set is not None: if set is None:
if isinstance(set, int): set = IISet(())
set = IISet((set,)) elif isinstance(set, int):
r = set_func(r, set) set = IISet((set,))
r = set_func(r, set)
if isinstance(r, int): r=IISet((r,)) if isinstance(r, int): r=IISet((r,))
if r is None: if r is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment