#1534: Enabling query callbacks breaks some queries having parameters and a 
limit
clause
-----------------------------------+----------------------------------------
 Reporter:  jphilip                |       Owner:  romanb
     Type:  defect                 |      Status:  new   
 Priority:  major                  |   Milestone:  1.0.3 
Component:  Listeners              |     Version:  1.0.2 
 Keywords:                         |    Has_test:  0     
 Mystatus:  Pending Core Response  |   Has_patch:  0     
-----------------------------------+----------------------------------------
 The same query runs fine when query callbacks are off, but not when it is
 turned off.
 The is no behavior with a preDqlSelect method attached to the models in
 this example:
 (Sorry I could not come up with a test case. Schema yml file is attached)

 The query:

 return $q->select('p.*, k.*, tg.*, t.*, c.id')
       ->from('Post p, p.kennel k, p.comments c, p.taggings tg, tg.tag t')
       ->orderby('p.created_at desc')
       ->where('k.slug = ?', $slug)
       ->limit($count)
       ->execute();

 The expected generated SQL when query callbacks are off:
 (Mostly the parameter is gone. If I remove the parameter or the limit
 clause, all is fine)

 SELECT DISTINCT p2.id FROM post p2 LEFT JOIN kennel k2 ON p2.kennel_id =
 k2.id LEFT JOIN comment c2 ON p2.id = c2.post_id LEFT JOIN tagging t3 ON
 p2.id = t3.post_id LEFT JOIN tag t4 ON t3.tag_id = t4.id WHERE k2.slug = ?
 ORDER BY p2.created_at desc LIMIT 20 - (noatak )

 The stack trace including the generated SQL query when callbacks are on:

     * at ()
       in
 SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Connection.php
 line 1074 ...
             1071.
             1072.         $name = 'Doctrine_Connection_' .
 $this->driverName . '_Exception';
             1073.
             1074.         $exc  = new $name($e->getMessage(), (int)
 $e->getCode());
             1075.         if ( ! is_array($e->errorInfo)) {
             1076.             $e->errorInfo = array(null, null, null,
 null);
             1077.         }
     * at Doctrine_Connection->rethrowException(object('PDOException'),
 object('Doctrine_Connection_Mysql'))
       in
 SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Connection.php
 line 1022 ...
             1019.         } catch (Doctrine_Adapter_Exception $e) {
             1020.         } catch (PDOException $e) { }
             1021.
             1022.         $this->rethrowException($e, $this);
             1023.     }
             1024.
             1025.     /**
     * at Doctrine_Connection->execute('SELECT DISTINCT p2.id FROM post p2
 LEFT JOIN kennel k2 ON p2.kennel_id = k2.id LEFT JOIN comment c2 ON p2.id
 = c2.post_id LEFT JOIN tagging t3 ON p2.id = t3.post_id LEFT JOIN tag t4
 ON t3.tag_id = t4.id WHERE k2.slug = ? ORDER BY p2.created_at desc LIMIT
 20', array())
       in
 SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query.php line
 1150 ...
             1147.                 switch
 (strtolower($this->_conn->getDriverName())) {
             1148.                     case 'mysql':
             1149.                         // mysql doesn't support LIMIT
 in subqueries
             1150.                         $list =
 $this->_conn->execute($subquery,
 $params)->fetchAll(Doctrine::FETCH_COLUMN);
             1151.                         $subquery = implode(', ',
 array_map(array($this->_conn, 'quote'), $list));
             1152.                         break;
             1153.                     case 'pgsql':
     * at Doctrine_Query->getSqlQuery()
       in
 SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query\Abstract.php
 line 1084 ...
             1081.             }
             1082.
             1083.             $copy = $this->copy();
             1084.             $copy->getSqlQuery();
             1085.
             1086.             foreach ($copy->getQueryComponents() as
 $alias => $component) {
             1087.                 $table = $component['table'];
     * at Doctrine_Query_Abstract->_preQuery()
       in
 SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query\Abstract.php
 line 989 ...
              986.      */
              987.     public function execute($params = array(),
 $hydrationMode = null)
              988.     {
              989.         $this->_preQuery();
              990.
              991.         if ($hydrationMode !== null) {
              992.
 $this->_hydrator->setHydrationMode($hydrationMode);

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1534>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to