dblayeroo : Manage the GROUP_CONCAT in PgSQL without error of casting
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4289 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -550,7 +550,6 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
->displayAdd ("group")
|
||||
->joinLeft ($tbl2, array ("group"=>"group"))
|
||||
->orderAdd ("group", "ASC")
|
||||
->debug (1)
|
||||
->execute ();
|
||||
$tbl1->disconnect ();
|
||||
$tbl2->disconnect ();
|
||||
@@ -768,7 +767,9 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
$tbl1->disconnect ();
|
||||
if ($this->engine === "pgsql")
|
||||
$this->assertSame (array (
|
||||
"order1" => "string_agg(".$tbl1->sep()."group".$tbl1->sep().")"), $res);
|
||||
"order1" => "string_agg(".$tbl1->sep()."group".$tbl1->sep().
|
||||
"::character varying, ',' order by \"group\"".
|
||||
")"), $res);
|
||||
else
|
||||
$this->assertSame (array (
|
||||
"order1" => "GROUP_CONCAT(".$tbl1->sep()."group".$tbl1->sep().")"), $res);
|
||||
@@ -783,7 +784,9 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
if ($this->engine === "pgsql")
|
||||
$this->assertSame (array (
|
||||
"order1" => "string_agg(DISTINCT ".
|
||||
$tbl1->sep()."group".$tbl1->sep().")"), $res);
|
||||
$tbl1->sep()."group".$tbl1->sep().
|
||||
"::character varying, ',' order by \"group\"".
|
||||
")"), $res);
|
||||
else
|
||||
$this->assertSame (array (
|
||||
"order1" => "GROUP_CONCAT(DISTINCT ".
|
||||
@@ -800,7 +803,10 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
if ($this->engine === "pgsql")
|
||||
$this->assertSame (array (
|
||||
"order1" => "string_agg(DISTINCT ".
|
||||
$tbl1->sep()."group".$tbl1->sep().") AS ".
|
||||
$tbl1->sep()."group".$tbl1->sep().
|
||||
"::character varying, ',' order by ".
|
||||
$tbl1->sep()."group".$tbl1->sep().
|
||||
") AS ".
|
||||
$tbl1->sep()."Group Alias".$tbl1->sep()), $res);
|
||||
else
|
||||
$this->assertSame (array (
|
||||
@@ -841,7 +847,9 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
if ($this->engine === "pgsql")
|
||||
$this->assertSame (array (
|
||||
"order1" => "string_agg(".$tbl1->sep()."groupedoo".$tbl1->sep().".".
|
||||
$tbl1->sep()."group".$tbl1->sep().")"), $res);
|
||||
$tbl1->sep()."group".$tbl1->sep().
|
||||
"::character varying, ',' order by \"group\"".
|
||||
")"), $res);
|
||||
else
|
||||
$this->assertSame (array (
|
||||
"order1" => "GROUP_CONCAT(".$tbl1->sep()."groupedoo".$tbl1->sep().".".
|
||||
@@ -858,7 +866,9 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
$this->assertSame (array (
|
||||
"order1" => "string_agg(DISTINCT ".
|
||||
$tbl1->sep()."groupedoo".$tbl1->sep().".".
|
||||
$tbl1->sep()."group".$tbl1->sep().")"), $res);
|
||||
$tbl1->sep()."group".$tbl1->sep().
|
||||
"::character varying, ',' order by \"group\"".
|
||||
")"), $res);
|
||||
else
|
||||
$this->assertSame (array (
|
||||
"order1" => "GROUP_CONCAT(DISTINCT ".
|
||||
@@ -877,7 +887,9 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
$this->assertSame (array (
|
||||
"order1" => "string_agg(DISTINCT ".
|
||||
$tbl1->sep()."groupedoo".$tbl1->sep().".".
|
||||
$tbl1->sep()."group".$tbl1->sep().") AS ".
|
||||
$tbl1->sep()."group".$tbl1->sep().
|
||||
"::character varying, ',' order by \"group\"".
|
||||
") AS ".
|
||||
$tbl1->sep()."Group Alias".$tbl1->sep()), $res);
|
||||
else
|
||||
$this->assertSame (array (
|
||||
@@ -931,10 +943,6 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1 ();
|
||||
$tbl1->displayAdd ("group_concat (group ),group ",
|
||||
"Group Alias,Group2");
|
||||
// PGSQL generate an exception :
|
||||
// function string_agg(character varying) does not exist
|
||||
if ($this->engine === "pgsql")
|
||||
$this->setExpectedException ("PDOException");
|
||||
$res = $tbl1->select ()
|
||||
->execute ();
|
||||
$tbl1->disconnect ();
|
||||
@@ -1010,7 +1018,6 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
$res = $tbl2->select ()
|
||||
->displayAdd ("MAX(uid)")
|
||||
->joinInner ($tbl1, array ("group"=>"group"))
|
||||
->debug (1)
|
||||
->execute ();
|
||||
$tbl2->disconnect ();
|
||||
$this->assertSame (array (array (
|
||||
@@ -1018,4 +1025,26 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
'MAX(usersoo.uid)' => 6,
|
||||
)), $res);
|
||||
}
|
||||
|
||||
public function test_GROUPCONCATwithAlias1 ()
|
||||
{
|
||||
$tbl1 = $this->tbl1 ();
|
||||
$res = $tbl1->select ()
|
||||
->displayAdd ("GROUP_CONCAT(group)", "groups")
|
||||
->execute ();
|
||||
$this->assertSame (array (array (
|
||||
'groups' => 'group1,group2'
|
||||
)), $res);
|
||||
}
|
||||
|
||||
public function test_GROUPCONCATwithAlias2 ()
|
||||
{
|
||||
$tbl1 = $this->tbl1 ();
|
||||
$res = $tbl1->select ()
|
||||
->displayAdd ("GROUP_CONCAT(group,',')", "groups")
|
||||
->execute ();
|
||||
$this->assertSame (array (array (
|
||||
'groups' => 'group1,group2'
|
||||
)), $res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user