beanie
beanie copied to clipboard
[BUG] Multilevel related document lookups don't work
Describe the bug If document referencing goes further than one level, find won't resolve it properly
To Reproduce
class Organization(Document):
slug: str
class Domain(Document):
organization: Link[Organization]
integration: str
class Attribute(Document):
domain: Link[Domain]
class AttributeMapping(Document):
source: Link[Attribute]
target: Link[Attribute]
# won't work
await AttributeMapping.find(
AttributeMapping.source.domain.integration == domain.integration,
AttributeMapping.source.domain.organization.slug == organization.slug,
fetch_links=True,
).count()
# won't work
await AttributeMapping.find(
AttributeMapping.source.domain.id == domain.id,
fetch_links=True, # regardless
).count()
Expected behavior Linked documents are found
Hi! I'll check what is going on there and will let you know here if this is possible to fix or not. Thank you
@roman-right , is there any update on this since February? For the workaround, should the aggregation be used?