Fixed AR::Relation#where edge case with Hash and other Relation

Example:

  Author.where(posts: { author_id: Author.where(country_id: 1) }).joins(:posts)
Merge pull request #16502 from bogdan/where-hash-nested-relation

[Regression 4.0 -> 4.1] Fixed AR::Relation#where edge case with Hash and other Relation