Skip to content

Search on two associations where the second one is part of the default scope generates invalid SQL #628

@nagyt234

Description

@nagyt234

See the minitest to demonstrate the problem:
https://gist.github.com/nagyt234/b4a9bb210f7cf83262ab
The generated SQL contains

AND "documents_revisions"."code" = 'BBB'

instead of

AND "documents"."code" = 'BBB'

The problem appears only if the default scope on model Revision applied and the first condition refer to an other association.
Note, that this error cames up on Rails 4.1.2 (used in my project), on the newest Rails 4.2 and on Rails 5 beta either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions