Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Bugs in eager loading of has_one :through and has_many :through
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joseph Palermo  
View profile  
 More options Jan 9, 3:46 pm
From: Joseph Palermo <jpale...@pivotallabs.com>
Date: Fri, 9 Jan 2009 12:46:11 -0800 (PST)
Local: Fri, Jan 9 2009 3:46 pm
Subject: Bugs in eager loading of has_one :through and has_many :through
Failing test can be found here:
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/17...

Eager loading of has_one :through has an easy to fix problem.  It
doesn't pass the :conditions or :order of the base association down to
the "source" include on the :through association.  has_many :through
does this already, the "options" just need to be passed down.

The larger problem, of both has_one :through and has_many :through is
when you have a :conditions that references the :through table.  Since
preload never does any joining, it always does the associations
independently, it throws a SQL error because it can't find that table.

This is only a problem with eager loading, the find_every code in
base.rb does the correct detection normally.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frederick Cheung  
View profile  
 More options Jan 11, 5:41 am
From: Frederick Cheung <frederick.che...@gmail.com>
Date: Sun, 11 Jan 2009 10:41:30 +0000
Local: Sun, Jan 11 2009 5:41 am
Subject: Re: [Rails-core] Bugs in eager loading of has_one :through and has_many :through

On 9 Jan 2009, at 20:46, Joseph Palermo wrote:

> Failing test can be found here:
> http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/17...

> Eager loading of has_one :through has an easy to fix problem.  It
> doesn't pass the :conditions or :order of the base association down to
> the "source" include on the :through association.  has_many :through
> does this already, the "options" just need to be passed down.

> The larger problem, of both has_one :through and has_many :through is
> when you have a :conditions that references the :through table.  Since
> preload never does any joining, it always does the associations
> independently, it throws a SQL error because it can't find that table.

I've been vaguely meaning to rewrite the preload code so that it loads  
hmt associations in one go (rather than loading the records in two  
steps).
There's a preliminary task which is to refactor the hmt code to make  
it easy for the preload stuff to recreate the appropriate joins (don't  
really fancy duplicating all that like in join based eager loading).

Fred


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google