exports: DurationAggregator: test qb addSelect for compute date interval

This commit is contained in:
2022-08-25 12:38:00 +02:00
parent 2c151c2ec9
commit e1ec2dc25c
2 changed files with 53 additions and 11 deletions

View File

@@ -2,7 +2,9 @@
namespace Chill\MainBundle\Doctrine\DQL;
use Doctrine\ORM\Query\AST\Functions\DateDiffFunction;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\AST\Node;
use Doctrine\ORM\Query\AST\PathExpression;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
@@ -12,13 +14,17 @@ use Doctrine\ORM\Query\SqlWalker;
* Extract postgresql function
* https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
*
* Usage : EXTRACT(field FROM value)
* Usage : EXTRACT(field FROM timestamp)
* TODO allow interval usage -> EXTRACT(field FROM interval)
*/
class Extract extends FunctionNode
{
private string $field;
private PathExpression $value;
private $value;
//private PathExpression $value;
//private FunctionNode $value;
//private DateDiffFunction $value;
public function getSql(SqlWalker $sqlWalker)
{
@@ -39,7 +45,8 @@ class Extract extends FunctionNode
$parser->match(Lexer::T_FROM);
$this->value = $parser->ScalarExpression();
//$this->value = $parser->ScalarExpression();
$this->value = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}