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

DocumentPersister's prepareQuery() method is not suitable for preparing newObj for update queries

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Persister
    • Labels:
      None

      Description

      Doctrine\ODM\MongoDB\Query\Expr::getNewObj() uses Doctrine\ODM\MongoDB\Persisters\DocumentPersister::prepareQuery() method for preparing newObj. However, prepareQuery is not suitable for that.

      The first lines in prepareQuery method should apply to find queries only:


      if (is_scalar($query) || $query instanceof \MongoId) {
      $query = array('_id' => $query);
      }
      if ($this->class->hasDiscriminator() && ! isset($query[$this->class->discriminatorField['name']])) {
      $discriminatorValues = $this->getClassDiscriminatorValues($this->class);
      $query[$this->class->discriminatorField['name']] = array('$in' => $discriminatorValues);
      }


      Recommendation: DocumentPersister should introduce a new method, such as prepareNewObj($newObj) for preparing the newObj array. Expr::getNewObj() should be change to invoke the new method.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Juha Suni
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: