[limb-svn] r6704 - in 3.x/trunk/limb/active_record: src tests/cases

svn at limb-project.com svn at limb-project.com
Fri Jan 18 14:39:49 MSK 2008


Author: serega
Date: 2008-01-18 14:39:49 +0300 (Fri, 18 Jan 2008)
New Revision: 6704
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6704

Modified:
   3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php
   3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php
Log:
-- precessed a case when related single object is null and relation info has "can_be_null" property

Modified: 3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php
===================================================================
--- 3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php	2008-01-18 11:29:17 UTC (rev 6703)
+++ 3.x/trunk/limb/active_record/src/lmbARRecordSetJoinDecorator.class.php	2008-01-18 11:39:49 UTC (rev 6704)
@@ -64,7 +64,10 @@
   {
     foreach($this->join_relations as $relation_name => $params)
     {
-      $relation_info = $this->base_object->getRelationInfo($relation_name); 
+      $relation_info = $this->base_object->getRelationInfo($relation_name);
+      if(isset($relation_info['can_be_null']) && $relation_info['can_be_null'] && !$record->get($this->prefix . $relation_info['field']))
+        return;
+      
       $fields = new lmbSet();
       $prefix = $this->prefix . $relation_name . '__';
       

Modified: 3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php	2008-01-18 11:29:17 UTC (rev 6703)
+++ 3.x/trunk/limb/active_record/tests/cases/lmbARQueryTest.class.php	2008-01-18 11:39:49 UTC (rev 6704)
@@ -614,6 +614,19 @@
     
     $this->assertEqual($this->conn->countQueries(), 0);
   }    
+
+  function testFetch_JoinWorkdsOkIfJoinedObjectIsNotSet()
+  {
+    $program = $this->creator->createProgram();
+    $course1 = $this->creator->createCourse($program);
+    $course2 = $this->creator->createCourse();
+    
+    $query = new lmbARQuery('CourseForTest', $this->conn);
+    $arr = $query->join('program')->fetch()->getArray();
+    
+    $this->assertEqual($arr[0]->getProgram()->getTitle(), $program->getTitle());
+    $this->assertNull($arr[1]->getProgram());
+  }  
 }
 
 



More information about the limb-svn mailing list