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

Unexpected: MappedSuperclass private property without annotation becomes persisted

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0ALPHA1
    • Fix Version/s: 1.0.0ALPHA1
    • Component/s: None
    • Labels:
      None
    • Environment:
      OS X, latest ODM checkout

      Description

      /** @MappedSuperclass */
      class Model {
      
          private $errors = array();
      
          protected function getErrors() {
              return $this->errors;
          }
      }
      
      /**
       * @Document(db="mydb", collection="data")
       */
      class Data extends Model {
          /**
           * @Id
           */
          public $id;
      
          /**
           * @String
           */
          public $name;
      }
      

      Did not expect, that $errors goes into mongo.

        Activity

        Hide
        Jonathan H. Wage added a comment -

        Thanks. I have updated the documentation with the new @Transient annotation.

        Show
        Jonathan H. Wage added a comment - Thanks. I have updated the documentation with the new @Transient annotation.
        Hide
        Florian Kubis added a comment -

        Thanks, this works.
        Just to complete this issue, for now documentation of @Transient is missing in the reference.
        http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/annotations-reference/en

        Show
        Florian Kubis added a comment - Thanks, this works. Just to complete this issue, for now documentation of @Transient is missing in the reference. http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/annotations-reference/en
        Hide
        Jonathan H. Wage added a comment -

        This is expected behavior. It was changed so that all properties are persisted unless specified otherwise. Map the property is @Transient and it will be ignored by Doctrine:

        class MyDocument
        {
            // ...
        
            /** @Transient */
            private $errors = array();
        }
        
        Show
        Jonathan H. Wage added a comment - This is expected behavior. It was changed so that all properties are persisted unless specified otherwise. Map the property is @Transient and it will be ignored by Doctrine: class MyDocument { // ... /** @Transient */ private $errors = array(); }

          People

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

            Dates

            • Created:
              Updated:
              Resolved: