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
324f3ac2
Unverified
Commit
324f3ac2
authored
Aug 04, 2017
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/#2785-fix-composite-expression-add-2.6' into 2.6
Backport #2785
parents
015f47af
cee81d54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
CompositeExpression.php
lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
+8
-2
CompositeExpressionTest.php
...e/Tests/DBAL/Query/Expression/CompositeExpressionTest.php
+23
-0
No files found.
lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php
View file @
324f3ac2
...
...
@@ -91,10 +91,16 @@ class CompositeExpression implements \Countable
*/
public
function
add
(
$part
)
{
if
(
!
empty
(
$part
)
||
(
$part
instanceof
self
&&
$part
->
count
()
>
0
))
{
$this
->
parts
[]
=
$part
;
if
(
empty
(
$part
))
{
return
$this
;
}
if
(
$part
instanceof
self
&&
0
===
count
(
$part
))
{
return
$this
;
}
$this
->
parts
[]
=
$part
;
return
$this
;
}
...
...
tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php
View file @
324f3ac2
...
...
@@ -20,6 +20,29 @@ class CompositeExpressionTest extends \Doctrine\Tests\DbalTestCase
$this
->
assertEquals
(
2
,
count
(
$expr
));
}
public
function
testAdd
()
{
$expr
=
new
CompositeExpression
(
CompositeExpression
::
TYPE_OR
,
array
(
'u.group_id = 1'
));
$this
->
assertCount
(
1
,
$expr
);
$expr
->
add
(
new
CompositeExpression
(
CompositeExpression
::
TYPE_AND
,
array
()));
$this
->
assertCount
(
1
,
$expr
);
$expr
->
add
(
new
CompositeExpression
(
CompositeExpression
::
TYPE_OR
,
array
(
'u.user_id = 1'
)));
$this
->
assertCount
(
2
,
$expr
);
$expr
->
add
(
null
);
$this
->
assertCount
(
2
,
$expr
);
$expr
->
add
(
'u.user_id = 1'
);
$this
->
assertCount
(
3
,
$expr
);
}
/**
* @dataProvider provideDataForConvertToString
*/
...
...
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