Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major 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

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Christian Jaentsch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: