Fix PGSQL error on sorting Versioned::get_all_versions()