fix: [component:CRUD] Make sure not to override table aliases when paginating

refacto/CRUDComponent
Sami Mokaddem 2023-12-12 09:51:38 +01:00
parent 42a5bd03c6
commit 2274fff424
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 3 additions and 1 deletions

View File

@ -90,8 +90,10 @@ class CRUDComponent extends Component
if ($this->_validOrderFields($sort) && ($direction === 'asc' || $direction === 'desc')) {
$sort = explode('.', $sort);
if (count($sort) > 1) {
if ($sort[0] != $this->Table->getAlias()) {
$sort[0] = Inflector::camelize(Inflector::pluralize($sort[0]));
}
}
$sort = implode('.', $sort);
$query->order($sort . ' ' . $direction);
}