#1667: Bug in forUpdate()
-----------------------------------+----------------------------------------
 Reporter:  planetenkiller         |       Owner:  romanb
     Type:  defect                 |      Status:  new   
 Priority:  blocker                |   Milestone:  1.0.4 
Component:  Query/Hydration        |     Version:  1.0.3 
 Keywords:  locking                |    Has_test:  0     
 Mystatus:  Pending Core Response  |   Has_patch:  1     
-----------------------------------+----------------------------------------
 Symfony 1.1.4, Doctrine 1.0.3, PHP 5.2.5, MySql 5.0.51a[[BR]]
 '''First bug:'''[[BR]]
 My query:
 {{{
 Doctrine_Query::create()
 ->from('Sektors')
 ->where('id = 1')
 ->forUpdate(true)
 ->fetchOne();
 }}}
 Error:
 {{{
 Fatal error: Undefined class constant 'FOR_UPDATE'
 in
 
symfonyproject/plugins/sfDoctrinePlugin/lib/doctrine/Doctrine/Query/Abstract.php
 on line 1478
 }}}
 To fix:[[BR]]
 class: Doctrine_Query_Abstract Line 1454
 {{{
 public function forUpdate($flag = true)
 {
         $this->_sqlParts['forUpdate'] = (bool) $flag;
         return $this;
 }
 }}}

 '''Secound bug with forUpdate():'''[[BR]]
 sql Query form Doctrine_Query in Symfony Webebug toolbar:[[BR]]
 {{{
 SELECT s.id AS s__id, s.x_start AS s__x_start, s.x_ende AS s__x_ende,
 s.y_start AS s__y_start, s.y_ende AS s__y_ende
 FROM sektors s WHERE s.id = 1
 }}}
 There is no FOR UPDATE at the end of the query!
 I think the bug is in the function
 Doctrine_Query_Abstract::_processDqlQueryPart() because the function call
 is_array($queryParts) falils (The dql part 'forUpdate' is a boolean not an
 array).

 To fix:[[BR]]
 class: Doctrine_Query_Abstract liine 1996
 {{{
 protected function _processDqlQueryPart($queryPartName, $queryParts)
 {
         // fix
         if($queryPartName == 'forUpdate')
         {
             return;
         }
         // end fix

         $this->removeSqlQueryPart($queryPartName);

         if (is_array($queryParts) && ! empty($queryParts)) {
             foreach ($queryParts as $queryPart) {
                 $parser = $this->_getParser($queryPartName);
                 $sql = $parser->parse($queryPart);
                 if (isset($sql)) {
                     if ($queryPartName == 'limit' || $queryPartName ==
 'offset') {
                         $this->setSqlQueryPart($queryPartName, $sql);
                     } else {
                         $this->addSqlQueryPart($queryPartName, $sql);
                     }
                 }
             }
         }
 }
 }}}
 '''attention:'''[[BR]]
 After $this->removeSqlQueryPart($queryPartName); you don't know the value
 of the sql part 'forUpdate' anymore.
 [[BR]]
 [[BR]]
 Fix these bugs please because Doctrine is unusable with this bug for me.

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1667>
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