You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document._class_id is overwritten. Document initialization should check if it's set before assigning a value. This messes up the customization of document discriminators and leads to failing queries (update, find, link fetching...).
To Reproduce
Create a couple of documents (with inheritance pattern), set Settings.class_id for example to "type", add type: str = "my-doc-type-1", type: str = "my-doc-type-2", ... properties to documents and also set _class_id on each document to the same value as the type property.
Expected behavior
Update, find, link fetching queries work.
Additional context
I'll submit a PR with a fix that avoids overwriting _class_id if it's already set. It solves the issues.
The text was updated successfully, but these errors were encountered:
volfpeter
added a commit
to volfpeter/beanie
that referenced
this issue
Feb 24, 2025
Describe the bug
Document._class_id
is overwritten. Document initialization should check if it's set before assigning a value. This messes up the customization of document discriminators and leads to failing queries (update, find, link fetching...).To Reproduce
Create a couple of documents (with inheritance pattern), set
Settings.class_id
for example to"type"
, addtype: str = "my-doc-type-1"
,type: str = "my-doc-type-2"
, ... properties to documents and also set_class_id
on each document to the same value as thetype
property.Expected behavior
Update, find, link fetching queries work.
Additional context
I'll submit a PR with a fix that avoids overwriting
_class_id
if it's already set. It solves the issues.The text was updated successfully, but these errors were encountered: