From 305274f6369112b0cb40e3b2e348d8a0f6513a44 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Tue, 2 Apr 2024 14:15:47 +0200 Subject: [PATCH] fix: [component:CRUD] Make sure to append model alias when ordering results --- src/Controller/Component/CRUDComponent.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 3c51bef..da00194 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -97,6 +97,8 @@ class CRUDComponent extends Component if ($sort[0] != $this->Table->getAlias()) { $sort[0] = Inflector::camelize(Inflector::pluralize($sort[0])); } + } else { + array_unshift($sort, $this->Table->getAlias()); } $sort = implode('.', $sort); $query->order($sort . ' ' . $direction);