From 74cad8a84c022866ace937ece02fccabd2a6f41e Mon Sep 17 00:00:00 2001 From: Samir Compres Date: Tue, 7 Jan 2020 13:19:07 -0500 Subject: [PATCH] Audit log repository sortBy fix --- src/DataDog/AuditBundle/Repository/AuditLogRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataDog/AuditBundle/Repository/AuditLogRepository.php b/src/DataDog/AuditBundle/Repository/AuditLogRepository.php index b54f1b5..ee5a2d4 100755 --- a/src/DataDog/AuditBundle/Repository/AuditLogRepository.php +++ b/src/DataDog/AuditBundle/Repository/AuditLogRepository.php @@ -29,7 +29,7 @@ public function findByOptions($options = array()) { $options = array( "draw" => isset($options["draw"]) ? $options["draw"] : 1, "search" => isset($options["search"]) ? $options["search"] : "", - "sortBy" => isset($options["sortBy"]) ? $options["sortBy"] : "a.loggedAt", + "sortBy" => isset($options["sortBy"]) ? $options["sortBy"] : "id", "orderBy" => (isset($options["orderBy"]) && in_array(strtolower($options["orderBy"]), array("desc", "asc"))) ? $options["orderBy"] : "asc", "start" => (isset($options["start"]) && $options["start"] >= 0) ? $options["start"] : 0, "limit" => (isset($options["limit"]) && $options["limit"] < self::MAX_RESULTS) ? $options["limit"] : ( (isset($options["length"]) && $options["length"] < self::MAX_RESULTS) ? $options["length"] : self::MAX_RESULTS ), @@ -124,7 +124,7 @@ public function findByOptions($options = array()) { // Manage SortBy if(is_array($options["sortBy"])) { foreach($options["sortBy"] as $sort) { - $qb->addOrderBy($sort, $options["orderBy"]); + $qb->addOrderBy($sort, "a.".$options["orderBy"]); } } else { $qb->orderBy($options["sortBy"], $options["orderBy"]);