Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0.0BETA2
-
Component/s: Mapping Drivers
-
Labels:None
Description
If I have a document which has a EmbeddedDocument and this other name used as the variable name. Thus, when saving but not used by the special reserved name of the variable name. But when read out of the special reserved name is used. so is my EmbeddedDocument always empty when the specific name are different. Furthermore, when I set no specific name for it is also EmbeddedDocument empty.
Example:
/**
* @EmbeddedDocument
*/
class SocialNetworkUser {
/**
* @Int(name="id")
* @var int
*/
protected $id;
/**
* @String(name="fN")
* @var string
*/
protected $firstName;
/**
* @String(name="lN")
* @var string
*/
protected $lastName;
}
/**
* @Document(collection="users")
*/
class User {
/**
* @Id
*/
protected $id;
/**
* @EmbedOne(
* discriminatorField="php",
* discriminatorMap={
* "fbu"="Documents\SocialNetworkUser "
* },
* name="snu",
* cascade={"persist", "remove"}
* )
*/
protected $socialNetworkUser;
}
$user = $this->dm->findOne('Documents\User', array('snu.id' => $this->Facebook->getUser()));
print_r($user->getSocialNetworkUser()):
Documents\SocialNetworkUser Object
(
[id:protected] => // Commented
[firstName:protected] =>
[lastName:protected] =>
)
in Mongo:
Array
(
[_id] => 4c7b4fc3ed1590814d050000
[snu] => Array
(
[id] => // Commented
[firstName] => Thomas
[lastName] => Adam
[php] => fbu
)
)
Correct but should be:
Array
(
[_id] => 4c7b4fc3ed1590814d050000
[snu] => Array
(
[id] => // Commented
[fN] => Thomas
[lN] => Adam
[php] => fbu
)
)
So, basically the name attribute is not being used on embedded documents?