Closed stanislavprokopov closed 12 years ago
oki, I'll take a look, thanks.
Your code couldn't work for all cases.
this commit d5eaf96 break some of my grids
Example:
generated DQL:
SELECT
_a.id, _a.confirmed, _a.type, _a.number, _a.date,
_customer.name as customer::name,
sum(_planned_charges.ammount) as planned_charges::ammount:sum,
_a.currency, _a.conversion, _a.due_date
FROM WebFactory\SaleBundle\Entity\Invoice _a
LEFT JOIN _a.customer _customer
LEFT JOIN _a.planned_charges _planned_charges
GROUP BY planned_charges
ORDER BY _a.date desc
GROUP BY planned_charges
<-- alias problem
[Semantical Error] line 0, col 326 near 'planned_charges': Error: Cannot group by undefined identification or result variable.
Entity.php
line 123
$previousParent = ''; // <--- introduce bug (maybe)
line 151
if ($withAlias) {
// Group by the primary field of the previous entity
$previousParent = '_' . $previousParent; // <---- possible solution prepend '_'
$this->query->addGroupBy($previousParent);
$this->querySelectfromSource->addGroupBy($previousParent);
return $functionWithParameters.' as '.substr($parent, 1).'::'.$matches['all'];
}
Is it better now ?
Does not work.
Error:
[Semantical Error] line 0, col 60 near '__user.email': Error: '__user' is not defined.
The error is because the alias is:
LEFT JOIN _a.user _user
But in the query it uses __user.
UPDATED: After updating to latest fix 6501696, works ok.
Not really ok because more than two level joined mapping isn't mapped into the result.
Can you try again ?
Updated, works ok for me.
Work again! Thanks!
I have found an alias name conflict. Entity has these 2 fields:
When i try to create the grid, the sql fails if i have both affiliate.personal.company_name and distributor.personal.company_name. If i have only one of these fields, the query works ok. The problem is that when building alias names, the script takes "personal" and creates an alias "_personal". So when the second field is processed and it`s alias is created the first one is overwritten.
Fast fix, in the Grid\Source\Entity class, line 128-131:
This fix will create alias names with the parent prefix: _affiliatepersonal AND _distributorpersonal