aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/DB
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2019-11-06 11:38:47 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-26 12:05:30 +0100
commit9e450d727a2374c218cdd62c1c97b5ad7ebf48a8 (patch)
tree1695f4521a05b66efc17f360d32696a0c8037a20 /tests/lib/DB
parentdfe85ae0c2c542178657a0a610ecea9f7cd1cea6 (diff)
downloadnextcloud-server-9e450d727a2374c218cdd62c1c97b5ad7ebf48a8.tar.gz
nextcloud-server-9e450d727a2374c218cdd62c1c97b5ad7ebf48a8.zip
add LEAST and GREATER to db function builder
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/DB')
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index a8af7f4fe07..0ddb50272bd 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -198,4 +198,24 @@ class FunctionBuilderTest extends TestCase {
$this->assertEquals(10, $query->execute()->fetchColumn());
}
+
+ public function testGreatest() {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select($query->func()->greatest($query->createNamedParameter(2, IQueryBuilder::PARAM_INT), new Literal(1)));
+ $query->from('appconfig')
+ ->setMaxResults(1);
+
+ $this->assertEquals(2, $query->execute()->fetchColumn());
+ }
+
+ public function testLeast() {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select($query->func()->least($query->createNamedParameter(2, IQueryBuilder::PARAM_INT), new Literal(1)));
+ $query->from('appconfig')
+ ->setMaxResults(1);
+
+ $this->assertEquals(1, $query->execute()->fetchColumn());
+ }
}