-
Notifications
You must be signed in to change notification settings - Fork 239
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
fix: hierarchy model with namespace should inherit from the superclass of basic model #384
fix: hierarchy model with namespace should inherit from the superclass of basic model #384
Conversation
…::ApplicationRecord
While this code works, the implementation is not correct. We need to inherit just the connection. This PR take in consideration that everyone will use ApplicationRecord inside a namespace. What if i have 1 model inheriting from PostgresqlRecord and Another From MysqlRecord for example ? What we need to do is to inherit still from Base, use the connection of the model with the tree. |
@seuros I have made some changes for inheriting the connection. PTAL. Thank you.
I think if our goal is to use the connection of the model with the tree, maybe we need to reproduce the logic of rails to make the models inherit from the same superclass use the same one database connection. Shall we use |
I was thinking at that solution at first. We should update the README to state that the hierarchy is going to inherit the connection from the model. If a Dev has some custom setup that need special setting, there is always the ability to create the Hierarchy model manually and assign it. |
Let use your fix for now. We can inherit the connection once we drop support for old AR version. Good job |
Thank you! |
It would be nice if the class being used was configurable (rather than |
@mbandrewfoster can you explain your use case ? |
Same problem here. See my issue regarding this: #395 |
#382
FYI: In my case, I have a namespace AAA for billing, and billing model inherits from AAA::ApplicationRecord.
Like the following code:
Therefore if I follow the unmodified code to execute, AAA::BillingHierarchy will inherit from ApplicationRecord, not AAA::ApplicationRecord, then it will connect to primary database, not aaa database.
PTAL.Thank you.