Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Finding Orphan Records #34727
As discussed here, I would like to introduce a way for simplifying the search for orphan records within ActiveRecord.
Currently you would do something like this:
I would like to introduce an API like this:
I've gotten started, but could use some feedback and direction from someone more experienced with the innards of ActiveRecord. I've modeled the
1. Adding the left join
In order to add the join to the current scope, I am just calling the
2. References in the where clause
I copied the
I have a version of your code with the tests passing on this branch https://github.com/rafaelfranca/omg-rails/tree/add_missing_to_where_chain.
How do these tests look?
I like that I am not testing the implementation, but not sure how we feel about relying on existing fixtures. For clarity, I started each test with an assertion of the fixture setup, but maybe that isn't necessary? I would hate for fixtures to change in the future and break the test or make the test meaningless.
Relying on existing fixtures is perfectly fine. I probably wouldn't have tested the relationships as the tests would've broken anyway, but just fine for these two cases