Describe the bug
When using a field named title in a Beanie document and referencing it through a Link in another document, querying the linked document's title field throws an AttributeError. The error occurs because Beanie appears to be conflicting with Python's built-in str.title() method, returning <built-in method title of ExpressionField object at 0x7e1098dd23d0> instead of the field value. According to the source code, in Link objects, title refers to its collection name, which creates a naming conflict when trying to access a document field also named title.
To Reproduce
from beanie import Document, Link
from typing import Optional
class Subject(Document):
title: str
class Chapter(Document):
title: str
subject: Link[Subject]
# This query fails with AttributeError
data = await Chapter.find(Chapter.subject.title == 'sub1')
# Error: AttributeError: 'builtin_function_or_method' object has no attribute 'split'
# The error suggests that Chapter.subject.title is returning the built-in str.title() method
# instead of the actual field reference
Describe the bug
When using a field named
titlein a Beanie document and referencing it through aLinkin another document, querying the linked document'stitlefield throws an AttributeError. The error occurs because Beanie appears to be conflicting with Python's built-instr.title()method, returning<built-in method title of ExpressionField object at 0x7e1098dd23d0>instead of the field value. According to the source code, in Link objects,titlerefers to its collection name, which creates a naming conflict when trying to access a document field also namedtitle.To Reproduce