diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-19 22:39:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 22:39:01 +0100 |
commit | 1b613c84e982ceaf273831e52a2ff2438068667b (patch) | |
tree | a71cc95a631f4fffd34c8924869a5167d06ca6b1 /tests/lib | |
parent | c2510ecae97045b557c75be43bed15ad886cac60 (diff) | |
parent | a61a757b854d89941f525dc218c0d5efd2e9dbc6 (diff) | |
download | nextcloud-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 'tests/lib')
-rw-r--r-- | tests/lib/DB/QueryBuilder/QueryBuilderTest.php | 38 |
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); |