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

Addressing #838, STI issues when code is reloaded in development, fix… #1064

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vanboom
Copy link

@vanboom vanboom commented Nov 10, 2023

The class level map using @@__types messes up the autoloading when STI classes are present. The Registry.all.detect lookup should be very fast so this seems to be a good trade off to fix the old STI auto load issue that was reported in #838 and closed by the stalebot.

Related PR #888 was also closed with a statement that STI support is deprecated and removed from the gem. It is my opinion that this PR and #888 is a fix related to Rails autoloading and has nothing to do with STI support.

Please consider this PR to close #848 for good. Thanks!

…nt, fix index name to klass lookup methodology
Copy link

cla-checker-service bot commented Nov 10, 2023

💚 CLA has been signed


key = "#{hit[:_index]}::#{hit[:_type]}" if hit[:_type] && hit[:_type] != '_doc'
key = hit[:_index] unless key

@@__types[key] ||= begin
Copy link
Author

@vanboom vanboom Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put Benchmark.measure around this code and contrary to my expectations, the original hash method was WAY. We will have to re-think this change, maybe the method of storing the class->index_name mapping can be improved to mitigate #838 with performance.
image

NOTE: my models use a Proc for index_name in a multi-tenant application so we are attempting to use an apartment qualified index name. Seems the Proc based index_name is causing the performance hit.

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

Successfully merging this pull request may close these issues.

Invalid single-table inheritance type: SubClass is not a subclass of Class
2 participants