This project is archived and is in readonly mode.

#4756 ✓invalid
fooledbyprimes

query engine: chaining 'includes' method with 'to_sql' method

Reported by fooledbyprimes | June 3rd, 2010 @ 01:51 AM

The to_sql method does not seem to be very consistent. Consider the following two queries:

Person.includes(:users).where("users.username = 'myusername'").to_sql
Person.joins(:users).where("users.username = 'myusername'").to_sql

The second instance returns the full query string showing the "inner joins." But the first one does not show any "inner join" in the query string even though we all know there was a join that was performed.

'to_sql' method should behave consistently especially if framework users are given the impression that to_sql always returns the full query that was used.

Comments and changes to this ticket

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>

Pages