Commit d04d18d9 authored by Toby Dickenson's avatar Toby Dickenson

merged toby-catalog-delete-property-branch: Collector 291: deleting and indexed property

parent eb7fa5ef
......@@ -104,6 +104,8 @@ Zope Changes
- Fixed a bug in TM.py that would cause database adapters to hang
on errors in the second phase of the two-phase commit.
- Collector #291: ZCatalog not unindexing deleted properties
Zope 2.5.1 beta 1
Bugs Fixed
......
......@@ -148,6 +148,29 @@ class TestCase( unittest.TestCase ):
self._checkApply(self._none_req, values[-1:])
assert None in self._index.uniqueValues('foo')
def testReindex( self ):
self._populateIndex()
result, used = self._index._apply_index( {'foo':'abc'} )
assert list(result)==[2]
assert self._index.keyForDocument(2)=='abc'
d = Dummy('world')
self._index.index_object(2,d)
result, used = self._index._apply_index( {'foo':'world'} )
assert list(result)==[2]
assert self._index.keyForDocument(2)=='world'
del d._foo
self._index.index_object(2,d)
result, used = self._index._apply_index( {'foo':'world'} )
assert list(result)==[]
try:
should_not_be = self._index.keyForDocument(2)
except KeyError:
# As expected, we deleted that attribute.
pass
else:
# before Collector #291 this would be 'world'
raise ValueError(repr(should_not_be))
def testRange(self):
"""Test a range search"""
index = FieldIndex( 'foo' )
......@@ -183,3 +206,9 @@ class TestCase( unittest.TestCase ):
def test_suite():
return unittest.makeSuite( TestCase )
def main():
unittest.TextTestRunner().run(test_suite())
if __name__ == '__main__':
main()
......@@ -13,7 +13,7 @@
"""Simple column indices"""
__version__='$Revision: 1.8 $'[11:-2]
__version__='$Revision: 1.9 $'[11:-2]
from Globals import Persistent
from Acquisition import Implicit
......@@ -224,6 +224,13 @@ class UnIndex(Persistent, Implicit):
if datum != oldDatum:
if oldDatum is not _marker:
self.removeForwardIndexEntry(oldDatum, documentId)
if datum is _marker:
try:
del self._unindex[documentId]
except:
LOG('UnIndex', ERROR,
'Should not happen: oldDatum was there, now its not,'
'for document with id %s' % documentId)
if datum is not _marker:
self.insertForwardIndexEntry(datum, documentId)
......
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