This project is archived and is in readonly mode.

#4472 ✓stale
Josh Kalderimis

:joins and :include behave differently with :conditions

Reported by Josh Kalderimis | April 25th, 2010 @ 03:28 PM

When using a has_many :through, :conditions are applied differently for joins and includes.

The issue is related to applying the aliased table name to the condition has, and is only evident when two :has_many :through relationships use one :has_many as the :through.

Please refer to the attached file for a full example, or the gist found at http://gist.github.com/373613.

I am not sure how to create a test case for this issue but am happy to provide one if someone can give me some pointers.

Comments and changes to this ticket

  • Josh Kalderimis

    Josh Kalderimis April 25th, 2010 @ 03:29 PM

    • Tag changed from activerecord, associations, include, joins to 2.3.x, activerecord, associations, include, joins

    added related version tag

  • Santiago Pastorino

    Santiago Pastorino April 26th, 2010 @ 04:47 AM

    Can you provide a test case?.
    Thanks.

  • Josh Kalderimis

    Josh Kalderimis April 26th, 2010 @ 09:11 AM

    Hi Santiago,

    As I said in the issue, I am not sure how to create a test case for this issue, but I am happy to give it a stab if you can provide me with some pointers or another test which is similar and I can use as an example.

    Thanks,

    Josh

  • Ryan Bigg

    Ryan Bigg April 26th, 2010 @ 09:15 AM

    If you're wanting to do conditions on another table you have to use joins rather than includes, as this will insert an SQL join. include is more for eager loading of potential records, where as joins will only load records that have that particular join.

  • Ryan Bigg

    Ryan Bigg April 27th, 2010 @ 08:44 AM

    • Assigned user set to “Pratik”
  • Josh Kalderimis

    Josh Kalderimis April 29th, 2010 @ 09:25 AM

    This issue is very similar to Issue 2908

    The core of the issue seems to be that the table alias name is not being applied to the conditions when using :joins

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:51 PM

    • State changed from “new” to “open”
    • Tag changed from 2.3.x, activerecord, associations, include, joins to 23x, activerecord, associations, include, joins

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:51 PM

    • State changed from “open” to “stale”

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>

Attachments

Pages