You're exactly right about not generating bad queries. This is what prompted me to make this patch and likely what prompted you as well.

Either the query keys should be literal database fields or they should be dynamic names that are interpreted into the correct fields, not half way between like it is now. We should either solve this or remove association name support from queries. There's all sorts of other inconsistencies too, like if you have an association where the table name is set to something other than the plural association name, it'll use the wrong table (something I started fixing in my other PR related to this one).

As for the polymorphic_type, you would be right *if* the polymorphic `_type` field were populated with the STI class. I had to double check this to make sure, but [belongs_to_polymorphic.rb:14](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb#L14) sets the polymorphic `_type` field to the `base_class` of the object. I think this is because you can't have the same `id` with two different STI classes so it's more consistent to just distill this down to the `base_class` for the association.