fix: remove duplicates from vobj.children

This commit is contained in:
relikd
2022-12-22 00:18:25 +01:00
parent b603fb9dd2
commit 1188216788
3 changed files with 6 additions and 5 deletions

View File

@@ -8,13 +8,14 @@ and this project does adhere to [Semantic Versioning](https://semver.org/spec/v2
## [Unreleased]
### Added
- Support `unique=False` in `vgroups` filter to return a list of all entries (including duplicates)
- `vgroups` filter now supports `unique=False` to return a list of all entries including duplicates (default: `True`)
### Fixed
- No duplicate `GroupBySource` entries in `vgroups` filter (while keeping sort order)
- Preserves original sort order in `vgroups` filter if `unique=True`
- Remove duplicates from `GroupBySource` children
### Changed
- Change default `recursive=True` for `vgroups` filter (most probable use case)
- `vgroups` filter uses `recursive=True` by default

View File

@@ -49,9 +49,9 @@ class VGroups:
*,
fields: Union[str, Iterable[str], None] = None,
flows: Union[str, Iterable[str], None] = None,
order_by: Union[str, Iterable[str], None] = None,
recursive: bool = True,
unique: bool = True,
order_by: Union[str, Iterable[str], None] = None,
) -> Iterator['GroupBySource']:
''' Extract all referencing groupby virtual objects from a page. '''
# prepare filter

View File

@@ -46,7 +46,7 @@ class GroupBySource(VirtualSourceObject):
self.page_num = page_num
def append_child(self, child: 'Record', key_obj: Any) -> None:
if child not in self.__children:
if child.path not in self.__children:
self.__children.append(child.path)
# __key_obj_map is later used to find most used key_obj
self.__key_obj_map.append(key_obj)