mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
2969a7ee44
commit
f331e2e1a6
@ -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; }
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user