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

Field's name attribute does not work for the update queries

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0.0BETA3
    • Fix Version/s: None
    • Component/s: None
    • 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();
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Başar Aykut
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: