diff options
author | Stephan Orbaugh <62374139+sorbaugh@users.noreply.github.com> | 2024-10-08 11:13:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 11:13:35 +0200 |
commit | 631ceaf6b060942b2417c5c149dbedc880093a24 (patch) | |
tree | 87952bf93ac6df4f7abc8631b39975121ef508d9 /lib/private | |
parent | 166d2f06f3c8d047f896e72d78878a13cd78075c (diff) | |
parent | aab30afc25f43960bef7f2ee2f507c83283a8afe (diff) | |
download | nextcloud-server-631ceaf6b060942b2417c5c149dbedc880093a24.tar.gz nextcloud-server-631ceaf6b060942b2417c5c149dbedc880093a24.zip |
Merge pull request #48558 from nextcloud/backport/48522/stable30
[stable30] fix(QueryBuilder): Account for aliases in output columns
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/DB/QueryBuilder/QueryBuilder.php | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 8432881b490..56187edb3b6 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -582,6 +582,9 @@ class QueryBuilder implements IQueryBuilder { 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); } @@ -591,14 +594,7 @@ class QueryBuilder implements IQueryBuilder { } 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); } /** |