Merge pull request #14992 from fredwu/habtm_relation_size_calculation_fix

Habtm relation size calculation fix. Fixes #14913, Fixes #14914.

Conflicts:
	activerecord/CHANGELOG.md