Skip to content

Commit d87ab17

Browse files
committed
Merge pull request #1427 from alcaeus/fix-simple-mapping
Store simple field in mapping
2 parents 3e61ecf + 43e382b commit d87ab17

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,9 @@ public function mapField(array $mapping)
12991299
if (isset($mapping['simple']) && ($mapping['simple'] === true || $mapping['simple'] === 'true')) {
13001300
$mapping['storeAs'] = ClassMetadataInfo::REFERENCE_STORE_AS_ID;
13011301
}
1302-
// Remove the "simple" mapping and use "storeAs" in all further logic
1303-
if (isset($mapping['simple'])) {
1304-
unset($mapping['simple']);
1302+
// Provide the correct value for the "simple" field for backwards compatibility
1303+
if (isset($mapping['storeAs'])) {
1304+
$mapping['simple'] = $mapping['storeAs'] === ClassMetadataInfo::REFERENCE_STORE_AS_ID;
13051305
}
13061306

13071307
if (isset($mapping['reference'])

tests/Doctrine/ODM/MongoDB/Tests/Mapping/Driver/AbstractDriverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public function testDriver()
142142
'type' => 'one',
143143
'reference' => true,
144144
'storeAs' => ClassMetadataInfo::REFERENCE_STORE_AS_ID,
145+
'simple' => true,
145146
'targetDocument' => 'Documents\Profile',
146147
'cascade' => array('remove', 'persist', 'refresh', 'merge', 'detach'),
147148
'isCascadeDetach' => true,
@@ -168,6 +169,7 @@ public function testDriver()
168169
'type' => 'one',
169170
'reference' => true,
170171
'storeAs' => ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB,
172+
'simple' => false,
171173
'targetDocument' => 'Documents\Account',
172174
'cascade' => array('remove', 'persist', 'refresh', 'merge', 'detach'),
173175
'isCascadeDetach' => true,
@@ -194,6 +196,7 @@ public function testDriver()
194196
'type' => 'many',
195197
'reference' => true,
196198
'storeAs' => ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB,
199+
'simple' => false,
197200
'targetDocument' => 'Documents\Group',
198201
'cascade' => array('remove', 'persist', 'refresh', 'merge', 'detach'),
199202
'isCascadeDetach' => true,

0 commit comments

Comments
 (0)