On Friday, October 25, 2019 at 3:29:03 PM UTC-7, Nícolas Iensen wrote:
>
> Thanks for your reply. 
>
> Now considering the two models below:
>
> class Producer < Sequel::Model
>   one_to_many :films
>
>   dataset_module do
>     def fooes
>       where{name = "foo"}
>     end
>   end
> end
>
> class Film < Sequel::Model
>   many_to_one :producer
> end
>
> Could I reuse the dataset fooes implemented in the Producer's module to 
> build the same SQL query?
>

Producer.from(:films, :producers).where{ { producers[:name] => 'foo', 
films[:producer_id] => producers[:id] } }.fooes.delete

Note that your fooes method definition is not going to do what you want.  
You want:

  def fooes
    where(name: "foo")
  end
 
or just:

  where :fooes, name: foo

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f8c551fb-37ba-4752-908c-d6124314f9b4%40googlegroups.com.

Reply via email to