Thanks! I missed that.

I am using eager_graph because i need to filter by fields on the associated 
objects. Is there a cleaner way? (i want something like select T.* from T 
join T2 using (...) where T2.x=y limit 1;) And, if I need to make the join, 
why would I want to avoid the eager loading of the associated object?

BTW, why does .first uses each? I would assumed .first was equivalent to 
.limit(1).all[0]

Thanks!
H

El sábado, 10 de enero de 2015, 20:25:11 (UTC-3), Horacio Peña escribió:
>
> Hi!
>
> From 
> http://sequel.jeremyevans.net/rdoc/classes/Sequel/Model/Associations/DatasetMethods.html
> :
>
> eager_graph (*associations)
>
> This method uses Dataset#graph to create appropriate aliases for columns 
> in all the tables. Then it uses the graph's metadata to build the 
> associations from the single hash, and finally replaces the array of hashes 
> with an array model objects inside all
> I understand that if I do Model.eager_graph(:association). ... .first I 
> should get a Model instance, but I'm getting a Hash, as if I'm were using 
> .ungraphed
>
> 2.0.0-p247 :013 > Suc::Asignacion.eager(:tarea).first
> #<Suc::Asignacion @values={:id=>220, :tarea_id=>3, :posicion=>1, 
> :usuario_id=>3102, :desde=>2000-01-01 09:00:00 -0300, :hasta=>2000-01-01 
> 13:00:00 -0300}>
>
> 2.0.0-p247 :014 > Suc::Asignacion.eager_graph(:tarea).first
> {
>              :id => 220,
>        :tarea_id => 3,
>        :posicion => 1,
>      :usuario_id => 3102,
>           :desde => 2000-01-01 09:00:00 -0300,
>           :hasta => 2000-01-01 13:00:00 -0300,
>      :tarea_id_0 => 3,
>           :fecha => #<Date: 2014-12-23 ((2457015j,0s,0n),+0s,2299161j)>,
>     :tarea_desde => 2000-01-01 09:00:00 -0300,
>     :tarea_hasta => 2000-01-01 13:00:00 -0300,
>        :cantidad => 20,
>     :campanya_id => 2456,
>           :casos => 10
> }
>
>   class Asignacion < Sequel::Model(:suc_asignacion_tareas)
>     many_to_one :tarea
>   end
>
>   class Tarea < Sequel::Model(:suc_tareas)
>     one_to_many :asignaciones, class: :Asignacion
>   end
>
> What am I missing?
>
> Thanks!
> H
>

-- 
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