Details
-
Type:
Bug
-
Status:
Reopened
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.0-RC1
-
Fix Version/s: None
-
Component/s: Relations
-
Labels:None
Description
While implementing a Record_Template and manipulating a query by using the preDqlSelect Event, i got massive problems if the query was generated by a refresh() or refreshRelated() call. I found out that the issue appears because the query has no alias for the table then. This makes it hard to add forther (sub-)selects to the query via preDqlSelect, e.g.
$params = $event->getParams();
$alias = $params['alias'];
if(!$query->isSubquery() && $alias == $queryClone->getRootAlias()) {
$countQuery = '(SELECT COUNT('.$alias.'_tcount.uid) FROM '.$modelName.' '.$alias.'_tcount WHERE '.$alias.'.'.$groupId.'='.$alias.'_tcount.'.$groupId.') AS '.$this->_options['terminationCount'];
$query->addSelect($countQuery);
}
The issue is solved by adding an alias in the foreignKey and localKey relation types' fetchRelatedFor methods (at least that's sufficient for my issue, maybe there is a need to add similar lines to the other relation types).
Doctrine_Relation_ForeignKey (from line 60):
$alias = $this->getTable()->getComponentName().'_rel'; $dql = 'FROM ' . $this->getTable()->getComponentName() .' '.$alias. ' WHERE ' . $this->getCondition($alias) . $this->getOrderBy(null, false);
Doctrine_Relation_LocalKey (from line 58):
$alias = $this->getTable()->getComponentName().'_rel'; $dql = 'FROM ' . $this->getTable()->getComponentName() .' '.$alias. ' WHERE ' . $this->getCondition($alias) . $this->getOrderBy(null, false);
Activity
Roman S. Borschel
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Roman S. Borschel [ romanb ] | Jonathan H. Wage [ jwage ] |
Jonathan H. Wage
made changes -
| Description |
While implementing a Record_Template and manipulating a query by using the preDqlSelect Event, i got massive problems if the query was generated by a refresh() or refreshRelated() call. I found out that the issue appears because the query has no alias for the table then. This makes it hard to add forther (sub-)selects to the query via preDqlSelect, e.g. $params = $event->getParams(); $alias = $params['alias']; if(!$query->isSubquery() && $alias == $queryClone->getRootAlias()) { $countQuery = '(SELECT COUNT('.$alias.'_tcount.uid) FROM '.$modelName.' '.$alias.'_tcount WHERE '.$alias.'.'.$groupId.'='.$alias.'_tcount.'.$groupId.') AS '.$this->_options['terminationCount']; $query->addSelect($countQuery); } The issue is solved by adding an alias in the foreignKey and localKey relation types' fetchRelatedFor methods (at least that's sufficient for my issue, maybe there is a need to add similar lines to the other relation types). Doctrine_Relation_ForeignKey (from line 60): $alias = $this->getTable()->getComponentName().'_rel'; $dql = 'FROM ' . $this->getTable()->getComponentName() .' '.$alias. ' WHERE ' . $this->getCondition($alias) . $this->getOrderBy(null, false); Doctrine_Relation_LocalKey (from line 58): $alias = $this->getTable()->getComponentName().'_rel'; $dql = 'FROM ' . $this->getTable()->getComponentName() .' '.$alias. ' WHERE ' . $this->getCondition($alias) . $this->getOrderBy(null, false); |
While implementing a Record_Template and manipulating a query by using the preDqlSelect Event, i got massive problems if the query was generated by a refresh() or refreshRelated() call. I found out that the issue appears because the query has no alias for the table then. This makes it hard to add forther (sub-)selects to the query via preDqlSelect, e.g. {code} $params = $event->getParams(); $alias = $params['alias']; if(!$query->isSubquery() && $alias == $queryClone->getRootAlias()) { $countQuery = '(SELECT COUNT('.$alias.'_tcount.uid) FROM '.$modelName.' '.$alias.'_tcount WHERE '.$alias.'.'.$groupId.'='.$alias.'_tcount.'.$groupId.') AS '.$this->_options['terminationCount']; $query->addSelect($countQuery); } {code} The issue is solved by adding an alias in the foreignKey and localKey relation types' fetchRelatedFor methods (at least that's sufficient for my issue, maybe there is a need to add similar lines to the other relation types). Doctrine_Relation_ForeignKey (from line 60): {code} $alias = $this->getTable()->getComponentName().'_rel'; $dql = 'FROM ' . $this->getTable()->getComponentName() .' '.$alias. ' WHERE ' . $this->getCondition($alias) . $this->getOrderBy(null, false); {code} Doctrine_Relation_LocalKey (from line 58): {code} $alias = $this->getTable()->getComponentName().'_rel'; $dql = 'FROM ' . $this->getTable()->getComponentName() .' '.$alias. ' WHERE ' . $this->getCondition($alias) . $this->getOrderBy(null, false); {code} |
Jonathan H. Wage
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Invalid [ 6 ] |
Christian Jaentsch
made changes -
| Resolution | Invalid [ 6 ] | |
| Status | Resolved [ 5 ] | Reopened [ 4 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DC-290, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
If no alias is explicitly defined, the alias is automatically set to the model name. So in your code change you changed it from "ModelName" to "ModelName_rel". If you had the following:
The alias would be "User" and it is the same as if you did: