On Feb 20, 5:37 am, Simon Arnaud <[email protected]> wrote:
> On 20 fév, 13:58, Simon Arnaud <[email protected]> wrote:
>
> > Something that would look like :
> > Person.filter( :shoes => { :color => 'red' }).filter( :shoes =>
> > { :country => { :name => 'france' } } )
>
> the more I think about it, the more I think it should be simple.
>
> I can do something like :
>
> Person.query do
>   join_table :inner, Shoe, :id => :people__id
>   filter :shoes__color => 'red'
> end

See my earlier message.  I don't really like the query method, I
prefer regular dataset method chaining, but the same ideas apply.

> which is basically SQL, with a ruby DSL.
>
> Note how I have to rewrite the join, when the Person class already
> knows about it, through the one_to_many :shoes.
> And how I have to use the table name, and can't use the class for
> shoes in the filter.

The Person class knows about an association, not a join.

> It seems I should be able to write one of those :
>
> Person.filter(Shoe.color => 'red')
> Person.filter(shoes.filter(:color => 'red'))
> Person.filter(:shoes.filter(:color => 'red'))
> Person.filter(Shoe.filter(:color => 'red'))
>
> as Sequel knows about the join already.

It can't work.  You can have multiple associations to the same model.
it wouldn't know which one to use.  I suppose you could add a method
like association_join, which joined based on the associations
criteria, without setting up eager graphing.  Then you could do:

  Person.association_join(:red_shoes=>:from_france)

You can already pretty much do that via:

  Person.eager_graph(:red_shoes=>:from_france).clone
(:graph=>nil, :eager_graph=>nil)

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to