10

Add disable_joins option to has_one relation by cheshire137 · Pull Request #4207...

 2 years ago
source link: https://github.com/rails/rails/pull/42079
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

cheshire137 commented on Apr 26

Summary

This adds disable_joins as an option for has_one ... through: relations, like what #41937 did for has_many ... through:. The goal is to be able to define has_one relationships whose tables are in separate database clusters in a multi-database Rails app. Joins need to be avoided in this case because you can't join across clusters.

Other Information

I've got some failing tests when I run has_one_through_disable_joins_associations_test.rb locally, and I'm not sure if the failures are due to an implementation problem I need to fix or if the test is wrong. thinking My approach for adding tests was to copy tests from activerecord/test/cases/associations/has_one_through_associations_test.rb and duplicate any existing has_one ... through: relations to add a *_without_joins version using disable_joins: true.

cc @eileencodes who encouraged me and was so helpful adding initial disable_joins support bowing_woman


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK