Closed waza-ari closed 1 month ago
Nice catch, thanks! Will be fixed
This one is a bit more subtle than the other one related to _nest_join_data
, so I'll make sure to fix it myself
def _nest_join_data(
data: dict[str, Any], join_definitions: list[JoinConfig]
) -> dict[str, Any]:
nested_data: dict = {}
for key, value in data.items():
nested = False
for join in join_definitions:
if join.join_prefix and key.startswith(join.join_prefix):
nested_key = join.join_prefix.rstrip("_")
nested_field = key[len(join.join_prefix) :]
if nested_key not in nested_data:
nested_data[nested_key] = {}
nested_data[nested_key][nested_field] = value
nested = True
break
if not nested:
nested_data[key] = value
return nested_data
Describe the bug or question Consider the following models:
When running a nested join query like this:
The returned values are:
Note how the nested set contains the
id
twice, once asid
and once asid_1
and note that the original field ofHero
calledability_id
is missing, which is failing when returning the data as the Pydantic model will complain about a missing field.When setting the
join_prefix
to something stupid, the attribute is in place correctly but obviously that also changes the name of the nested dict: