Details

      Description

      If I try to select a couple of documents with the in() query, I receive an empty result set when the selected field is the document id.

      The following code works fine and selects the right document:

             $query = $dm->createQueryBuilder("Object\Does\Not\Matter")
                         ->field("id")->equals("4d1db8ba2d8aa162300a0000")
                         ->getQuery()->execute();
      

      Whereas the following query returns nothing:

             $query = $dm->createQueryBuilder("Object\Does\Not\Matter")
                         ->field("id")->in(array("4d1db8ba2d8aa162300a0000"))
                         ->getQuery()->execute();
      

        Activity

        Hide
        Jonathan H. Wage added a comment -

        This should be fixed in the latest version in github. I resolved the issues with converting the different types of query parameters

        Show
        Jonathan H. Wage added a comment - This should be fixed in the latest version in github. I resolved the issues with converting the different types of query parameters
        Hide
        Vladimir Razuvaev added a comment -

        This is not fixed actually, as there is other issue in DocumentPersister::prepareQueryValue method, unrelated to type converting.

        e.g. following call will produce unexpectable result:

        $result = $persister->prepareQueryValue('_id', array('$in' => array(new \MongoId('some_id'))));
        // will produce new \MongoId() instead of original array
        

        That's because prepareQueryValue always transforms value for '_id' field to scalar, even if it was originally array, containing $in.

        Show
        Vladimir Razuvaev added a comment - This is not fixed actually, as there is other issue in DocumentPersister::prepareQueryValue method, unrelated to type converting. e.g. following call will produce unexpectable result: $result = $persister->prepareQueryValue('_id', array('$in' => array( new \MongoId('some_id')))); // will produce new \MongoId() instead of original array That's because prepareQueryValue always transforms value for '_id' field to scalar, even if it was originally array, containing $in.
        Show
        Jonathan H. Wage added a comment - I see better now. I fixed it here https://github.com/doctrine/mongodb-odm/commit/199cab760a7b3cc6a5050111c25e47d4788b310f

          People

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

            Dates

            • Created:
              Updated:
              Resolved: