Adding some enhancements.
This commit is contained in:
parent
013d1c0bd5
commit
a8b07eb115
4 changed files with 24 additions and 9 deletions
|
|
@ -121,7 +121,7 @@ class CRUDSpec:
|
|||
"""
|
||||
raw = self.params.get('fields')
|
||||
if not raw:
|
||||
return [], {}
|
||||
return [], {}, {}
|
||||
|
||||
if isinstance(raw, list):
|
||||
tokens = []
|
||||
|
|
@ -131,6 +131,7 @@ class CRUDSpec:
|
|||
tokens = [p.strip() for p in str(raw).split(',') if p.strip()]
|
||||
|
||||
root_fields: List[InstrumentedAttribute] = []
|
||||
root_field_names: list[str] = []
|
||||
rel_field_names: Dict[Tuple[str, ...], List[str]] = {}
|
||||
|
||||
for token in tokens:
|
||||
|
|
@ -142,6 +143,7 @@ class CRUDSpec:
|
|||
self.eager_paths.add(join_path)
|
||||
else:
|
||||
root_fields.append(col)
|
||||
root_field_names.append(getattr(col, "key", token))
|
||||
|
||||
seen = set()
|
||||
root_fields = [c for c in root_fields if not (c.key in seen or seen.add(c.key))]
|
||||
|
|
@ -151,7 +153,7 @@ class CRUDSpec:
|
|||
|
||||
self._root_fields = root_fields
|
||||
self._rel_field_names = rel_field_names
|
||||
return root_fields, rel_field_names
|
||||
return root_fields, rel_field_names, root_field_names
|
||||
|
||||
def get_eager_loads(self, root_alias, *, fields_map=None):
|
||||
loads = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue