Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document._class_id is always overwritten #1132

Open
volfpeter opened this issue Feb 24, 2025 · 0 comments · May be fixed by #1133
Open

Document._class_id is always overwritten #1132

volfpeter opened this issue Feb 24, 2025 · 0 comments · May be fixed by #1133

Comments

@volfpeter
Copy link

volfpeter commented 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", 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.

volfpeter added a commit to volfpeter/beanie that referenced this issue Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant