Hi List, Recently interpolate_sql has dissapeared from edge in JoinAssociation (associations.rb) However there are some lines of code in associations.rb that call this method, and I''m now getting test failures in my own projects: NoMethodError: undefined method `interpolate_sql'' for #<ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation:0x398d818> What''s going on? Presumably, at least those method calls shouldn''t be there. Cheers, Ian White --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
> Hi List, > > Recently interpolate_sql has dissapeared from edge in JoinAssociation > (associations.rb) > > However there are some lines of code in associations.rb that call this > method, and I''m now getting test failures in my own projects: > NoMethodError: undefined method `interpolate_sql'' for > #<ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation:0x398d818> > > What''s going on? Presumably, at least those method calls shouldn''t be > there. >Ah, I think I left that out on accident on one of my recent commits. I''ll check it out. What tests are failing? The AR test suite was all passing when I committed. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
This change broke a couple of my tests. I was eager loading association with conditions that contained #{aliased_table_name}. Even though the interpolation can''t include model attributes, it is still useful to be able to substitute the table name in. To get around the issue, I simply looked at the generated sql and put the aliased table names straight into the conditions, but that is a bit error prone. -Jonathan. On 10/11/06, Rick Olson <technoweenie@gmail.com> wrote:> > > > Hi List, > > > > Recently interpolate_sql has dissapeared from edge in JoinAssociation > > (associations.rb) > > > > However there are some lines of code in associations.rb that call this > > method, and I''m now getting test failures in my own projects: > > NoMethodError: undefined method `interpolate_sql'' for > > > #<ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation:0x398d818> > > > > What''s going on? Presumably, at least those method calls shouldn''t be > > there. > > > > Ah, I think I left that out on accident on one of my recent commits. > I''ll check it out. What tests are failing? The AR test suite was all > passing when I committed. > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
ian.w.white@gmail.com
2006-Oct-11 06:33 UTC
Re: missing interpolate_sql in JoinAssociation
Hi Rick,> Ah, I think I left that out on accident on one of my recent commits. > I''ll check it out. What tests are failing? The AR test suite was all > passing when I committed.The problem occurs when you have a has_many :through a has_many which has conditions. Luckily, the AR fixtures have an instance of this type of relationship, so I wrote a small test (http://pastie.caboo.se/17035) that fails in the current revision, but passes in r5263 (which I believe is the rev before the change). Cheers, Ian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
On 10/11/06, ian.w.white@gmail.com <ian.w.white@gmail.com> wrote:> > Hi Rick, > > > Ah, I think I left that out on accident on one of my recent commits. > > I''ll check it out. What tests are failing? The AR test suite was all > > passing when I committed. > > The problem occurs when you have a has_many :through a has_many which > has conditions. > > Luckily, the AR fixtures have an instance of this type of relationship, > so I wrote a small test (http://pastie.caboo.se/17035) that fails in > the current revision, but passes in r5263 (which I believe is the rev > before the change). > > Cheers, > IanI rolled back the changeset and documented the quirky behavior. Basically, conditions are usually interpolated in the context of the actual record. But since the record hasn''t been loaded yet with eager loading, it''s interpolated in the context of the class. This gives you access to the aliased_table_name method which probably comes in handy for those crazy eager include queries. Thanks for bringing this up, and let me know if this works out. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
ian.w.white@gmail.com
2006-Oct-11 14:27 UTC
Re: missing interpolate_sql in JoinAssociation
> I rolled back the changeset and documented the quirky behavior. > Basically, conditions are usually interpolated in the context of the > actual record. But since the record hasn''t been loaded yet with eager > loading, it''s interpolated in the context of the class. This gives > you access to the aliased_table_name method which probably comes in > handy for those crazy eager include queries.Makes sense. Also good to have documented exactly why {:conditions => "foo = #{foo}"} won''t work in this situation but {:conditions => ["foo = ?", true]} will> ... let me know if this works out.Sure does, thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---