Skip to content

Commit

Permalink
refactor PluginIndexes.unindex.UnIndex.query_index fixing #55 and #56
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Mar 8, 2019
1 parent c72323f commit c8580d1
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 247 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
4.4 (unreleased)
----------------

- Refactor ``Products.PluginIndexes.unindex.Unindex.query_index``
(`#56 <https://github.com/zopefoundation/Products.ZCatalog/issues/56>`_)
and fix
(`#55 <https://github.com/zopefoundation/Products.ZCatalog/issues/55>`_).

- Specify supported Python versions using ``python_requires`` in setup.py
(`Zope#481 <https://github.com/zopefoundation/Zope/issues/481>`_)

Expand Down
1 change: 1 addition & 0 deletions src/Products/PluginIndexes/FieldIndex/FieldIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FieldIndex(UnIndex):
"""
meta_type = 'FieldIndex'
query_options = ('query', 'range', 'not')
potentially_multivalued = False # optimization for exclude terms

manage_options = (
{'label': 'Settings', 'action': 'manage_main'},
Expand Down
15 changes: 14 additions & 1 deletion src/Products/PluginIndexes/tests/test_unindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import unittest

from BTrees.IIBTree import difference
from BTrees.IIBTree import difference, IISet
from OFS.SimpleItem import SimpleItem
from Testing.makerequest import makerequest

Expand Down Expand Up @@ -193,3 +193,16 @@ class Dummy(object):
query = IndexQuery({'counter': 42}, 'counter')
res = index.query_index(query)
self.assertListEqual(list(res), [])

def test_resultset_intersection(self):
"""see #55
`https://github.com/zopefoundation/Products.ZCatalog/issues/55`.
"""
index = self._makeOne("rsi")
for i in (1, 2):
index.insertForwardIndexEntry(i, i)
ers = IISet() # empty result set
for q in ((1,), (1, 2)):
qd = dict(rsi=dict(query=q))
self.assertEqual(q, tuple(index._apply_index(qd)[0]))
self.assertEqual((), tuple(index._apply_index(qd, ers)[0]))
Loading

0 comments on commit c8580d1

Please sign in to comment.