This project is archived and is in readonly mode.
with_scope clobbers result attributes when :joins key is specified
Reported by duncanbeevers | April 25th, 2008 @ 06:28 PM | in 2.1.1
Using with_scope with a :joins option does not narrow returned fields to those on the primary model resulting in join table attributes being added to the primary model.
Comments and changes to this ticket
-
duncanbeevers April 24th, 2008 @ 10:46 PM
Attached change to ActiveRecord::Base that gives precedence to last-specified select and provides table-name scoping to selects where joins are involved in the scoping, but not in the final set of find options.
-
duncanbeevers April 25th, 2008 @ 06:27 PM
- Title changed from named_scope should support joins to with_scope clobbers result attributes when :joins key is specified
Attached test showing with_scope injecting false attributes when :joins key is used in scope.
-
Pratik May 13th, 2008 @ 01:55 PM
- State changed from new to incomplete
Could you please upload a single patch ? I'm a little confused with 3 uploded patches. Also, it's good idea to use git-format-patch to create the diff file, so that you get the credit in commit message. http://rails.lighthouseapp.com/p... has a decent explanation.
I'll reopen the ticket after you upload a new patch.
Thanks !
-
Mark June 21st, 2008 @ 12:47 PM
I encountered this bug too.
I have combined the patches into one file and run the tests.
They expose the bug well so I can +1 this patch.
-
Jeremy Kemper June 22nd, 2008 @ 11:55 PM
- Milestone set to 2.1.1
- Assigned user set to Jeremy Kemper
- State changed from incomplete to open
-
Repository June 23rd, 2008 @ 03:22 AM
- State changed from open to resolved
(from [3558a50a1cb31dd207cc1932aaee5025a7dc7c1b]) Fix column collision with named_scope and :joins. [#46 state:resolved]
-
Repository June 23rd, 2008 @ 03:22 AM
(from [0fd3e4cd2b2b1b31304a922dc65284d5363f78b6]) Fix column collision with named_scope and :joins. [#46 state:resolved]
-
duncanbeevers June 23rd, 2008 @ 07:06 PM
Argh! I've helped make construct_finder_sql that little bit uglier!
-
David Stevenson July 11th, 2008 @ 05:11 PM
- Tag set to activerecord, joins, named_scope, patch
This seems like it's a problem with scoping and joins in general - couldn't this be caused by any scoped join?
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 501 Merge :joins instead of clobbering them 4. construct_finder_sql adds the DISTINCT sql keyword to...
- 501 Merge :joins instead of clobbering them Ticket #46 scopes the select to the posts table (i.e. 'p...