From 768a9f5e0e704474b4dfc6f85395d86d7dfba17a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 26 Oct 2022 23:22:31 -0400 Subject: [PATCH] SearchKit - Add modulo operator to math function --- Civi/Api4/Query/SqlEquation.php | 1 + tests/phpunit/api/v4/Action/SqlExpressionTest.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Civi/Api4/Query/SqlEquation.php b/Civi/Api4/Query/SqlEquation.php index dec56e5e14..8ce182fa6a 100644 --- a/Civi/Api4/Query/SqlEquation.php +++ b/Civi/Api4/Query/SqlEquation.php @@ -29,6 +29,7 @@ class SqlEquation extends SqlExpression { '-', '*', '/', + '%', ]; /** diff --git a/tests/phpunit/api/v4/Action/SqlExpressionTest.php b/tests/phpunit/api/v4/Action/SqlExpressionTest.php index d93a175ee6..181cf29a63 100644 --- a/tests/phpunit/api/v4/Action/SqlExpressionTest.php +++ b/tests/phpunit/api/v4/Action/SqlExpressionTest.php @@ -113,6 +113,7 @@ class SqlExpressionTest extends Api4TestBase implements TransactionalInterface { '(illegal * stuff) AS illegal_stuff', // This field will be null '(hold_date + 5) AS null_plus_five', + '(1 % 2) AS one_is_odd', ]) ->addWhere('(contact_id + 1)', '=', 1 + $contact['id']) ->setLimit(1) @@ -126,6 +127,7 @@ class SqlExpressionTest extends Api4TestBase implements TransactionalInterface { $this->assertTrue($result['is_between']); $this->assertArrayNotHasKey('illegal_stuff', $result); $this->assertEquals('5', $result['null_plus_five']); + $this->assertEquals('1', $result['one_is_odd']); } } -- 2.25.1