[MODM-9] Unexpected: MappedSuperclass private property without annotation becomes persisted Created: 03/Jun/10  Updated: 09/Jun/10  Resolved: 03/Jun/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA1

Type: Bug Priority: Minor
Reporter: Florian Kubis Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
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.



 Comments   
Comment by Jonathan H. Wage [ 03/Jun/10 ]

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();
}
Comment by Florian Kubis [ 04/Jun/10 ]

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

Comment by Jonathan H. Wage [ 04/Jun/10 ]

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

Generated at Tue Sep 02 21:41:09 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.