Does rom-sql support something like Sequel's #from_self?

In Sequel there is a #from_self method, which returns a dataset selecting from the current dataset.

https://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html#method-i-from_self

I want to achieve this with rom-rb. Is it possible?

I tried lots of things without success.

I.e.

      relation.from_self.select {
        [
          # sum(total_price).as(:total_price), # sequel dsl
          integer::sum(:total_price).as(:total_price), # rom dsl
        ]
      }.map.to_a

Thanks

You can try to do forward :from_self within your Relation class and it will define Relation#from_self that should just work.

1 Like

Wow! Thank you. That works! :grinning:

1 Like