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);