Uploaded image for project: 'Doctrine MongoDB ODM'
  1. Doctrine MongoDB ODM
  2. MODM-65

EmbeddedDocument - Incorrect assignment of special field names on save

    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
              )
      )
      
      

        Activity

        Hide
        jwage Jonathan H. Wage added a comment -

        So, basically the name attribute is not being used on embedded documents?

        Show
        jwage Jonathan H. Wage added a comment - So, basically the name attribute is not being used on embedded documents?
        Hide
        tecbot Thomas Adam added a comment -

        Correct. But when read out of data it is used the name attribute.

        Show
        tecbot Thomas Adam added a comment - Correct. But when read out of data it is used the name attribute.
        Show
        jwage Jonathan H. Wage added a comment - Fixed here http://github.com/doctrine/mongodb-odm/commit/3331a91fc628cc2196bcbdc4bbed91d6faa743d3 Thanks, Jon

          People

          • Assignee:
            jwage Jonathan H. Wage
            Reporter:
            tecbot Thomas Adam
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: