summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-11-20 14:27:27 +0100
committerGitHub <noreply@github.com>2020-11-20 14:27:27 +0100
commite0e3334fc27b1ef70f1486823d52449a1266df75 (patch)
treeb721fa57de1ed7f0c0327fb9284aa32adefde5fc /tests
parent7fa352b28c4b3be998900e054e0bdfc7119e91a6 (diff)
parent22bf656e0232c577ffa581700d73e23768d51fc7 (diff)
downloadnextcloud-server-e0e3334fc27b1ef70f1486823d52449a1266df75.tar.gz
nextcloud-server-e0e3334fc27b1ef70f1486823d52449a1266df75.zip
Merge pull request #24230 from nextcloud/backport/24007/stable20
[stable20] allow selecting multiple columns with SELECT DISTINCT
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
index faf06360e17..fe87a201d57 100644
--- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
@@ -314,6 +314,44 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows('testFirstResult2');
}
+ public function testSelectDistinctMultiple() {
+ $this->deleteTestingRows('testFirstResult1');
+ $this->deleteTestingRows('testFirstResult2');
+ $this->createTestingRows('testFirstResult1');
+ $this->createTestingRows('testFirstResult2');
+
+ $this->queryBuilder->selectDistinct(['appid', 'configkey']);
+
+ $this->queryBuilder->from('*PREFIX*appconfig')
+ ->where($this->queryBuilder->expr()->eq(
+ 'appid',
+ $this->queryBuilder->expr()->literal('testFirstResult1')
+ ))
+ ->orderBy('appid', 'DESC');
+
+ $query = $this->queryBuilder->execute();
+ $rows = $query->fetchAll();
+ $query->closeCursor();
+
+ $this->assertEquals(
+ [
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing1'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing2'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing3'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing4'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing5'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing6'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing7'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing8'],
+ ['appid' => 'testFirstResult1', 'configkey' => 'testing9'],
+ ],
+ $rows
+ );
+
+ $this->deleteTestingRows('testFirstResult1');
+ $this->deleteTestingRows('testFirstResult2');
+ }
+
public function dataAddSelect() {
$config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(ILogger::class);