From 6b2b79d34e29167e4ec60120e74c2ffac202e1cb Mon Sep 17 00:00:00 2001 From: Waseem Khan Date: Mon, 7 Mar 2022 22:05:21 +0500 Subject: [PATCH] Fixed a bug in custom select statement inclusion --- src/ColumnSortable/Sortable.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ColumnSortable/Sortable.php b/src/ColumnSortable/Sortable.php index aa03274..3272b0e 100755 --- a/src/ColumnSortable/Sortable.php +++ b/src/ColumnSortable/Sortable.php @@ -344,8 +344,11 @@ private function formJoin( { $joinType = config('columnsortable.join_type', 'leftJoin'); - $query->select($parentTable . '.*') - ->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey); + if ($query->getQuery()->columns === null) { + $query->select($parentTable.'.*'); + } + + $query->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey); if ($sub1RelatedTable) { $query->{$joinType}($sub1RelatedTable, $sub1RelatedParentPrimaryKey, '=', $sub1RelatedPrimaryKey);