mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fixed querying of composite fields (broken due to inappropriate optimisation of hasField)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84796 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e0e12aeb40
commit
dfbd16e140
@ -2096,6 +2096,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
return (
|
return (
|
||||||
array_key_exists($field, $this->record)
|
array_key_exists($field, $this->record)
|
||||||
|| $this->hasDatabaseField($field)
|
|| $this->hasDatabaseField($field)
|
||||||
|
|| array_key_exists($field, $this->db()) // Needed for composite fields
|
||||||
|| $this->hasMethod("get{$field}")
|
|| $this->hasMethod("get{$field}")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,12 @@ class MoneyTest extends SapphireTest {
|
|||||||
|
|
||||||
static $fixture_file = 'sapphire/tests/model/MoneyTest.yml';
|
static $fixture_file = 'sapphire/tests/model/MoneyTest.yml';
|
||||||
|
|
||||||
|
function testMoneyFieldsReturnedAsObjects() {
|
||||||
|
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
||||||
|
$this->assertType('Money', $obj->MyMoney);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function testLoadFromFixture() {
|
function testLoadFromFixture() {
|
||||||
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
||||||
|
|
||||||
@ -32,6 +38,7 @@ class MoneyTest extends SapphireTest {
|
|||||||
$this->assertNotContains('MyMoney', array_keys($changed));
|
$this->assertNotContains('MyMoney', array_keys($changed));
|
||||||
|
|
||||||
// With changes
|
// With changes
|
||||||
|
$this->assertType('Money', $obj->MyMoney);
|
||||||
$obj->MyMoney->setAmount(99);
|
$obj->MyMoney->setAmount(99);
|
||||||
$changed = $obj->getChangedFields();
|
$changed = $obj->getChangedFields();
|
||||||
$this->assertContains('MyMoney', array_keys($changed));
|
$this->assertContains('MyMoney', array_keys($changed));
|
||||||
|
Loading…
Reference in New Issue
Block a user