-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Related to #181.
After introducing changes from #181 to properly mock MockSet.query, the following breaks because utils.get_attribute doesn't currently handle Subquery expressions.
ms = MockSet()
ms.annotate(
my_field=Subquery(ms.filter(value=OuterRef("value")))
)
# Raises AttributeError: Mock object has no attribute 'split'I've been playing around the codebase, trying to see if I could fit this in, but hit a wall. In contrast to all other cases (F, Case, Value and Coalesce), a Subquery cannot be immediately resolved so I'm not too sure how the logic should go.
def get_attribute(obj, attr, default=None):
# ...
elif isinstance(attr, Subquery):
expr = attr.get_source_expressions()[0] # <--- This returns a Query mock
return get_attribute(obj, expr)
parts = attr.split('__') # <--- This is what raises the exception if Subquery is unhandledHappy to help and contribute if you point me in the right direction.
Metadata
Metadata
Assignees
Labels
No labels