Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
b0202f29
Commit
b0202f29
authored
Aug 14, 2009
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Fixed issue with missing parenthesis in Math expressions
parent
c81affb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
Math.php
lib/Doctrine/ORM/Query/Expr/Math.php
+15
-1
ExprTest.php
tests/Doctrine/Tests/ORM/Query/ExprTest.php
+6
-0
No files found.
lib/Doctrine/ORM/Query/Expr/Math.php
View file @
b0202f29
...
@@ -45,6 +45,20 @@ class Math
...
@@ -45,6 +45,20 @@ class Math
public
function
__toString
()
public
function
__toString
()
{
{
return
$this
->
_leftExpr
.
' '
.
$this
->
_operator
.
' '
.
$this
->
_rightExpr
;
// Adjusting Left Expression
$leftExpr
=
(
string
)
$this
->
_leftExpr
;
if
(
$this
->
_leftExpr
instanceof
Math
)
{
$leftExpr
=
'('
.
$leftExpr
.
')'
;
}
// Adjusting Right Expression
$rightExpr
=
(
string
)
$this
->
_rightExpr
;
if
(
$this
->
_rightExpr
instanceof
Math
)
{
$rightExpr
=
'('
.
$rightExpr
.
')'
;
}
return
$leftExpr
.
' '
.
$this
->
_operator
.
' '
.
$rightExpr
;
}
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Query/ExprTest.php
View file @
b0202f29
...
@@ -129,6 +129,12 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
...
@@ -129,6 +129,12 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
{
{
$this
->
assertEquals
(
'10 / 2'
,
(
string
)
Expr
::
quot
(
10
,
2
));
$this
->
assertEquals
(
'10 / 2'
,
(
string
)
Expr
::
quot
(
10
,
2
));
}
}
public
function
testScopeInArithmeticExpr
()
{
$this
->
assertEquals
(
'(100 - 20) / 2'
,
(
string
)
Expr
::
quot
(
Expr
::
diff
(
100
,
20
),
2
));
$this
->
assertEquals
(
'100 - (20 / 2)'
,
(
string
)
Expr
::
diff
(
100
,
Expr
::
quot
(
20
,
2
)));
}
public
function
testSquareRootExpr
()
public
function
testSquareRootExpr
()
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment