Fix error for aggregate methods with select, see issue #13648
fix exception on polymorphic associations with predicates
Merge pull request #14711 from swoker/activerecord_fix_aggregate_methods_with_select

Activerecord fix aggregate methods with select
:scissors:
New CHANGELOG entries are in to top of file
Use assert_not
Merge branch 'rm-fix-13648'

Includes https://github.com/rails/rails/pull/14711 and some cleanup
commits.

Fixes #13648
The comparison between `Relation` and `CollectionProxy` should be consistent.

Example:

    author.posts == Post.where(author_id: author.id)
    # => true
      Post.where(author_id: author.id) == author.posts
    # => true

Fixes #13506
Make the comparison between 'Relation' and 'AssociationRelation'
consistent.
Ensure that the comparison between 'CollectionProxy' and
'AssociationRelation' is consistent.