column = case attribute.try(:relation)
                   when Arel::Nodes::TableAlias, NilClass
                   else
                     cache = attribute.relation.engine.connection.schema_cache
                     if cache.table_exists? attribute.relation.name