Skip to content

Commit

Permalink
Merge d8fcdc0 into 97762d2
Browse files Browse the repository at this point in the history
  • Loading branch information
makhov committed Aug 6, 2013
2 parents 97762d2 + d8fcdc0 commit 1d37685
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/Doctrine/ORM/Query/AST/Functions/DateAddFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -59,7 +64,7 @@ public function getSql(SqlWalker $sqlWalker)

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.'
);
}
}
Expand Down
7 changes: 6 additions & 1 deletion lib/Doctrine/ORM/Query/AST/Functions/DateSubFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -53,7 +58,7 @@ public function getSql(SqlWalker $sqlWalker)

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

0 comments on commit 1d37685

Please sign in to comment.