Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

with_scope clobbers result attributes when :joins key is specified

#46

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.

Reported by duncanbeevers · April 25th, 2008 @ 06:28 PM

State: resolved
Milestone: 2.1.1
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. duncanbeevers
    duncanbeevers

    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.

    April 24th, 2008 @ 10:46 PM

  2. duncanbeevers
    duncanbeevers
    • 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.

    April 25th, 2008 @ 06:27 PM

  3. Pratik
    Pratik
    • 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 !

    May 13th, 2008 @ 01:55 PM

  4. Mark
    Mark

    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.

    June 21st, 2008 @ 12:47 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 2.1.1
    • Assigned user set to Jeremy Kemper
    • State changed from incomplete to open

    June 22nd, 2008 @ 11:55 PM

  6. Repository
    Repository
    • State changed from open to resolved

    (from [3558a50a1cb31dd207cc1932aaee5025a7dc7c1b]) Fix column collision with named_scope and :joins. [#46 state:resolved]

    http://github.com/rails/rails/co...

    June 23rd, 2008 @ 03:22 AM

  7. Repository
    Repository

    (from [0fd3e4cd2b2b1b31304a922dc65284d5363f78b6]) Fix column collision with named_scope and :joins. [#46 state:resolved]

    http://github.com/rails/rails/co...

    June 23rd, 2008 @ 03:22 AM

  8. duncanbeevers
    duncanbeevers

    Argh! I've helped make construct_finder_sql that little bit uglier!

    June 23rd, 2008 @ 07:06 PM

  9. David Stevenson
    David Stevenson
    • 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?

    July 11th, 2008 @ 05:11 PM