I am sorry, but I am struggling. I installed new versions of my gems and
my programs don''t run anymore. As suggested I tried to roll back to
older versions, but that is becoming a bigger mess. The flight forward
has at least recovered 90% of my application.
Both statement worked perfect with the old version of activerecord.
Now the first one works okay, the last one does not get the join built
up in the sql statement.
Again thanks for all the help.
Ernst
This statement works:
owner = Owner.find(:all, :include => {:accounts => {:orders =>{}}},
:conditions => [''Orders.flag = 0''],
:order => [''owners.name, accounts.name, orders.id''])
This statement does not work:
owner = Owner.find(:all,
:include => {:accounts => {:trades =>{}}},
:order => [''owners.name, accounts.name, trades.underlying,
trades.month,
trades.strategy''] )
---------
The error I get is a that accounts.name is not a valid column. Which is
caused by the fact that the join is not added into the SQL statement.
Here is my Schema:
class Owner < ActiveRecord::Base
has_many :accounts
end
class Account < ActiveRecord::Base
belongs_to :owner
has_many :trades
has_many :orders
end
class Order < ActiveRecord::Base
belongs_to :account
end
class Trade < ActiveRecord::Base
belongs_to :account
has_many :legs
end
class Leg < ActiveRecord::Base
belongs_to :trade
end
class Earning < ActiveRecord::Base
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I found a work around dirty but for now it works. The difference between the statements is the use of the conditions part. I added a fake condition :conditions => [''trades.id = trades.id''] and now the joins is built as I want. Definitely a difference between activerecord versions. Would still appreciate a comment from a experience programmer. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-10 21:33 UTC
Re: New version of Activerecord gives different result
On Jun 10, 8:24 pm, Ernst Tanaka <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I am sorry, but I am struggling. I installed new versions of my gems and > my programs don''t run anymore. As suggested I tried to roll back to > older versions, but that is becoming a bigger mess. The flight forward > has at least recovered 90% of my application. > > Both statement worked perfect with the old version of activerecord. > Now the first one works okay, the last one does not get the join built > up in the sql statement. > > Again thanks for all the help. > Ernst >Eager loading (:include) changed substantially in 2.1 but should be able to fallback to the previous code in cases like this. You''ve confused the fallback code by giving an array to :order where you should only be giving a string (the first example works because the conditions options is able to trigger the fallback. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---