Project

General

Profile

Actions

Bug #12011

closed

Replace .includes(table).where(table) by .eager_load

Added by Daniel Lobato Garcia over 8 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

On Rails 3, .includes(:users).where("users.name = 'daniel'") works because Rails would be smart enough to figure out the where query uses the includes table.
In this case it'd internally resolve it to eager_load to use the table users in the query. However on Rails 4 they decided they didn't want to maintain a parser for
SQL, so you have to append .references(:table) after all .includes(:table).where("SQL that uses table"). This is not retrocompatible, but we can directly use
eager_load on Rails 3 and 4 to avoid using .references.


Related issues 1 (0 open1 closed)

Related to Foreman - Tracker #3157: Rails 4.1 upgrade tasksClosed09/27/2013

Actions
Actions

Also available in: Atom PDF