From a61a757b854d89941f525dc218c0d5efd2e9dbc6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 9 Nov 2020 17:43:29 +0100 Subject: allow selecting multiple columns with SELECT DISTINCT Signed-off-by: Robin Appelman --- lib/private/DB/QueryBuilder/QueryBuilder.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/private/DB') 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; -- cgit v1.2.3