I meant the "manual fix" you mentionned (adding the third parameter to
link() and unlink() methods)

Taiku

2009/3/9 Hugo Sarti <[email protected]>

> Mmm, I'm working with Doctrine 1.1 and still have this problem... where did
> you found the fix/patch?
>
>
> El Monday 09 March 2009 17:47:33 Nicolas Garnault escribió:
>
> > Thanks a lot Hugo,
> >
> > However, it seems to be a valid fix for Doctrine 1.1, and since
> Doctrine1.1
> > is not shipped with any version of symfony, would you have any idea of
> what
> > could be done to fix this with Doctrine1.0 ?
> >
> > Thanks by advance for you answer,
> >
> > Cheers,
> >
> > Taku
> >
> > 2009/3/9 Hugo Sarti <[email protected]>
> >
> > > I think that it's a bug, but not sure if from Symfony or Doctrine
> (since
> > > the corresponding functions are defined at Doctrine lib)... if you
> > > override the saveFIELDNAMEList() function and modify the following
> > > function calls: $this->object->unlink('XXX', array());
> > > $this->object->link('XXX', $values);
> > >
> > >
> > > by:
> > >
> > >
> > > $this->object->unlink('XXX', array(), true);
> > > $this->object->link('XXX', $values, true);
> > >
> > >
> > > then it works. The last param (true) force the operation to execute now
> > > on database but I'm pretty sure that it won't follow the transactional
> > > order.
> > >
> > >
> > > Let's wait some response from devs to check where do you need to make a
> > > ticket
> > >
> > >
> > > Regards
> > >
> > > El Sunday 08 March 2009 23:13:13 Nicolas Garnault escribió:
> > > > Hello all,
> > > >
> > > > I recently noticed a quite annoying bug with sfFormDoctrine ...
> > > > I've got a quite simple schema, in which I've got three classes :
> > > > "Task", "Category", and "TaskCategory" ; "Task" and "Category"
> relation
> > > > type is n:m.
> > > >
> > > > The problem is that, when I generate a crud to administrate Task
> > > > objects, TaskForm doesn't save the TaskCategory relation properly :
> the
> > > > "task_id" and "category_id" values of the TaskCategory object are
> > > > "switched".
> > > >
> > > > I mean that saving a Task object with id = 1 after having associed it
> > >
> > > with
> > >
> > > > a Category whose id = 5 will make Doctrine try to save a TaskCategory
> > > > object that will contain [task_id : 5, category_id : 1].
> > > >
> > > > I join to this message the concerned part of the stacktrace I get
> when
> > > > I try to submit my form (exception is thrown here because I try to
> save
> > > > a task with id = 1 with a category whose id = 5. As the values are
> > > > switch
> > >
> > > and
> > >
> > > > as it doesn't exist any task with id = 5, doctrine throws me an
> > > > integrity violation on the foreign key constraint).
> > > >
> > > >
> > > > Did anyone already notice this ?
> > > >
> > > >
> > > > Cheers,
> > > >
> > > > Taku (sorry for my english)
> > > >
> > > >
> > > >
> > > >
> > > > StackTrace :
> > > >
> > > >
> > > > - at *Doctrine_Connection_Statement->execute*(*array*('1', '5'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Co
> > >
> > > >nnection.php * line 1041 ...
> > > > <http://kontei/frontend_dev.php/task/update/id/1#> 1. try {
> > > > 2. if ( ! empty($params)) {
> > > > 3. $stmt = $this->prepare($query);
> > > > 4. $stmt->execute($params);
> > > > 5.
> > > > 6. return $stmt->rowCount();
> > > > 7. } else {
> > > > - at *Doctrine_Connection->exec*('INSERT INTO task_category
> > > > (category_id, task_id) VALUES (?, ?)', *array*('1', '5'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Co
> > >
> > > >nnection.php * line 674 ...
> > > > <http://kontei/frontend_dev.php/task/update/id/1#> 1. . '
> > > > (' . implode(', ', $cols) . ')'
> > > > 2. . ' VALUES (' . implode(', ', $a) . ')';
> > > > 3.
> > > > 4. return $this->exec($query, array_values($fields));
> > > > 5. }
> > > > 6.
> > > > 7. /**
> > > > - at *Doctrine_Connection->insert*(*object*('TaskCategoryTable'), *
> > > > array*('category_id' => '1', 'task_id' => '5'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Co
> > >
> > > >nnection/UnitOfWork.php * line 600 ...
> > > > <http://kontei/frontend_dev.php/task/update/id/1#> 1.
> > > > $record->assignIdentifier($id);
> > > > 2. }
> > > > 3.
> > > > 4. $this->conn->insert($table, $fields);
> > > > 5.
> > > > 6. if (empty($seq) && count($identifier) == 1 &&
> > > > $identifier[0] == $table->getIdentifier() &&
> > > > 7. $table->getIdentifierType() != Doctrine::
> > > > IDENTIFIER_NATURAL) {
> > > > - at *Doctrine_Connection_UnitOfWork->processSingleInsert*(*object*
> > > > ('TaskCategory'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Co
> > >
> > > >nnection/UnitOfWork.php * line 559 ...
> > > > <http://kontei/frontend_dev.php/task/update/id/1#> 1.
> > > > $this->_insertCTIRecord($table, $record); 2. //--
> > > > 3. } else {
> > > > 4. $this->processSingleInsert($record);
> > > > 5. }
> > > > 6. }
> > > > 7.
> > > > - at *Doctrine_Connection_UnitOfWork->insert*(*object*
> > > > ('TaskCategory'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Co
> > >
> > > >nnection/UnitOfWork.php * line 79 ...
> > > > <http://kontei/frontend_dev.php/task/update/id/1#> 1.
> > > > switch ($state) {
> > > > 2. case Doctrine_Record::STATE_TDIRTY:
> > > > 3. case Doctrine_Record::STATE_TCLEAN:
> > > > 4. $isValid = $this->insert($record);
> > > > 5. break;
> > > > 6. case Doctrine_Record::STATE_DIRTY:
> > > > 7. case Doctrine_Record::STATE_PROXY:
> > > > - at *Doctrine_Connection_UnitOfWork->saveGraph*(*object*
> > > > ('TaskCategory'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Re
> > >
> > > >cord.php * line 1318 ... <
> > >
> > > http://kontei/frontend_dev.php/task/update/id/1#>
> > >
> > > > 1. if ($conn === null) {
> > > > 2. $conn = $this->_table->getConnection();
> > > > 3. }
> > > > 4. $conn->unitOfWork->saveGraph($this);
> > > > 5. }
> > > > 6.
> > > > 7. /**
> > > > - at *Doctrine_Record->save*()
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/
> > >Re
> > >
> > > >cord.php * line 2053 ... <
> > >
> > > http://kontei/frontend_dev.php/task/update/id/1#>
> > >
> > > > 1. $record = new $modelClassName;
> > > > 2. $record[$localFieldName] = $identifier;
> > > > 3. $record[$foreignFieldName] = $id;
> > > > 4. $record->save();
> > > > 5. }
> > > > 6.
> > > > 7. } else if ($rel instanceof
> > > > Doctrine_Relation_ForeignKey) {
> > > >
> > > > - at *Doctrine_Record->link*('Categories', *array*('1', '5'))
> > > > in *SF_ROOT_DIR/lib/form/doctrine/base/BaseTaskForm.class.php* line
> 128
> > > > ... <http://kontei/frontend_dev.php/task/update/id/1#>
> > > > 1. $values = $this->getValue('categories_list');
> > > > 2. if (is_array($values))
> > > > 3. {
> > > > 4. $this->object->link('Categories', $values);
> > > > 5. }
> > > > 6. }
> > > > 7.
> > > > - at *BaseTaskForm->saveCategoriesList*(*object*
> > > > ('Doctrine_Connection_Mysql'))
> > > > in *SF_ROOT_DIR/lib/form/doctrine/base/BaseTaskForm.class.php* line
> 75
> > > > ... <http://kontei/frontend_dev.php/task/update/id/1#>
> > > > 1. parent::doSave($con);
> > > > 2.
> > > > 3. $this->saveUsersList($con);
> > > > 4. $this->saveCategoriesList($con);
> > > > 5. }
> > > > 6.
> > > > 7. public function saveUsersList($con = null)
> > > > - at *BaseTaskForm->doSave*(*object*('Doctrine_Connection_Mysql'))
> > > > in *
> > >
> > >
> SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/form/sfFormDoctrine.class
> > >.p
> > >
> > > >hp * line 179 ... <http://kontei/frontend_dev.php/task/update/id/1#>
> > >
> > > --
> > >
> > > Hugo Sarti
> > >
> > > Ingeniero en Sistemas de Información
> > >
> > > Syons
> > >
> > > www.syons.com.ar
> >
> >
> --
>
> Hugo Sarti
>
> Ingeniero en Sistemas de Información
>
> Syons
>
> www.syons.com.ar
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" 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.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to