Skip to content

Commit

Permalink
Merge pull request #48522 from nextcloud/fix/querybuilder/output-colu…
Browse files Browse the repository at this point in the history
…mns-aliases
  • Loading branch information
provokateurin authored Oct 3, 2024
2 parents 9095b49 + e445be1 commit 8638a89
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ private function addOutputColumns(array $columns): void {
if (is_array($column)) {
$this->addOutputColumns($column);
} elseif (is_string($column) && !str_contains($column, '*')) {
if (str_contains(strtolower($column), ' as ')) {
[, $column] = preg_split('/ as /i', $column);
}
if (str_contains($column, '.')) {
[, $column] = explode('.', $column);
}
Expand All @@ -591,14 +594,7 @@ private function addOutputColumns(array $columns): void {
}

public function getOutputColumns(): array {
return array_unique(array_map(function (string $column) {
if (str_contains($column, '.')) {
[, $column] = explode('.', $column);
return $column;
} else {
return $column;
}
}, $this->selectedColumns));
return array_unique($this->selectedColumns);
}

/**
Expand Down

0 comments on commit 8638a89

Please sign in to comment.