Ticket #1113 (closed defect: fixed)

Opened 13 months ago

Last modified 12 months ago

If relationship is not saved on first save, it does not work

Reported by: lsolesen Owned by: romanb
Priority: minor Milestone:
Component: Relations Version: 0.11.0
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description

The following code will not work:

$registrar3 = new VIH_Model_Course_Registration(); $registrar3->Course = $course1; $registrar3->vaerelse = 'test'; $registrar3->save();

$reopend = Doctrine::getTable('VIH_Model_Course_Registration')->findOneById($registrar3->id); $reopend->Subjects[] = $subject1; $reopend->save();

echo '<h2>Registar3 reopened subjects</h2>'; foreach ($reopend->Subjects as $subject) {

echo $subject->navn;

}

Model for the registration can be found here:

 http://svn.intraface.dk/vih/trunk/hojskole/src/VIH/Model/Course/Registration.php

If I save the Subjects right away, it will work. But if I save first and the reopen the registration and try to access Subjects, I get:

Doctrine_Record_Exception: Unknown record property / related component "Subjects" on "VIH_Model_Course_Registration".

An entire test script can be found here:  http://svn.intraface.dk/vih/trunk/hojskole/examples/doctrinebug.php

Attachments

1113TestCase.php (7.3 KB) - added by lsolesen 13 months ago.

Change History

Changed 13 months ago by lsolesen

Seems that if I do:

$registrar3 = new VIH_Model_Course_Registration(); $registrar3->Course = $course1; $registrar3->vaerelse = 'test'; $registrar3->Subjects; $registrar3->save();

it will work.

Changed 13 months ago by lsolesen

  • priority changed from critical to minor

Changed 13 months ago by lsolesen

Changed 13 months ago by guilhermeblanco

  • status changed from new to closed
  • resolution set to fixed

(In [4498]) Fixes #1113. You have a problem with your model. M:N relations should never map both sides with hasOne.

Changed 13 months ago by guilhermeblanco

(In [4499]) Fixes #1113. You have another problem with your model. M:N relations should never map both sides with hasOne and also they should be mapped in both directions to work correctly.

Changed 12 months ago by anonymous

  • milestone 0.11.3 deleted

Milestone 0.11.3 deleted

Note: See TracTickets for help on using tickets.