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

IndexMeta removal prevents index class reuse #1190

Open
giovannibelzoni opened this issue Jul 13, 2023 · 1 comment
Open

IndexMeta removal prevents index class reuse #1190

giovannibelzoni opened this issue Jul 13, 2023 · 1 comment

Comments

@giovannibelzoni
Copy link

#998

This PR has made index class reuse impossible, due in part by the __set_name__ method on the index class setting the first model it's used on.

Prior to this change, it was possible to define an index class and use it on multiple models. Now we see:

In [2]: ModelA._indexes['MyIndex'].Meta.model
Out[2]: app.models.ModelA

In [3]: ModelB._indexes['MyIndex'].Meta.model
Out[3]: app.models.ModelA

I suspect this is the problem for this reported bug:
#1026

@ikonst
Copy link
Contributor

ikonst commented Jul 13, 2023

We could allow reuse since an index should only be useable as an instance on a model, i.e. MyIndex.query(...) should no longer be possible in the current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants