Martin Emde
2006-Aug-31 20:41 UTC
Ticket #5971 - Patch to fix sanitize_sql for associations.
There''s a very minor bug in the associations when generating conditions. It uses @reflection.active_record.sanitize_sql which results in Hash type conditions getting the table name of the model that has the association instead of on the association table. For example, something like: class Person < ActiveRecord::Base has_one :address, :conditions => { :disabled => false } has_many :shipments, :through => :address end if you do: p = Person.find(1) p.shipments the sql it generates to fetch the shipments will include in it''s conditions: `people`.disabled = ''0'' when that should be `addresses`.disabled = ''0'' All we need to do to fix that is have each call to sanitize_sql be done with the class the conditions are being called on as the receiver. @reflection.through_reflection.klass.sanitize_sql(@ reflection.throught_reflection.options[:conditions]) And it''s solved: Here''s the patch link. I''d like to get this in so I don''t have to write a monkey patch to do it since it''s considerably more code than the 3 line fix to core. http://dev.rubyonrails.org/ticket/5971/ Let me know if there''s anything I can do to help this through. -Martin Emde --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---