dblayeroo : if there is only one displayed GROUP select, do not add an empty "GROUP BY" in SQL request. The request is invalid.
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4286 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -974,4 +974,30 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
|||||||
), $res);
|
), $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_displayAdd_MAX1 ()
|
||||||
|
{
|
||||||
|
$tbl2 = $this->tbl2 ();
|
||||||
|
$res = $tbl2->select ()
|
||||||
|
->displayAdd ("MAX(uid)", "max")
|
||||||
|
->displayAdd ("gecos")
|
||||||
|
->orderAdd ("max","ASC")
|
||||||
|
->execute ();
|
||||||
|
$tbl2->disconnect ();
|
||||||
|
$this->assertSame (array (
|
||||||
|
array ('max' => 1, 'gecos' => 'name'),
|
||||||
|
array ('max' => 4, 'gecos' => 'name2'),
|
||||||
|
array ('max' => 5, 'gecos' => 'name3'),
|
||||||
|
array ('max' => 6, 'gecos' => 'name4')),
|
||||||
|
$res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_displayAdd_MAX2 ()
|
||||||
|
{
|
||||||
|
$tbl2 = $this->tbl2 ();
|
||||||
|
$res = $tbl2->select ()
|
||||||
|
->displayAdd ("MAX(uid)")
|
||||||
|
->execute ();
|
||||||
|
$tbl2->disconnect ();
|
||||||
|
$this->assertSame (array (array ('MAX(uid)' => 6)), $res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2315,7 +2315,8 @@ class dblayeroo
|
|||||||
if ($this->groupByNeeded ())
|
if ($this->groupByNeeded ())
|
||||||
{
|
{
|
||||||
$groupByExpression = $this->groupByGet ();
|
$groupByExpression = $this->groupByGet ();
|
||||||
$sql .= "\n GROUP BY ". implode (",", $groupByExpression);
|
if (count ($groupByExpression))
|
||||||
|
$sql .= "\n GROUP BY ". implode (",", $groupByExpression);
|
||||||
}
|
}
|
||||||
if (count ($order))
|
if (count ($order))
|
||||||
$sql .= "\n ORDER BY ". implode (",", $order);
|
$sql .= "\n ORDER BY ". implode (",", $order);
|
||||||
|
|||||||
Reference in New Issue
Block a user