BUGFIX: Was using custom_database_fields in Aggregate, not database_fields, and so aggregates for the common fields (LastEdited, Created, ClassName) would fail (from r97414)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102489 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 21:10:21 +00:00
parent 2969a7ee44
commit f331e2e1a6
2 changed files with 18 additions and 1 deletions

View File

@ -87,7 +87,7 @@ class Aggregate extends ViewableData {
$table = null;
foreach (ClassInfo::ancestry($this->type, true) as $class) {
$fields = DataObject::custom_database_fields($class);
$fields = DataObject::database_fields($class);
if (array_key_exists($attribute, $fields)) { $table = $class; break; }
}

View File

@ -87,6 +87,23 @@ class AggregateTest extends SapphireTest {
}
/* */
/**
* Test base-level field access - was failing due to use of custom_database_fields, not just database_fields
* @return unknown_type
*/
function testBaseFieldAggregate() {
$this->assertEquals(
DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited'),
DataObject::get_one('AggregateTest_Foo', '', '', 'LastEdited DESC')->LastEdited
);
$this->assertEquals(
DataObject::Aggregate('AggregateTest_Foo')->Max('Created'),
DataObject::get_one('AggregateTest_Foo', '', '', 'Created DESC')->Created
);
}
/* */
/**
* Test aggregation takes place on the passed type & it's children only
*/