APIv4 - Add SQL expression handling and aggregate functions
authorColeman Watts <coleman@civicrm.org>
Tue, 31 Mar 2020 21:33:19 +0000 (17:33 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 1 Apr 2020 21:36:51 +0000 (17:36 -0400)
commit3176b04cb62b0e8f94454e367736f50454f89de8
treead53ef7b0b7efff0b952baf6f6b5c1475ba48853
parent9b06167d3c8dc54bb51e22e3583b18799a46c930
APIv4 - Add SQL expression handling and aggregate functions

Adds a series of SqlExpression classes to parse and validate sql expressions used in SELECT, GROUP BY and ORDER BY clauses.
The framework can handle most sql functions, but this first commit adds support for the aggregate functions AVG, COUNT, MAX, MIN & SUM
19 files changed:
Civi/Api4/Generic/AbstractGetAction.php
Civi/Api4/Generic/DAOGetFieldsAction.php
Civi/Api4/Query/Api4SelectQuery.php
Civi/Api4/Query/SqlExpression.php [new file with mode: 0644]
Civi/Api4/Query/SqlField.php [new file with mode: 0644]
Civi/Api4/Query/SqlFunction.php [new file with mode: 0644]
Civi/Api4/Query/SqlFunctionAVG.php [new file with mode: 0644]
Civi/Api4/Query/SqlFunctionCOUNT.php [new file with mode: 0644]
Civi/Api4/Query/SqlFunctionMAX.php [new file with mode: 0644]
Civi/Api4/Query/SqlFunctionMIN.php [new file with mode: 0644]
Civi/Api4/Query/SqlFunctionSUM.php [new file with mode: 0644]
Civi/Api4/Query/SqlNull.php [new file with mode: 0644]
Civi/Api4/Query/SqlNumber.php [new file with mode: 0644]
Civi/Api4/Query/SqlString.php [new file with mode: 0644]
Civi/Api4/Query/SqlWild.php [new file with mode: 0644]
tests/phpunit/api/v4/Action/SqlExpressionTest.php [new file with mode: 0644]
tests/phpunit/api/v4/Action/SqlFunctionTest.php [new file with mode: 0644]
tests/phpunit/api/v4/Query/SqlExpressionParserTest.php [new file with mode: 0644]
tests/phpunit/api/v4/UnitTestCase.php