Permalink
Browse files

GH-55 fixed error with eager loading when record doesn't exist

  • Loading branch information...
kla committed Jun 11, 2010
1 parent c225942 commit d2bed655f402beee5d915c7822e84d2b92493da4
Showing with 12 additions and 4 deletions.
  1. +1 −1 lib/Table.php
  2. +9 −1 test/RelationshipTest.php
  3. +2 −2 test/models/Author.php
View
@@ -220,7 +220,7 @@ public function find_by_sql($sql, $values=null, $readonly=false, $includes=null)
$list[] = $model;
}
if ($collect_attrs_for_includes)
if ($collect_attrs_for_includes && !empty($list))
$this->execute_eager_load($list, $attrs, $includes);
return $list;
View
@@ -674,5 +674,13 @@ public function test_gh_40_relationships_with_joins_aliases_table_name_in_condit
$this->assert_equals($event->id, $event->venue->id);
}
/**
* @expectedException ActiveRecord\RecordNotFound
*/
public function test_xxx()
{
Author::find(999999, array('include' => array('books')));
}
};
?>
?>
View
@@ -4,7 +4,7 @@ class Author extends ActiveRecord\Model
static $pk = 'author_id';
static $has_one = array(array('awesome_person', 'foreign_key' => 'author_id', 'primary_key' => 'author_id'),
array('parent_author', 'class_name' => 'Author', 'foreign_key' => 'parent_author_id'));
static $has_many;
static $has_many = array(array('books'));
static $belongs_to = array();
static $setters = array('password');
@@ -19,4 +19,4 @@ public function set_name($value)
$this->assign_attribute('name',$value);
}
};
?>
?>

0 comments on commit d2bed65

Please sign in to comment.