dblayeroo: GROUP BY was incorrect when there was a join and only one local grouped function: do not call the displayed field on the join objects
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3939 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -320,10 +320,10 @@ class dblayeroo
|
||||
{
|
||||
$this->debugLog ("Entering createTable");
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"),
|
||||
$this->DBException (dgettext("domframework", "Database not connected"),
|
||||
500);
|
||||
if (count ($this->fields) === 0)
|
||||
throw new Exception (dgettext("domframework", "No Field defined"), 500);
|
||||
$this->DBException (dgettext("domframework", "No Field defined"), 500);
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to create the table"), 500);
|
||||
@@ -360,7 +360,7 @@ class dblayeroo
|
||||
$params = array_slice ($params, 1);
|
||||
break;
|
||||
default:
|
||||
throw new Exception (sprintf (
|
||||
$this->DBException (sprintf (
|
||||
dgettext("domframework",
|
||||
"Unknown type '%s' provided for field '%s'"),
|
||||
$this->fieldTypeLight ($field), $field), 500);
|
||||
@@ -386,7 +386,7 @@ class dblayeroo
|
||||
$sql .= " AUTOINCREMENT";
|
||||
break;
|
||||
default:
|
||||
throw new Exception (sprintf (dgettext("domframework",
|
||||
$this->DBException (sprintf (dgettext("domframework",
|
||||
"Unknown additionnal parameter '%s' for field '%s'"),
|
||||
$p, $field), 500);
|
||||
}
|
||||
@@ -397,7 +397,7 @@ class dblayeroo
|
||||
if ($this->unique !== null)
|
||||
{
|
||||
if (!is_array ($this->unique))
|
||||
throw new Exception (dgettext("domframework",
|
||||
$this->DBException (dgettext("domframework",
|
||||
"The Unique field definition is not an array"),
|
||||
500);
|
||||
foreach ($this->unique as $u)
|
||||
@@ -458,7 +458,7 @@ class dblayeroo
|
||||
$params = array_slice ($params, 1);
|
||||
break;
|
||||
default:
|
||||
throw new Exception (sprintf (
|
||||
$this->DBException (sprintf (
|
||||
dgettext("domframework",
|
||||
"Unknown type provided for field '%s'"),
|
||||
$field), 500);
|
||||
@@ -484,7 +484,7 @@ class dblayeroo
|
||||
$sql .= " AUTO_INCREMENT";
|
||||
break;
|
||||
default:
|
||||
throw new Exception (sprintf (
|
||||
$this->DBException (sprintf (
|
||||
dgettext("domframework",
|
||||
"Unknown additionnal '%s' parameter for field '%s'"),
|
||||
$p, $field), 500);
|
||||
@@ -563,7 +563,7 @@ class dblayeroo
|
||||
$params = array_slice ($params, 1);
|
||||
break;
|
||||
default:
|
||||
throw new Exception (sprintf (
|
||||
$this->DBException (sprintf (
|
||||
dgettext("domframework",
|
||||
"Unknown type provided for field '%s'"),
|
||||
$field), 500);
|
||||
@@ -581,7 +581,7 @@ class dblayeroo
|
||||
{
|
||||
case "not null": $sql .= " NOT NULL"; break;
|
||||
default:
|
||||
throw new Exception (sprintf (
|
||||
$this->DBException (sprintf (
|
||||
dgettext("domframework",
|
||||
"Unknown additionnal parameter '%s' for field '%s'"),
|
||||
$p, $field), 500);
|
||||
@@ -620,7 +620,7 @@ class dblayeroo
|
||||
$sql .=")";
|
||||
break;
|
||||
default:
|
||||
throw new Exception (dgettext("domframework",
|
||||
$this->DBException (dgettext("domframework",
|
||||
"PDO Engine not supported in dbLayeroo"), 500);
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ class dblayeroo
|
||||
{
|
||||
$this->debugLog ("Entering dropTable ()");
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"));
|
||||
$this->DBException (dgettext("domframework", "Database not connected"));
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to drop the table"), 500);
|
||||
@@ -907,7 +907,7 @@ class dblayeroo
|
||||
"foreign" => $foreign);
|
||||
break;
|
||||
default:
|
||||
throw new Exception (dgettext("domframework",
|
||||
$this->DBException (dgettext("domframework",
|
||||
"PDO Engine not supported in dbLayeroo"), 500);
|
||||
}
|
||||
}
|
||||
@@ -1576,6 +1576,7 @@ class dblayeroo
|
||||
"MIN","SUM")))
|
||||
{
|
||||
$aggregateFunction = true;
|
||||
echo "AGGRAGATE $this->table \n";
|
||||
// Aggregate function. Add the non aggregate fields to the GROUP BY
|
||||
// expression, if not already done
|
||||
if ($this->groupByExpression === null)
|
||||
@@ -2124,7 +2125,6 @@ class dblayeroo
|
||||
$groupBy = array_merge ($groupBy, $ext);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// If there is some GROUP BY in join Object, but not in this object, all
|
||||
// the displayed fields must be added to be added in the GROUP BY
|
||||
@@ -2134,6 +2134,22 @@ class dblayeroo
|
||||
empty ($this->groupByExpression))
|
||||
))
|
||||
$this->groupByExpression = $this->displayColumn;
|
||||
// If the local groupByExpression is set, but the external object was null,
|
||||
// request the displayed fields to external objects
|
||||
if (is_array ($this->groupByExpression) && $groupBy === null &&
|
||||
$this->joinObject)
|
||||
{
|
||||
foreach ($this->joinObject as $obj)
|
||||
{
|
||||
$ext = $obj->displayGet (true);
|
||||
if ($ext !== null)
|
||||
{
|
||||
if (! is_array ($groupBy))
|
||||
$groupBy = array ();
|
||||
$groupBy = array_merge ($groupBy, $ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array ($this->groupByExpression))
|
||||
{
|
||||
if (! is_array ($groupBy))
|
||||
|
||||
Reference in New Issue
Block a user