Various Config and Mongo Driver fixes (#2795)

- Fixes defaults being mixed into custom groups above the document level when doing `Group.all()`
- Fixes `Config.clear_all()` with Mongo driver
- Fixes `Group.set()` with Mongo driver on custom groups above the document level
- Fixes `IdentifierData.custom_group_data` being set to the wrong thing in `BaseDriver.import/export_data` (although this was an inconsequential bug)

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
Toby Harradine
2019-06-24 12:55:49 +10:00
committed by GitHub
parent 6ae3040aac
commit 71d0bd0d07
4 changed files with 160 additions and 39 deletions

View File

@@ -18,8 +18,8 @@ class IdentifierData:
self,
uuid: str,
category: str,
primary_key: Tuple[str],
identifiers: Tuple[str],
primary_key: Tuple[str, ...],
identifiers: Tuple[str, ...],
custom_group_data: dict,
is_custom: bool = False,
):
@@ -183,7 +183,7 @@ class BaseDriver:
c,
(),
(),
custom_group_data.get(c, {}),
custom_group_data,
is_custom=c in custom_group_data,
)
try:
@@ -202,7 +202,19 @@ class BaseDriver:
category,
pkey,
(),
custom_group_data.get(category, {}),
custom_group_data,
is_custom=category in custom_group_data,
)
await self.set(ident_data, data)
@staticmethod
def get_pkey_len(identifier_data: IdentifierData) -> int:
cat = identifier_data.category
if cat == ConfigCategory.GLOBAL.value:
return 0
elif cat == ConfigCategory.MEMBER.value:
return 2
elif identifier_data.is_custom:
return identifier_data.custom_group_data[cat]
else:
return 1