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

Example:

  Author.where(posts: { author_id: Author.where(country_id: 1) }).joins(:posts)

Conflicts:
	activerecord/lib/active_record/relation/query_methods.rb
Merge pull request #16503 from bogdan/where-hash-nested-relation-4-1-stable

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