Fix for nil sorting on postgres