Commit e69d1cf3 authored by Marco Pivetta's avatar Marco Pivetta

Merge branch 'fix/#2292-do-not-generate-sql-from-with-no-tables' into 2.5

Close #2292
parents bc85f142 e937f37a
......@@ -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']) : '')
......
......@@ -25,6 +25,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment