[MODM-138] Field's name attribute does not work for the update queries Created: 07/Apr/11 Updated: 07/Apr/11 |
|
| Status: | Open |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | 1.0.0BETA3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Başar Aykut | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Documents class Test
{
.
.
.
/**
* @EmbedOne(targetDocument="Location", name="l")
*/
private $location;
.
.
.
}
/** @EmbeddedDocument */
class Location
{
/**
* @Field(type="float", name="y")
*/
public $lat;
/**
* @Field(type="float", name="x")
*/
public $lng;
public function __construct($latitude,$longitude) {
$this->lat = $latitude;
$this->lng = $longitude;
}
}
Update query: $dm->createQueryBuilder('Test')
->update()
->field('id')->equals(123)
->field('l')->set(new Location(39, 32);
->getQuery(array('upsert' => true))
->execute();
Result of this query is "l": { "lat": 39, "lng": 32 }, however, it should be "l": { "y": 39, "x": 32 }, also field function can support field name of the class on update queries, as follows $dm->createQueryBuilder('Test')
->update()
->field('id')->equals(123)
->field('location')->set(new Location(39, 32);
->getQuery(array('upsert' => true))
->execute();
|