On Wednesday, December 4, 2013 12:13:04 AM UTC-8, Nels Nelson wrote:
>
> On Wednesday, December 4, 2013 1:30:05 AM UTC-6, Nels Nelson wrote:
>>
>> undefined method `id' for {:one=>1}:Hash
>>
>
> I was able to work around this one as well, by changing
>
> self.parent.remove_child self
>
> to
>
> self.parent.remove_children self.object_id
>
> I'm guessing that the rcte_tree plugin uses 'child' as a special
> depluralized keyword to reference the original children association. But
> since I'm redefining the children association, the plugin thinks 'child'
> refers to a singly-limited empty result set, which breaks.
>
I don't think that's it. From the backtrace it was because in the self
case, the eager_each plugin is causing a eager load, where as in the
self.id case, it retrieves a new object from the database. Honestly, I'm
not sure why remove_children is even defined.
>
>
> Meanwhile this appears to work:
>
> class Bar < Sequel::Model
> plugin :rcte_tree
> plugin :tactical_eager_loading
> one_to_many :children, :key => :parent_id, :class => self, :eager =>
> :foos
> many_to_many :foos, :class => Foo, :join_table => :bar_to_foo,
> :left_key => :foo_id, :right_key => :bar_id, :after_load => proc { |bar,
> foos| foos.each { |foo| something_special_with(bar, foo) } }
> end
>
> However, it doesn't seem to provide any noticeable performance
> improvement. I'll have to gather some metrics, and look into it further.
>
OK. What you might want to do is include SQL logs of the original code and
this code, so you can see what the differences are.
Thanks,
Jeremy
--
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/groups/opt_out.