Add SqlFunction support in addWhere
authorPatrick Figel <pfigel@greenpeace.org>
Sat, 4 Sep 2021 12:51:42 +0000 (14:51 +0200)
committerPatrick Figel <pfigel@greenpeace.org>
Sat, 4 Sep 2021 12:51:42 +0000 (14:51 +0200)
commit1f76bc105d6beef17ea226e7a48f49e6f280371b
treecac3521d24e29d92dce825ca2a36640ba8ed9c04
parente56a41aae945519344668f08dba0d13b09e39cdb
Add SqlFunction support in addWhere

This adds an optional $isExpression parameter in addWhere that
allows use of SqlFunctions in WHERE expressions:

Contact::get(FALSE)
  ->addWhere('last_name', '=', $last_name)
  ->addWhere('LOWER(first_name)', '=', "BINARY('ALICE')", TRUE)
  ->execute()->indexBy('id');

This also adds a few tests to the existing expression support for
ON and HAVING clauses as well as a new BINARY function.
Civi/Api4/Generic/DAOGetAction.php
Civi/Api4/Query/Api4SelectQuery.php
Civi/Api4/Query/SqlFunctionBINARY.php [new file with mode: 0644]
tests/phpunit/api/v4/Action/ContactGetTest.php
tests/phpunit/api/v4/Action/FkJoinTest.php
tests/phpunit/api/v4/Action/SqlFunctionTest.php