Add hour to DATE_ADD and DATE_SUB
This commit is contained in:
parent
97762d21a4
commit
dd975fe53d
@ -45,6 +45,11 @@ class DateAddFunction extends FunctionNode
|
|||||||
public function getSql(SqlWalker $sqlWalker)
|
public function getSql(SqlWalker $sqlWalker)
|
||||||
{
|
{
|
||||||
switch (strtolower($this->unit->value)) {
|
switch (strtolower($this->unit->value)) {
|
||||||
|
case 'hour':
|
||||||
|
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression(
|
||||||
|
$this->firstDateExpression->dispatch($sqlWalker),
|
||||||
|
$this->intervalExpression->dispatch($sqlWalker)
|
||||||
|
);
|
||||||
case 'day':
|
case 'day':
|
||||||
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression(
|
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression(
|
||||||
$this->firstDateExpression->dispatch($sqlWalker),
|
$this->firstDateExpression->dispatch($sqlWalker),
|
||||||
@ -59,7 +64,7 @@ class DateAddFunction extends FunctionNode
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
throw QueryException::semanticalError(
|
throw QueryException::semanticalError(
|
||||||
'DATE_ADD() only supports units of type day and month.'
|
'DATE_ADD() only supports units of type hour, day and month.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,11 @@ class DateSubFunction extends DateAddFunction
|
|||||||
public function getSql(SqlWalker $sqlWalker)
|
public function getSql(SqlWalker $sqlWalker)
|
||||||
{
|
{
|
||||||
switch (strtolower($this->unit->value)) {
|
switch (strtolower($this->unit->value)) {
|
||||||
|
case 'hour':
|
||||||
|
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression(
|
||||||
|
$this->firstDateExpression->dispatch($sqlWalker),
|
||||||
|
$this->intervalExpression->dispatch($sqlWalker)
|
||||||
|
);
|
||||||
case 'day':
|
case 'day':
|
||||||
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression(
|
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression(
|
||||||
$this->firstDateExpression->dispatch($sqlWalker),
|
$this->firstDateExpression->dispatch($sqlWalker),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user