Skip to content

Commit

Permalink
SearchKit - Add modulo operator to math function
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Oct 31, 2022
1 parent f9bb820 commit 768a9f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions Civi/Api4/Query/SqlEquation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SqlEquation extends SqlExpression {
'-',
'*',
'/',
'%',
];

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/api/v4/Action/SqlExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function testSelectEquations() {
'(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)
Expand All @@ -126,6 +127,7 @@ public function testSelectEquations() {
$this->assertTrue($result['is_between']);
$this->assertArrayNotHasKey('illegal_stuff', $result);
$this->assertEquals('5', $result['null_plus_five']);
$this->assertEquals('1', $result['one_is_odd']);
}

}

0 comments on commit 768a9f5

Please sign in to comment.