Skip to content

Eager load issue after upgrading to Rails 6 #37222

@ghost

Description

Steps to reproduce

cars.eager_load(:tires).joins('LEFT JOIN special_table ON tires.id = special_table.tire_id')

The application.rb file has 'config.load_defaults "6.0"' as suggested on the Upgrade to Rails 6 guide.

Expected behavior

It should take the 'tires.id' from the table 'tires' that has been previously eager loaded. This has been working until upgrading to Rails 6.

Actual behavior

Instead there's an error that as far as I understand it means that the table tires isn't there in the moment of the join so it can't get the tires.id column from anywhere.

ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column 'tires.id' in 'on clause')

If I change the 'eager_load' to 'joins' it solves the issue. However, our app is full of examples like this and I would like to know if there's any other practical solution. Thanks in advance!

System configuration

Rails version: 6.0.0

Ruby version: 2.6.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions