Merge pull request #748 from makhov/master
Add hour to DATE_ADD and DATE_SUB
This commit is contained in:
commit
34b855e253
@ -45,6 +45,11 @@ class DateAddFunction extends FunctionNode
|
||||
public function getSql(SqlWalker $sqlWalker)
|
||||
{
|
||||
switch (strtolower($this->unit->value)) {
|
||||
case 'hour':
|
||||
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddHourExpression(
|
||||
$this->firstDateExpression->dispatch($sqlWalker),
|
||||
$this->intervalExpression->dispatch($sqlWalker)
|
||||
);
|
||||
case 'day':
|
||||
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression(
|
||||
$this->firstDateExpression->dispatch($sqlWalker),
|
||||
@ -59,7 +64,7 @@ class DateAddFunction extends FunctionNode
|
||||
|
||||
default:
|
||||
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)
|
||||
{
|
||||
switch (strtolower($this->unit->value)) {
|
||||
case 'hour':
|
||||
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubHourExpression(
|
||||
$this->firstDateExpression->dispatch($sqlWalker),
|
||||
$this->intervalExpression->dispatch($sqlWalker)
|
||||
);
|
||||
case 'day':
|
||||
return $sqlWalker->getConnection()->getDatabasePlatform()->getDateSubDaysExpression(
|
||||
$this->firstDateExpression->dispatch($sqlWalker),
|
||||
@ -53,7 +58,7 @@ class DateSubFunction extends DateAddFunction
|
||||
|
||||
default:
|
||||
throw QueryException::semanticalError(
|
||||
'DATE_SUB() only supports units of type day and month.'
|
||||
'DATE_SUB() only supports units of type hour, day and month.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user