aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/QueryBuilder
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-11-19 22:39:01 +0100
committerGitHub <noreply@github.com>2020-11-19 22:39:01 +0100
commit1b613c84e982ceaf273831e52a2ff2438068667b (patch)
treea71cc95a631f4fffd34c8924869a5167d06ca6b1 /lib/private/DB/QueryBuilder
parentc2510ecae97045b557c75be43bed15ad886cac60 (diff)
parenta61a757b854d89941f525dc218c0d5efd2e9dbc6 (diff)
downloadnextcloud-server-1b613c84e982ceaf273831e52a2ff2438068667b.tar.gz
nextcloud-server-1b613c84e982ceaf273831e52a2ff2438068667b.zip
Merge pull request #24007 from nextcloud/select-distinct-multiple
allow selecting multiple columns with SELECT DISTINCT
Diffstat (limited to 'lib/private/DB/QueryBuilder')
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index 7fdeed12130..c2686f7b4a0 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -436,8 +436,14 @@ class QueryBuilder implements IQueryBuilder {
* @return $this This QueryBuilder instance.
*/
public function selectDistinct($select) {
+ if (!is_array($select)) {
+ $select = [$select];
+ }
+
+ $quotedSelect = $this->helper->quoteColumnNames($select);
+
$this->queryBuilder->addSelect(
- 'DISTINCT ' . $this->helper->quoteColumnName($select)
+ 'DISTINCT ' . implode(', ', $quotedSelect)
);
return $this;