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

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97414 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Hamish Friedlander 2010-01-22 00:31:28 +00:00 committed by Sam Minnee
parent 9aa9d936b9
commit c826191897
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
*/