Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11562 (new defect)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Associations' dynamic finders fail with :order depends on :include

Reported by: jes5199 Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

Dynamic finders generate invalid queries when they are called on an association like: has_many :posts, :include => :comments, :order_by => 'comments.position' because :include is getting ignored. (using non-dynamic #find() works correctly)

I've attached test cases that cause this error and a patch to fix it. Tested against Trunk.

Attachments

tests_dynamic_finders_on_associations_with_include_and_order.diff (4.2 kB) - added by jes5199 on 04/10/08 07:55:40.
patch_fix_dynamic_finders_on_associations_with_include_and_order.diff (2.0 kB) - added by jes5199 on 04/10/08 07:58:25.
dynamic_finders_on_associations_with_include_and_order.diff (7.3 kB) - added by brandon on 05/31/08 19:41:02.
Updated patch for edge rails

Change History

04/10/08 07:55:40 changed by jes5199

  • attachment tests_dynamic_finders_on_associations_with_include_and_order.diff added.

04/10/08 07:58:25 changed by jes5199

  • attachment patch_fix_dynamic_finders_on_associations_with_include_and_order.diff added.

05/31/08 19:41:02 changed by brandon

  • attachment dynamic_finders_on_associations_with_include_and_order.diff added.

Updated patch for edge rails

05/31/08 20:54:19 changed by brandon

+1

I ran into this problem too. I've attached a patch that includes the fixes and tests updated for edge.