Fixes #3197: Using `ActiveQuery::indexBy()` may cause relational AR queries to generate incorrect relational results