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
272b8721
Commit
272b8721
authored
Jul 15, 2016
by
Marco Pivetta
Committed by
GitHub
Jul 15, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2292 from deeky666/DBAL-2291
Do not generate FROM clause in QueryBuilder if no tables specified
parents
27d33238
3cbd4938
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+2
-2
QueryBuilderTest.php
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+12
-0
No files found.
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
272b8721
...
...
@@ -1107,9 +1107,9 @@ class QueryBuilder
*/
private
function
getSQLForSelect
()
{
$query
=
'SELECT '
.
implode
(
', '
,
$this
->
sqlParts
[
'select'
])
.
' FROM '
;
$query
=
'SELECT '
.
implode
(
', '
,
$this
->
sqlParts
[
'select'
]);
$query
.=
implode
(
', '
,
$this
->
getFromClauses
()
)
$query
.=
(
$this
->
sqlParts
[
'from'
]
?
' FROM '
.
implode
(
', '
,
$this
->
getFromClauses
())
:
''
)
.
(
$this
->
sqlParts
[
'where'
]
!==
null
?
' WHERE '
.
((
string
)
$this
->
sqlParts
[
'where'
])
:
''
)
.
(
$this
->
sqlParts
[
'groupBy'
]
?
' GROUP BY '
.
implode
(
', '
,
$this
->
sqlParts
[
'groupBy'
])
:
''
)
.
(
$this
->
sqlParts
[
'having'
]
!==
null
?
' HAVING '
.
((
string
)
$this
->
sqlParts
[
'having'
])
:
''
)
...
...
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
View file @
272b8721
...
...
@@ -23,6 +23,18 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
->
will
(
$this
->
returnValue
(
$expressionBuilder
));
}
/**
* @group DBAL-2291
*/
public
function
testSimpleSelectWithoutFrom
()
{
$qb
=
new
QueryBuilder
(
$this
->
conn
);
$qb
->
select
(
'some_function()'
);
$this
->
assertEquals
(
'SELECT some_function()'
,
(
string
)
$qb
);
}
public
function
testSimpleSelect
()
{
$qb
=
new
QueryBuilder
(
$this
->
conn
);
...
...
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