1
0
mirror of synced 2025-01-18 14:31:40 +03:00

Merge pull request #748 from makhov/master

Add hour to DATE_ADD and DATE_SUB
This commit is contained in:
Guilherme Blanco 2013-08-06 14:50:14 -07:00
commit 34b855e253
2 changed files with 12 additions and 2 deletions

View File

@ -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.'
);
}
}

View File

@ -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.'
);
}
}