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?


On Friday, 25 October 2019 21:50:52 UTC+2, My Nguyen wrote:
>
> Something like this would produce the query you want
> ```
> DB.from(:films, :producers).where{ { producers[:name] => 'foo', 
> films[:producer_id] => producers[:id] } }
> ```
>
> My Nguyen
>
> On Fri, Oct 25, 2019 at 2:26 PM Nícolas Iensen <[email protected] 
> <javascript:>> wrote:
>
>> Hey there,
>>
>> I would like to know how could one perform the following SQL query using 
>> the Sequel gem:
>>
>> DELETE FROM films 
>> USING producers
>> WHERE producer_id = producers.id 
>> AND producers.name = 'foo';
>>
>> Thanks for your help :)
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sequel-talk/9239a20e-f18a-4389-9b09-95e9736dee02%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sequel-talk/9239a20e-f18a-4389-9b09-95e9736dee02%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/54fa90b2-cb69-439e-ac7f-2275bbae2f1f%40googlegroups.com.

Reply via email to