Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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?)
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.