Hey. I don't know if this is a bug or something that has been omitted for 
technical reasons, but if I use association_join on an association that 
takes a block parameter, the block is ignored.

For instance, this works:

class Club < Sequel::Model
  many_to_many :members, conditions: { cancelled: nil }
end

This ignores the same conditions:

class Club < Sequel::Model
  many_to_many :members do |ds|
    ds.where(cancelled: nil)
  end
end

In our own use case, we regularly create dataset_modules on our classes for 
common queries, it also allows us to keep certain logic with a single 
object and, in our case, the query is more complex than the example above. 
It would be something like this:

class Club < Sequel::Model
  many_to_many :members do |ds|
    ds.with_active_membership
  end
end

class Member < Sequel::Model
  dataset_module do
    def with_active_membership
      where(cancelled: nil)
    end
  end
end

Is this a bug or a limitation of association_join?

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to