Fix query entity handling for get_mapper
Improve order by type handling