-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from GitHubHubus/ceil_function
added CEIL function
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Oro\ORM\Query\AST\Platform\Functions\Mysql; | ||
|
||
use Oro\ORM\Query\AST\Functions\SimpleFunction; | ||
use Oro\ORM\Query\AST\Platform\Functions\PlatformFunctionNode; | ||
use Doctrine\ORM\Query\SqlWalker; | ||
|
||
class Ceil extends PlatformFunctionNode | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getSql(SqlWalker $sqlWalker) | ||
{ | ||
$value = $this->parameters[SimpleFunction::PARAMETER_KEY]; | ||
|
||
return sprintf('CEIL(%s)', $this->getExpressionValue($value, $sqlWalker)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Oro/ORM/Query/AST/Platform/Functions/Postgresql/Ceil.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Oro\ORM\Query\AST\Platform\Functions\Postgresql; | ||
|
||
use Oro\ORM\Query\AST\Functions\SimpleFunction; | ||
use Oro\ORM\Query\AST\Platform\Functions\PlatformFunctionNode; | ||
use Doctrine\ORM\Query\SqlWalker; | ||
|
||
class Ceil extends PlatformFunctionNode | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getSql(SqlWalker $sqlWalker) | ||
{ | ||
$value = $this->parameters[SimpleFunction::PARAMETER_KEY]; | ||
|
||
return sprintf('CEIL(%s)', $this->getExpressionValue($value, $sqlWalker)); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/Oro/Tests/ORM/AST/Query/Functions/fixtures/mysql/ceil.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- functions: | ||
- { name: "ceil", className: "Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction", type: "numeric" } | ||
dql: "SELECT CEIL(12.34) FROM Oro\\Entities\\Foo f WHERE f.id = 1" | ||
sql: "SELECT CEIL(12.34) AS sclr0 FROM test_foo t0_ WHERE t0_.id = 1" | ||
expectedResult: | ||
- 13 |
6 changes: 6 additions & 0 deletions
6
tests/Oro/Tests/ORM/AST/Query/Functions/fixtures/postgresql/ceil.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- functions: | ||
- { name: "ceil", className: "Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction", type: "numeric" } | ||
dql: "SELECT CEIL(12.34) FROM Oro\\Entities\\Foo f WHERE f.id = 1" | ||
sql: "SELECT CEIL(12.34) AS sclr0 FROM test_foo t0_ WHERE t0_.id = 1" | ||
expectedResult: | ||
- 13 |