[Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2019-04-10 Thread Tom Rossi
Any help with this (my first) PR is appreciated! On Tuesday, April 9, 2019 at 4:32:31 PM UTC-4, Filipe W. Lima wrote: > > Tom's PR can be found at https://github.com/rails/rails/pull/34727. > > On Tuesday, November 27, 2018 at 7:41:53 PM UTC-3, Tom Rossi wrote: >> >> Its common for me to look for

[Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2019-04-09 Thread Filipe W. Lima
Tom's PR can be found at https://github.com/rails/rails/pull/34727. On Tuesday, November 27, 2018 at 7:41:53 PM UTC-3, Tom Rossi wrote: > > Its common for me to look for orphans and I typically do it like this: > > Child.eager_load(:parent).where(parents: { id: nil }) > > I would like to propose

[Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2018-12-13 Thread Deepak Mahakale
This sounds interesting. On Wednesday, 28 November 2018 04:11:53 UTC+5:30, Tom Rossi wrote: > > Its common for me to look for orphans and I typically do it like this: > > Child.eager_load(:parent).where(parents: { id: nil }) > > I would like to propose putting together a PR for something like

Re: [Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2018-12-13 Thread Kasper Timm Hansen
Once you’re getting down to specific code choices, it’s better in a PR. So feel free to submit one  You also don’t have to get everything right up front as long as you help guide reviewers. For instance, it's fine to submit a piecemeal PR, just describe what you intend to defer for your

Re: [Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2018-12-13 Thread Tom Rossi
I'd like to give this a shot! I am thinking this will be added to the activerecord/lib/active_record/relation/query_methods.rb to the WhereChain class. The missing method will accept an individual or array of relationships. The resulting scope will have a left join on each relationship as well as

[Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2018-12-12 Thread DHH
I even like Person.where.missing(:parent). The key distinguisher is to use modifiers on #where, just like we have with #not, rather than hang these off the root scope. On Tuesday, December 11, 2018 at 3:38:36 PM UTC-8, Joshua Stowers wrote: > > This reminds me of another recent topic: >

[Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2018-12-10 Thread Nathaniel Suchy
That functionality sounds really useful. The code you showed you use above to find orphans seems a bit more complex than an easy to use ActiveRecord method. I look forward to seeing what other people say about this idea :) On Tuesday, November 27, 2018 at 5:41:53 PM UTC-5, Tom Rossi wrote: > >

[Rails-core] Re: [Feature][ActiveRecord] Finding Orphans

2018-12-10 Thread John Pollard
I definitely find myself looking for orphans to clean up my database. What about adding a method scope as "missing_#{relationship_name}" Book.missing_author #without a parent Author.missing_books #without children On Tuesday, November 27, 2018 at 5:41:53 PM UTC-5, Tom Rossi wrote: > > Its