Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-18

All Document object properties are persisted regardless of mapping instructions.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0ALPHA1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      ubuntu, php 5.3.2, odm 1.0.0ALPHA1

      Description

      User Model
      class Users_Model_User
      {
          public $id;
          public $username;
          public $password;
          public $myRuntimeProperty = 'some value';
      }
      
      Document Mapping (in YAML)
      Users_Model_User:
      db: my_db
      collection: users
      fields:
          id:
              fieldName: id
              id: true
          username:
              fieldName: username
              type: string
          password:
              fieldName: password
              type: string
      
      My test code
      $user = new Users_Model_User;
      $user->username = 'hello';
      $user->password = 'world';
      $this->dm->persist($user);
      $this->dm->flush();
      

      The result is "myRuntimeProperty" is saved to the db.
      This causes problems for several properties such as "_propertyChangedListeners" which, once saved and later loaded back from the database, overrides the array of object listeners with a string of "Array"

      If this is not a bug:
      I have search everywhere for an answer. All the docs, mailing list, irc, blogs. If this is not a bug the solution needs to be better documented.

      Temporary fix:
      Use Docblock Annotations, set the unwanted properties with @NotSaved
      (Unless there is also a way to set NotSaved using YAML?)

        Activity

        Hide
        Rabbit added a comment -

        I see how I was mistaken on this issue.

        Conceptually, marking any property as "transient" therefore preventing the data from persisting makes sense. In practice, I wonder if it would be possible to set the default behavior to transient on all fields unless otherwise stated.

        Show
        Rabbit added a comment - I see how I was mistaken on this issue. Conceptually, marking any property as "transient" therefore preventing the data from persisting makes sense. In practice, I wonder if it would be possible to set the default behavior to transient on all fields unless otherwise stated.
        Hide
        Jonathan H. Wage added a comment -

        Right now it cannot be customized. It always persist every property unless otherwise specified.

        Show
        Jonathan H. Wage added a comment - Right now it cannot be customized. It always persist every property unless otherwise specified.
        Hide
        Bulat Shakirzyanov added a comment -

        this should be resolved in the current trunk

        Show
        Bulat Shakirzyanov added a comment - this should be resolved in the current trunk
        Hide
        Bulat Shakirzyanov added a comment -

        all the magic was removed

        Show
        Bulat Shakirzyanov added a comment - all the magic was removed

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Rabbit
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: