Merge pull request #12834 from dredozubov/has_one_association_replacement

Fixes problem with replacing has_one association record with itself
Conflicts:
	activerecord/CHANGELOG.md