Re: [Rails-core] [ActiveRecord] [Feature Proposal] Common Table Expression support

2019-01-15 Thread Daniel Heath
IME, which subset of features you use largely depends on the industry sector you're in. There are many rails features I haven't used in the past decade of working on rails apps, but they are important to some users. CTEs are primarily useful when dealing with much larger databases and complex

Re: [Rails-core] [ActiveRecord] [Feature Proposal] Common Table Expression support

2019-01-15 Thread Rafael Mendonça França
Cool! I think the hard work is already done. But I still find it hard to justify this in the framework. It is a feature that is out of Rails for more than 10 years and I personally never needed it working in many applications through the years so I'm not sure if I want to add that complexity to

Re: [Rails-core] [ActiveRecord] [Feature Proposal] Common Table Expression support

2019-01-15 Thread Sean Linsley
While we’re on the subject, I have a PR to get postgres_ext working with Rails 5.2, but need help from someone that has experience with Arel’s internals. https://github.com/danmcclain/postgres_ext/pull/2 Though more broadly I’m of the

Re: [Rails-core] [ActiveRecord] [Feature Proposal] Common Table Expression support

2019-01-15 Thread Rafael Mendonça França
Thank you for the feature proposal. It doesn't seem to be difficult to implement this as a gem given most of the APIs you need in able to implement something like this are public. What do you think about implementing this first as a gem and see if there are adoption of this feature before

[Rails-core] [ActiveRecord] [Feature Proposal] Common Table Expression support

2019-01-15 Thread Daniel Heath
I'd like to be able to use my ActiveRecord scopes in a CTE for another scope. Proposed syntax class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end Post.with(Comment.select(:post_id), name: :post_ids, recursive: false).where(id: