beanie icon indicating copy to clipboard operation
beanie copied to clipboard

[BUG] Multilevel related document lookups don't work

Open thorin-schiffer opened this issue 1 year ago • 2 comments

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

thorin-schiffer avatar Feb 21 '24 10:02 thorin-schiffer

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 avatar Feb 26 '24 22:02 roman-right

@roman-right , is there any update on this since February? For the workaround, should the aggregation be used?

alexkrytsky avatar Jul 24 '24 17:07 alexkrytsky