[BUG] Link not working in find queries on fields with alias
Closed this issue · 4 comments
rexa222 commented
Explanation
Imagine an alias is set for a Link field (which it's value will be DBRef), when a find filter is used on the id of that DBRef to get a record, it does not work. However, if the field name in Document class is directly set to the previous class alias, it works perfectly.
Documents Example
class LinkDoc(Document):
foo: str = 'foo'
class Doc(Document):
field: Link[LinkDoc] = Field(alias='alias')
class DirectDoc(Document):
alias: Link[LinkDoc]
Example Record in DB
_id: 6666cfcd915ab3ed5ff6155a
alias: DBRef('LinkDoc', '6666a7eca6fa9e0ac7a286b4')
Occurred Behavior
>>> await Doc.find_one(Doc.field == ObjectId('6666a7eca6fa9e0ac7a286b4')
None
>>> await DirectDoc.find_one(Doc.field == ObjectId('6666a7eca6fa9e0ac7a286b4'))
DirectDoc(id=ObjectId('6666cfcd915ab3ed5ff6155a'), revision_id=None, field=<beanie.odm.fields.Link object at 0x000002A731C38FD0>)
github-actions commented
This issue is stale because it has been open 30 days with no activity.
alexkrytsky commented
I'm hitting the same issue. @rexa222 , were you able to resolve it?
Is there a PR to address the issue?
github-actions commented
This issue is stale because it has been open 30 days with no activity.
github-actions commented
This issue was closed because it has been stalled for 14 days with no activity.