Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.0.0BETA1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:CentOS 5.5, PHP 5.3
Description
It looks like that "name" attribute is not supported anymore in @Field annotation
http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/annotations-reference/en#ann_field
> name - By default the property name is used for the mongodb field name also, however the 'name' attribute allows you to specify the field name.
For instance the code below produces a document inside "mydocs" collection which has only one property "first_name" instead of two:
/** @Document(collection="mydocs") */
class MyDocument
{
/** @Id */
public $id;
/** @Field(type="string") */
public $first_name;
/** @Field(type="string", name="last_name") */
protected $_last_name;
public function __get($propertyName)
{
return $this->
}
public function __set($propertyName, $propertyValue)
{
$this->{'_'.$propertyName}
= $propertyValue;
}
}
$doc = new MyDocument();
$doc->first_name = 'aaa';
$doc->last_name = 'bbb';
dm()->persist($doc);
dm()->flush();
I added a test here for your issue and it appears to be working properly in the latest master in git.
https://github.com/doctrine/mongodb-odm/commit/cb1cbd2e81b8912dd5959f1d6275443679959a86