On Wednesday, March 16, 2016 at 9:11:36 PM UTC-5, [email protected] wrote:
>
> This will return all asset with EITHER 'foo' or 'bar' labels, but what I 
> want is to return the assets with BOTH labels.
>

This is perhaps inelegant, but might be an option for you: 

labels = ['foo', 'bar']

label_ids = Label.where(name: labels).select(:id)
asset_ids = DB[:asset_label]
  .where(label_id: label_ids)
  .select_group(:asset_id)
  .having { count(1) =~ labels.size }
@assets = Asset.where(id: asset_ids)


-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to