From 770cac9b87c16aebe93b8fa67f34c99bb1408c7d Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 6 Mar 2020 13:02:39 +0200 Subject: [PATCH] orm: IFNULL, NULLIF functions --- application/Espo/ORM/DB/Query/Base.php | 4 ++++ tests/unit/Espo/ORM/DB/QueryTest.php | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/application/Espo/ORM/DB/Query/Base.php b/application/Espo/ORM/DB/Query/Base.php index 9259e152c8..2afce2c0a7 100644 --- a/application/Espo/ORM/DB/Query/Base.php +++ b/application/Espo/ORM/DB/Query/Base.php @@ -162,6 +162,8 @@ abstract class Base 'NOT', 'IN', 'NOT_IN', + 'IFNULL', + 'NULLIF', 'BINARY', 'UNIX_TIMESTAMP', 'TIMESTAMPDIFF_DAY', @@ -195,6 +197,8 @@ abstract class Base 'MUL', 'DIV', 'MOD', + 'IFNULL', + 'NULLIF', 'TIMESTAMPDIFF_DAY', 'TIMESTAMPDIFF_MONTH', 'TIMESTAMPDIFF_YEAR', diff --git a/tests/unit/Espo/ORM/DB/QueryTest.php b/tests/unit/Espo/ORM/DB/QueryTest.php index b11b202b86..5b7f9e89bb 100644 --- a/tests/unit/Espo/ORM/DB/QueryTest.php +++ b/tests/unit/Espo/ORM/DB/QueryTest.php @@ -764,6 +764,17 @@ class QueryTest extends \PHPUnit\Framework\TestCase $this->assertEquals($expectedSql, $sql); } + public function testFunction18() + { + $sql = $this->query->createSelectQuery('Comment', [ + 'select' => [["IFNULL:(name, '')", 'test']], + 'withDeleted' => true + ]); + $expectedSql = + "SELECT IFNULL(comment.name, '') AS `test` FROM `comment`"; + $this->assertEquals($expectedSql, $sql); + } + public function testFunctionTZ1() { $sql = $this->query->createSelectQuery('Comment', [