Fix regression on eager loading association based on SQL query rather than existing column.

It is a regression added by #14855 (yeah, that's my fault :angry:)

Basically it checks if the column exists before trying to get its type.

Fixes #15480.