Fixes BR#8822. Fixes issue with field values, when directly upgrading from 1.2.x series.
Fixes issue when using orderby='custom_alias'.