take-five / activerecord-hierarchical_query

Simple DSL for creating recursive queries with ActiveRecord
MIT License
119 stars 24 forks source link

Add a select distinct option #9

Closed susanblueapron closed 8 years ago

susanblueapron commented 8 years ago

Adding an option to perform a select distinct on the Common Table Expression, which is useful when this table is created using an outer join.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling a6132d2aba18f6398c6329562e8dcea149451e30 on blueapron:master into c7b60b7f5df91c15dc10a4666411f6dc9d9138b8 on take-five:master.

take-five commented 8 years ago

Hello, and thank you very much for your PR! Have you considered introducing new method distinct instead of introducing an option? I.e.:

Category.join_recursive do |query|
  query.connect_by(id: :parent_id)
       .start_with(id: node_1.id)
       .distinct
end

It won't affect most of your changes, but this way we can have more clear interface. What do you think about it?

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 1be3d924d38f116036c63229433aa2d19b6f60da on blueapron:master into c7b60b7f5df91c15dc10a4666411f6dc9d9138b8 on take-five:master.

susanblueapron commented 8 years ago

Updated distinct from an option to a method now

take-five commented 8 years ago

Thanks, great job!

take-five commented 8 years ago

Check out version 0.1.0 from rubygems

susanblueapron commented 8 years ago

yup, updated in our Gemfile