aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-11-09 17:43:29 +0100
committerJoas Schilling <coding@schilljs.com>2020-11-16 15:45:17 +0100
commita61a757b854d89941f525dc218c0d5efd2e9dbc6 (patch)
tree476bec27c81dcebb154bcbb421d81acb113fc482 /lib/private/DB
parent426dc68b456f4ea5c5bfbe9f07053e17924ea31a (diff)
downloadnextcloud-server-a61a757b854d89941f525dc218c0d5efd2e9dbc6.tar.gz
nextcloud-server-a61a757b854d89941f525dc218c0d5efd2e9dbc6.zip
allow selecting multiple columns with SELECT DISTINCT
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/DB')
-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;