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

        Christian Jaentsch created issue -
        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 ]

          People

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

            Dates

            • Created:
              Updated: