Author: romanb
Date: 2008-09-08 20:48:10 +0100 (Mon, 08 Sep 2008)
New Revision: 4889

Added:
   branches/1.0/tests/Ticket/1323TestCase.php
   branches/1.0/tests/Ticket/1323b2TestCase.php
Modified:
   branches/1.0/lib/Doctrine/Collection.php
   branches/1.0/lib/Doctrine/Connection/UnitOfWork.php
   branches/1.0/lib/Doctrine/Relation.php
   branches/1.0/lib/Doctrine/Relation/Nest.php
   branches/1.0/lib/Doctrine/Relation/Parser.php
   branches/1.0/tests/Query/LimitTestCase.php
   branches/1.0/tests/Relation/ManyToManyTestCase.php
   branches/1.0/tests/run.php
Log:
Fixed #1323. Final adjustments to come from jon.

Modified: branches/1.0/lib/Doctrine/Collection.php
===================================================================
--- branches/1.0/lib/Doctrine/Collection.php    2008-09-08 19:15:03 UTC (rev 
4888)
+++ branches/1.0/lib/Doctrine/Collection.php    2008-09-08 19:48:10 UTC (rev 
4889)
@@ -263,8 +263,7 @@
         $this->relation  = $relation;
 
         if ($relation instanceof Doctrine_Relation_ForeignKey || 
-            $relation instanceof Doctrine_Relation_LocalKey) {
-
+                $relation instanceof Doctrine_Relation_LocalKey) {
             $this->referenceField = $relation->getForeignFieldName();
 
             $value = $record->get($relation->getLocalFieldName());
@@ -441,7 +440,6 @@
     {
         if (isset($this->referenceField)) {
             $value = 
$this->reference->get($this->relation->getLocalFieldName());
-
             if ($value !== null) {
                 $record->set($this->referenceField, $value, false);
             } else {

Modified: branches/1.0/lib/Doctrine/Connection/UnitOfWork.php
===================================================================
--- branches/1.0/lib/Doctrine/Connection/UnitOfWork.php 2008-09-08 19:15:03 UTC 
(rev 4888)
+++ branches/1.0/lib/Doctrine/Connection/UnitOfWork.php 2008-09-08 19:48:10 UTC 
(rev 4889)
@@ -444,6 +444,8 @@
                     
$assocRecord->set($assocTable->getFieldName($rel->getLocal()), $record);
                     $this->saveGraph($assocRecord);
                 }
+                // take snapshot of collection state, so that we know when its 
modified again
+                $v->takeSnapshot();
             }
         }
     }

Modified: branches/1.0/lib/Doctrine/Relation/Nest.php
===================================================================
--- branches/1.0/lib/Doctrine/Relation/Nest.php 2008-09-08 19:15:03 UTC (rev 
4888)
+++ branches/1.0/lib/Doctrine/Relation/Nest.php 2008-09-08 19:48:10 UTC (rev 
4889)
@@ -38,7 +38,7 @@
      * @param integer $count
      * @return string
      */
-    public function getRelationDql($count, $context = 'record')
+    /*public function getRelationDql($count, $context = 'record')
     {
         switch ($context) {
             case 'record':
@@ -72,9 +72,8 @@
         };
 
         return $dql;
-    }
+    }*/
 
-    /**
     public function fetchRelatedFor(Doctrine_Record $record)
     {
         $id = $record->getIncremented();
@@ -82,32 +81,6 @@
         if (empty($id) || ! 
$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
             return new Doctrine_Collection($this->getTable());
         } else {
-            $q = new Doctrine_Query();
-            
-            $c  = $this->getTable()->getComponentName();
-            $a  = substr($c, 0, 1);
-            $c2 = $this->getAssociationTable()->getComponentName();
-            $a2 = substr($c2, 0, 1);
-
-            $q->from($c)
-              ->innerJoin($c . '.' . $c2)
-
-            $sub = 'SELECT ' . $this->getForeign() 
-                 . ' FROM '  . $c2
-                 . ' WHERE ' . $this->getLocal() 
-                 . ' = ?';
-        }
-    }
-    */
-
-    public function fetchRelatedFor(Doctrine_Record $record)
-    {
-        $id = $record->getIncremented();
-
-
-        if (empty($id) || ! 
$this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
-            return new Doctrine_Collection($this->getTable());
-        } else {
             $q = new Doctrine_RawSql($this->getTable()->getConnection());
 
             $assocTable = $this->getAssociationFactory()->getTableName();
@@ -136,11 +109,17 @@
               ->from($tableName . ' INNER JOIN ' . $assocTable . ' ON ' . 
implode(' OR ', $joinCondition))
               ->where(implode(' OR ', $condition));
             $q->addComponent($tableName,  
$record->getTable()->getComponentName());
-            $q->addComponent($assocTable, 
$record->getTable()->getComponentName(). '.' . 
$this->getAssociationFactory()->getComponentName());
+            
+            $path = $record->getTable()->getComponentName(). '.' . 
$this->getAssociationFactory()->getComponentName();
+            if ($this->definition['refClassRelation']) {
+                $path = $record->getTable()->getComponentName(). '.' . 
$this->definition['refClassRelation'];
+            }
+            $q->addComponent($assocTable, $path);
 
             $params = ($this->definition['equal']) ? array($id, $id) : 
array($id);
+            $res = $q->execute($params);
 
-            return $q->execute($params);
+            return $res;
         }
     }
 }
\ No newline at end of file

Modified: branches/1.0/lib/Doctrine/Relation/Parser.php
===================================================================
--- branches/1.0/lib/Doctrine/Relation/Parser.php       2008-09-08 19:15:03 UTC 
(rev 4888)
+++ branches/1.0/lib/Doctrine/Relation/Parser.php       2008-09-08 19:48:10 UTC 
(rev 4889)
@@ -155,22 +155,24 @@
         if (isset($this->_relations[$alias])) {
             return $this->_relations[$alias];
         }
-
+       
         if (isset($this->_pending[$alias])) {
             $def = $this->_pending[$alias];
             $identifierColumnNames = $this->_table->getIdentifierColumnNames();
             $idColumnName = array_pop($identifierColumnNames);
-        
+            
             // check if reference class name exists
             // if it does we are dealing with association relation
             if (isset($def['refClass'])) {
                 $def = $this->completeAssocDefinition($def);
                 $localClasses = 
array_merge($this->_table->getOption('parents'), 
array($this->_table->getComponentName()));
+                
+                $backRefRelationName = isset($def['refClassRelation']) ?
+                        $def['refClassRelation'] : $def['refClass'];
+                if ( ! isset($this->_pending[$backRefRelationName]) && ! 
isset($this->_relations[$backRefRelationName])) {
 
-                if ( ! isset($this->_pending[$def['refClass']]) && 
-                     ! isset($this->_relations[$def['refClass']])) {
-
                     $parser = $def['refTable']->getRelationParser();
+                    
                     if ( ! 
$parser->hasRelation($this->_table->getComponentName())) {
                         $parser->bind($this->_table->getComponentName(),
                                       array('type'    => 
Doctrine_Relation::ONE,
@@ -180,10 +182,18 @@
                                             ));
                     }
 
-                    if ( ! $this->hasRelation($def['refClass'])) {
-                        $this->bind($def['refClass'], array('type' => 
Doctrine_Relation::MANY,
-                                                            'foreign' => 
$def['local'],
-                                                            'local'   => 
$idColumnName));
+                    if ( ! $this->hasRelation($backRefRelationName)) {
+                        if (in_array($def['class'], $localClasses)) {
+                            $this->bind($def['refClass'] . " as " . 
$backRefRelationName, array(
+                                    'type' => Doctrine_Relation::MANY,
+                                    'foreign' => $def['foreign'],
+                                    'local'   => $idColumnName));
+                        } else {
+                            $this->bind($def['refClass'] . " as " . 
$backRefRelationName, array(
+                                    'type' => Doctrine_Relation::MANY,
+                                    'foreign' => $def['local'],
+                                    'local'   => $idColumnName));
+                        }
                     }
                 }
                 if (in_array($def['class'], $localClasses)) {
@@ -212,7 +222,6 @@
             if (isset($rel)) {
                 // unset pending relation
                 unset($this->_pending[$alias]);
-
                 $this->_relations[$alias] = $rel;
                 return $rel;
             }
@@ -292,7 +301,6 @@
             if ( ! isset($def['local'])) {
                 // foreign key not set
                 // try to guess the foreign key
-
                 $def['local'] = ($def['foreign'] === $id[0]) ? $id[1] : $id[0];
             }
         } else {

Modified: branches/1.0/lib/Doctrine/Relation.php
===================================================================
--- branches/1.0/lib/Doctrine/Relation.php      2008-09-08 19:15:03 UTC (rev 
4888)
+++ branches/1.0/lib/Doctrine/Relation.php      2008-09-08 19:48:10 UTC (rev 
4889)
@@ -66,6 +66,7 @@
                                   'equal'       => false,
                                   'cascade'     => array(), // 
application-level cascades
                                   'owningSide'  => false, // whether this is 
the owning side
+                                  'refClassRelation' => null,
                                   );
 
     /**

Modified: branches/1.0/tests/Query/LimitTestCase.php
===================================================================
--- branches/1.0/tests/Query/LimitTestCase.php  2008-09-08 19:15:03 UTC (rev 
4888)
+++ branches/1.0/tests/Query/LimitTestCase.php  2008-09-08 19:48:10 UTC (rev 
4889)
@@ -241,13 +241,23 @@
         $user->Group[2]->name = "Terminators";
         
         $user2 = $this->objTable->find(4);
-        $user2->Group = $user->Group;
+        //$user2->Group = $user->Group;
+        $user2->Group = new Doctrine_Collection('Group');
+        $user2->Group[] = $user->Group[0];
+        $user2->Group[] = $user->Group[1];
+        $user2->Group[] = $user->Group[2];
         
         $user3 = $this->objTable->find(6);
-        $user3->Group = $user->Group;
+        //$user3->Group = $user->Group;
+        $user3->Group = new Doctrine_Collection('Group');
+        $user3->Group[] = $user->Group[0];
+        $user3->Group[] = $user->Group[1];
+        $user3->Group[] = $user->Group[2];
 
         $this->assertEqual($user->Group[0]->name, "Action Actors");
         $this->assertEqual(count($user->Group), 3);
+        $this->assertEqual(count($user2->Group), 3);
+        $this->assertEqual(count($user3->Group), 3);
 
         $this->connection->flush();
         
@@ -255,8 +265,8 @@
         $this->assertEqual(count($user->Group), 3);
         
         $q = new Doctrine_Query();
-        $q->from("User")->where("User.Group.id = ?")->orderby("User.id 
ASC")->limit(5);       
-             
+        $q->from("User")->where("User.Group.id = ?")->orderby("User.id 
ASC")->limit(5);
+        
         $users = $q->execute(array($user->Group[1]->id));
         
         $this->assertEqual($users->count(), 3);

Modified: branches/1.0/tests/Relation/ManyToManyTestCase.php
===================================================================
--- branches/1.0/tests/Relation/ManyToManyTestCase.php  2008-09-08 19:15:03 UTC 
(rev 4888)
+++ branches/1.0/tests/Relation/ManyToManyTestCase.php  2008-09-08 19:48:10 UTC 
(rev 4889)
@@ -35,6 +35,7 @@
             $rel = $component->getTable()->getRelation('M2MTest2');
             $this->pass();
         } catch(Doctrine_Exception $e) {
+            echo $e->getMessage();
             $this->fail();
         }
         $this->assertEqual($rel->getForeign(), 'oid');

Added: branches/1.0/tests/Ticket/1323TestCase.php
===================================================================
--- branches/1.0/tests/Ticket/1323TestCase.php                          (rev 0)
+++ branches/1.0/tests/Ticket/1323TestCase.php  2008-09-08 19:48:10 UTC (rev 
4889)
@@ -0,0 +1,225 @@
+<?php
+
+class Doctrine_Ticket_1323_TestCase extends Doctrine_UnitTestCase {
+    public function prepareTables() {
+        $this->tables = array();
+        $this->tables[] = "T1323User";
+        $this->tables[] = "T1323UserReference";
+        parent::prepareTables();
+    }
+    
+    public function prepareData() {}
+
+    public function resetData()
+    {
+      $q = Doctrine_Query::create();
+      $q->delete()->from("T1323UserReference")->execute();
+      $q = Doctrine_Query::create();
+      $q->delete()->from("T1323User")->execute();
+
+      $m = new T1323User();
+      $m->name = "Mother";
+      $m->save();
+      $f = new T1323User();
+      $f->name = "Father";
+      $f->save();
+      $s = new T1323User();
+      $s->name = "Son";
+      $s->save();
+      $d = new T1323User();
+      $d->name = "Daughter";
+      $d->save();
+      $gf = new T1323User();
+      $gf->name = "Grandfather";
+      $gf->save();
+      $gm = new T1323User();
+      $gm->name = "Grandmother";
+      $gm->save();
+      
+      $f->Children[] = $s;
+      $f->Children[] = $d;
+      
+      $f->Parents[] = $gf;
+      $f->Parents[] = $gm;
+      
+      $f->save();
+      
+      $m->Children[] = $s;
+      $m->Children[] = $d;
+      
+      $m->save();      
+
+    }
+    
+    public function testRelationsAreCorrect() {
+        $this->resetData();
+        
+        $f = Doctrine::getTable("T1323User")->findOneByName("Father");
+        $childLinks = $f->childLinks;
+        $this->assertEqual(2, count($childLinks));
+        $this->assertEqual($f->id, $childLinks[0]->parent_id);
+        $this->assertEqual($f->id, $childLinks[1]->parent_id);
+        
+        $parentLinks = $f->parentLinks;
+        $this->assertEqual(2, count($parentLinks));
+        $this->assertEqual($f->id, $parentLinks[0]->child_id);
+        $this->assertEqual($f->id, $parentLinks[1]->child_id);
+        
+        $m = Doctrine::getTable("T1323User")->findOneByName("Mother");
+        $childLinks = $m->childLinks;
+        $this->assertEqual(2, count($childLinks));
+        $this->assertEqual($m->id, $childLinks[0]->parent_id);
+        $this->assertEqual($m->id, $childLinks[1]->parent_id);
+        
+        $parentLinks = $m->parentLinks;
+        $this->assertEqual(0, count($parentLinks));
+        
+        $s = Doctrine::getTable("T1323User")->findOneByName("Son");
+        $childLinks = $s->childLinks;
+        $this->assertEqual(0, count($childLinks));
+        $parentLinks = $s->parentLinks;
+        $this->assertEqual(2, count($parentLinks));
+        $this->assertEqual($s->id, $parentLinks[0]->child_id);
+        $this->assertEqual($s->id, $parentLinks[1]->child_id);
+        
+        $d = Doctrine::getTable("T1323User")->findOneByName("Daughter");
+        $childLinks = $d->childLinks;
+        $this->assertEqual(0, count($childLinks));
+        $parentLinks = $d->parentLinks;
+        $this->assertEqual(2, count($parentLinks));
+        $this->assertEqual($d->id, $parentLinks[0]->child_id);
+        $this->assertEqual($d->id, $parentLinks[1]->child_id);
+        
+        $gm = Doctrine::getTable("T1323User")->findOneByName("Grandmother");
+        $childLinks = $gm->childLinks;
+        $this->assertEqual(1, count($childLinks));
+        $this->assertEqual($gm->id, $childLinks[0]->parent_id);
+        $parentLinks = $gm->parentLinks;
+        $this->assertEqual(0, count($parentLinks));
+        
+        $gf = Doctrine::getTable("T1323User")->findOneByName("Grandfather");
+        $childLinks = $gf->childLinks;
+        $this->assertEqual(1, count($childLinks));
+        $this->assertEqual($gf->id, $childLinks[0]->parent_id);
+        $parentLinks = $gf->parentLinks;
+        $this->assertEqual(0, count($parentLinks));
+    }
+
+   /**
+    * this test will fail
+    */       
+   public function testWithShow() {
+      $this->resetData();
+      
+      T1323User::showAllRelations();
+      $this->runTests();
+   }
+
+   /**
+    * this test will pass
+    */       
+   public function testWithoutShow() {
+      $this->resetData();
+      
+      $this->runTests();
+   }
+
+    
+    public function runTests() {
+        
+      // change "Father"'s name...
+      $f = Doctrine::getTable("T1323User")->findOneByName("Father");
+      $f->name = "Dad";
+      $f->save(); 
+      
+      /*  just playing; makes no difference: 
+          remove "Dad"'s relation to "Son"... */
+      //$s = Doctrine::getTable("T1323User")->findOneByName("Son");
+      //$f->unlink("Children", array($s->id));
+      //$f->save();
+      
+      $relations = Doctrine::getTable("T1323UserReference")->findAll();
+      foreach ($relations as $relation) {
+        /*  never directly touched any relation; so no user should have 
+            himself as parent or child */ 
+        $this->assertNotEqual($relation->parent_id, $relation->child_id);
+      }
+    }
+}
+  
+
+  
+class T1323User extends Doctrine_Record
+{
+    public function setTableDefinition()
+    {
+        $this->hasColumn('name', 'string', 30);
+    }
+
+    public function setUp()
+    {
+        $this->hasMany('T1323User as Parents', array('local' => 'child_id',
+                                                'foreign'  => 'parent_id',
+                                                'refClass' => 
'T1323UserReference',
+                                                'refClassRelation' => 
'childLinks'
+                                                ));
+
+        $this->hasMany('T1323User as Children', array('local' => 'parent_id',
+                                                 'foreign'  => 'child_id',
+                                                 'refClass' => 
'T1323UserReference',
+                                                 'refClassRelation' => 
'parentLinks'
+                                                 ));
+    }
+    
+    /**
+     * just a little function to show all users and their relations
+     */         
+    public static function showAllRelations() {
+        $users = Doctrine::getTable("T1323User")->findAll();
+        
+        //echo "=========================================<br/>".PHP_EOL;
+        //echo "list of all existing users and their relations:<br/> ".PHP_EOL;
+        //echo 
"=========================================<br/><br/>".PHP_EOL.PHP_EOL;
+        
+        foreach ($users as $user) {
+            $parents = $user->Parents;
+            $children = $user->Children;
+            
+            /*echo "user: ";
+            echo $user->name;
+            echo PHP_EOL."<br/>";
+            
+            echo "parents:";
+            echo PHP_EOL."<br/>";
+            foreach ($parents as $parent) {
+                echo $parent->name;
+                echo PHP_EOL."<br/>";
+            }
+            echo PHP_EOL."<br/>";
+            
+            echo "children:";
+            echo PHP_EOL."<br/>";
+            foreach ($children as $child) {
+                echo $child->name;
+                echo PHP_EOL."<br/>";
+            }
+            echo PHP_EOL."<br/>";
+            echo "--------------".PHP_EOL."<br/>";
+            echo PHP_EOL."<br/>";*/
+        }
+    }
+}
+
+class T1323UserReference extends Doctrine_Record
+{
+    public function setTableDefinition()
+    {
+        //$this->hasColumn('id', 'integer', null, array('primary' => true, 
'autoincrement' => true));
+        $this->hasColumn('parent_id', 'integer', null, array('primary' => 
true));
+        $this->hasColumn('child_id', 'integer', null, array('primary' => 
true));
+    }
+}
+
+  
+  
+?>

Added: branches/1.0/tests/Ticket/1323b2TestCase.php
===================================================================
--- branches/1.0/tests/Ticket/1323b2TestCase.php                                
(rev 0)
+++ branches/1.0/tests/Ticket/1323b2TestCase.php        2008-09-08 19:48:10 UTC 
(rev 4889)
@@ -0,0 +1,216 @@
+<?php
+
+class Doctrine_Ticket_1323b2_TestCase extends Doctrine_UnitTestCase {
+    public function prepareTables() {
+       $this->tables = array();
+        $this->tables[] = "Concept";
+        $this->tables[] = "ConceptRelation";
+        parent::prepareTables();
+    }
+
+    public function prepareData() {}
+    
+    /**
+     * setting some polyhierarchical relations
+     */
+    public function resetData()
+    {
+        $q = Doctrine_Query::create();
+        $q->delete()->from("ConceptRelation")->execute();
+        $q = Doctrine_Query::create();
+        $q->delete()->from("Concept")->execute();
+
+        $concepts = array("Woodworking", "Metalworking",  
+                        "Submetalworking 1", "Submetalworking 2",  
+                        "Subwoodworking 1", "Subwoodworking 2",
+                        "Surfaceworking", 
+                        "drilled", "welded", "turned");
+
+        foreach ($concepts as $concept) { 
+            $c = new Concept();
+            $c->identifier = $concept;
+            $c->status = "approved";
+            $c->source = "test";
+            $c->created = "today";
+            $c->creator = "me";
+            $c->creationIdentifier = "nothing";
+            $c->save();
+        }
+        $w = Doctrine::getTable("Concept")->findOneByIdentifier("Woodworking");
+        $sw1 = 
Doctrine::getTable("Concept")->findOneByIdentifier("Subwoodworking 1");
+        $sw2 = 
Doctrine::getTable("Concept")->findOneByIdentifier("Subwoodworking 2");
+        $m = 
Doctrine::getTable("Concept")->findOneByIdentifier("Metalworking");
+        $sm1 = 
Doctrine::getTable("Concept")->findOneByIdentifier("Submetalworking 1");
+        $sm2 = 
Doctrine::getTable("Concept")->findOneByIdentifier("Submetalworking 2");
+        $d = Doctrine::getTable("Concept")->findOneByIdentifier("drilled");
+        $wd = Doctrine::getTable("Concept")->findOneByIdentifier("welded");
+        $t = Doctrine::getTable("Concept")->findOneByIdentifier("turned");
+        $s =  
Doctrine::getTable("Concept")->findOneByIdentifier("Surfaceworking");
+        
+        $w->narrowerConcepts[] = $sw1;
+        $w->narrowerConcepts[] = $sw2;
+        $w->save();
+        
+        $sw1->narrowerConcepts[] = $s;
+        $sw1->narrowerConcepts[] = $d;
+        $sw1->narrowerConcepts[] = $t;
+        $sw1->save();
+        
+        $sw2->narrowerConcepts[] = $d;
+        $sw2->save();
+        
+        $m->narrowerConcepts[] = $sm1;
+        $m->narrowerConcepts[] = $sm2;
+        $m->save();
+        
+        $sm1->narrowerConcepts[] = $wd;
+        $sm1->narrowerConcepts[] = $s;
+        $sm1->save();
+        
+        $sm2->narrowerConcepts[] = $t;
+        $sm2->save();
+        
+        $s->narrowerConcepts[] = $t;
+        $s->narrowerConcepts[] = $d;
+        $s->save();
+    }
+
+    /**
+     * this test will fail ... 
+     */       
+    public function testFAIL() {
+        $this->resetData();
+
+        ConceptRelation::showAllRelations();
+        //lets count all relations
+        $relCount = ConceptRelation::countAll();
+        
+        $oRecord = 
Doctrine::getTable("Concept")->findOneByIdentifier("Surfaceworking");
+        $oRecord->identifier = "MySurfaceworking";
+        $oRecord->save();
+        
+        ConceptRelation::showAllRelations();
+      
+        // we did not change any relations, so we assume this test to be passed
+        $this->assertEqual(ConceptRelation::countAll(), $relCount);
+        // -> where do the additional relations come from ???
+    }
+
+    /*
+     * ... while this test is ok (since we dont save anything)
+     */
+    public function testOK() {
+        $this->resetData();
+        
+        ConceptRelation::showAllRelations();
+        //lets count all relations
+        $relCount = ConceptRelation::countAll();
+        
+        $oRecord = 
Doctrine::getTable("Concept")->findOneByIdentifier("Surfaceworking");
+        $oRecord->identifier = "MySurfaceworking";
+        // $oRecord->save();  --> only this line differs !!!
+        
+        ConceptRelation::showAllRelations();
+        
+        // we did not change any relations, so we assume this test to be passed
+        $this->assertEqual(ConceptRelation::countAll(), $relCount);
+    }
+}
+  
+
+
+
+
+
+
+
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class BaseConcept extends Doctrine_Record
+{
+  public function setTableDefinition()
+  {
+    $this->setTableName('concepts');
+    $this->hasColumn('id', 'integer', 4, array('primary' => true, 
'autoincrement' => true, 'type' => 'integer', 'length' => '4'));
+    $this->hasColumn('vok_id as vokId', 'integer', 4, array('type' => 
'integer', 'length' => '4'));
+    $this->hasColumn('identifier', 'string', 255, array('notnull' => true, 
'type' => 'string', 'length' => '255'));
+    $this->hasColumn('status', 'string', 20, array('notnull' => true, 'type' 
=> 'string', 'length' => '20'));
+    $this->hasColumn('source', 'string', 255, array('notnull' => true, 'type' 
=> 'string', 'length' => '255'));
+    $this->hasColumn('created_on as created', 'string', 255, array('notnull' 
=> true, 'type' => 'string', 'length' => '255'));
+    $this->hasColumn('creator', 'string', 255, array('notnull' => true, 'type' 
=> 'string', 'length' => '255'));
+    $this->hasColumn('creation_identifier as creationIdentifier', 'string', 
255, array('notnull' => true, 'type' => 'string', 'length' => '255'));
+
+    $this->option('type', 'INNODB');
+    $this->option('collate', 'utf8_unicode_ci');
+    $this->option('charset', 'utf8');
+  }
+
+  public function setUp()
+  {
+    $this->hasMany('Concept as broaderConcepts', array('refClass' => 
'ConceptRelation',
+                                                       'local' => 'concept_id',
+                                                       'foreign' => 
'parent_concept_id', 
+                                                       'refClassRelation' => 
'broaderLinks'));
+
+
+    $this->hasMany('Concept as narrowerConcepts', array('refClass' => 
'ConceptRelation',
+                                                        'local' => 
'parent_concept_id',
+                                                        'foreign' => 
'concept_id', 
+                                                        'refClassRelation' => 
'narrowerLinks'));
+  }
+}
+
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class BaseConceptRelation extends Doctrine_Record
+{
+  public function setTableDefinition()
+  {
+    $this->setTableName('concepts_x_concepts');
+    $this->hasColumn('concept_id as conceptId', 'integer', 4, array('type' => 
'integer', 'notnull' => true, 'length' => '4', 'primary' => true));
+    $this->hasColumn('parent_concept_id as conceptIdParent', 'integer', 4, 
array('type' => 'integer', 'notnull' => true, 'length' => '4', 'primary' => 
true));
+
+    $this->option('type', 'INNODB');
+    $this->option('collate', 'utf8_unicode_ci');
+    $this->option('charset', 'utf8');
+  }
+
+  public function setUp()
+  {
+    $this->hasOne('Concept as concept', array('local' => 'concept_id',
+                                              'foreign' => 'id'));
+
+    $this->hasOne('Concept as broaderConcept', array('local' => 
'parent_concept_id',
+                                             'foreign' => 'id'));
+  }
+}
+
+
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class Concept extends BaseConcept
+{
+
+}
+
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class ConceptRelation extends BaseConceptRelation
+{
+    public static function showAllRelations() {
+        /*$relations = Doctrine::getTable("ConceptRelation")->findAll();
+        foreach ($relations as $relation) {
+          echo 
$relation->broaderConcept->identifier."(".$relation->conceptIdParent.")->".$relation->concept->identifier."(".$relation->conceptId.")\n<br/>";
+        }
+        echo "\n\n<br/><br/>";*/
+    }
+    
+    public static function countAll() {
+        return Doctrine::getTable("ConceptRelation")->count();
+    }
+}
+?>

Modified: branches/1.0/tests/run.php
===================================================================
--- branches/1.0/tests/run.php  2008-09-08 19:15:03 UTC (rev 4888)
+++ branches/1.0/tests/run.php  2008-09-08 19:48:10 UTC (rev 4889)
@@ -119,6 +119,8 @@
 $tickets->addTestCase(new Doctrine_Ticket_1296_TestCase());
 $tickets->addTestCase(new Doctrine_Ticket_1304_TestCase());
 $tickets->addTestCase(new Doctrine_Ticket_1305_TestCase());
+$tickets->addTestCase(new Doctrine_Ticket_1323_TestCase());
+$tickets->addTestCase(new Doctrine_Ticket_1323b2_TestCase());
 $tickets->addTestCase(new Doctrine_Ticket_1325_TestCase());
 $tickets->addTestCase(new Doctrine_Ticket_1326_TestCase());
 $tickets->addTestCase(new Doctrine_Ticket_1335_TestCase());


--~--~---------~--~----~------------~-------~--~----~
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