comparison roundup/hyperdb.py @ 6413:7b1b6dffc7ed

Fix searching+sorting for Link properties Note that this turns off recursive pre-populating the cache in filter_iter, we only pre-populate the top-level element. Otherwise this interacts with searching producing duplicates.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 17 May 2021 20:52:27 +0200
parents a0c0ee3ed8b1
children 8e06194ff0b0
comparison
equal deleted inserted replaced
6412:a0c0ee3ed8b1 6413:7b1b6dffc7ed
517 propclass for the child. 517 propclass for the child.
518 """ 518 """
519 if name in self.propdict: 519 if name in self.propdict:
520 pt = self.propdict[name] 520 pt = self.propdict[name]
521 pt.need_for[need_for] = True 521 pt.need_for[need_for] = True
522 if retr and isinstance(pt.propclass, Link): 522 # For now we do not recursively retrieve Link properties
523 pt.append_retr_props() 523 #if retr and isinstance(pt.propclass, Link):
524 # pt.append_retr_props()
524 return pt 525 return pt
525 propclass = self.props[name] 526 propclass = self.props[name]
526 cls = None 527 cls = None
527 props = None 528 props = None
528 if isinstance(propclass, (Link, Multilink)): 529 if isinstance(propclass, (Link, Multilink)):
536 child.need_retired = True 537 child.need_retired = True
537 else: 538 else:
538 child.need_child_retired = True 539 child.need_child_retired = True
539 self.children.append(child) 540 self.children.append(child)
540 self.propdict[name] = child 541 self.propdict[name] = child
541 if retr and isinstance(child.propclass, Link): 542 # For now we do not recursively retrieve Link properties
542 child.append_retr_props() 543 #if retr and isinstance(child.propclass, Link):
544 # child.append_retr_props()
543 return child 545 return child
544 546
545 def append_retr_props(self): 547 def append_retr_props(self):
546 """Append properties for retrieval.""" 548 """Append properties for retrieval."""
547 for name, prop in self.cls.getprops(protected=1).items(): 549 for name, prop in self.cls.getprops(protected=1).items():
1564 def _proptree(self, filterspec, exact_match_spec={}, sortattr=[], 1566 def _proptree(self, filterspec, exact_match_spec={}, sortattr=[],
1565 retr=False): 1567 retr=False):
1566 """Build a tree of all transitive properties in the given 1568 """Build a tree of all transitive properties in the given
1567 exact_match_spec/filterspec. 1569 exact_match_spec/filterspec.
1568 If we retrieve (retr is True) linked items we don't follow 1570 If we retrieve (retr is True) linked items we don't follow
1569 across multilinks. We also don't follow if the searched value 1571 across multilinks or links.
1570 can contain NULL values.
1571 """ 1572 """
1572 proptree = Proptree(self.db, self, '', self.getprops(), retr=retr) 1573 proptree = Proptree(self.db, self, '', self.getprops(), retr=retr)
1573 for exact, spec in enumerate((filterspec, exact_match_spec)): 1574 for exact, spec in enumerate((filterspec, exact_match_spec)):
1574 for key, v in spec.items(): 1575 for key, v in spec.items():
1575 keys = key.split('.') 1576 keys = key.split('.')

Roundup Issue Tracker: http://roundup-tracker.org/