Skip to content

Sorting on a joined column overwrites the current query select #224

Description

@rareclass

With a query that has a select and a join, sorting by a column in the joined table overwrites the original query select, in the formJoin function:

private function formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey)
{
      $joinType = config("columnsortable.join_type", "leftJoin");

      return $query->select($parentTable.".*")->{$joinType}($relatedTable, $parentPrimaryKey, "=", $relatedPrimaryKey);
}

I think the fix is to change the ->select() to ->addSelect()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions