I'm going over a project I've taken over which is crashing in this 
doctrine/mongoDB query:



    /**
     * Deactivate all Device documents via set 'activate = false' and 
unsetting 
     * passenger field for all devices that has passenger = $oPassenger 
     * and Device._id != oDevice
     * @param Document\Device $oDevice
     * @param Document\Passenger $oPassenger
     */
    public function deactivateDuplicateDevices(Document\Device $oDevice,
                                               Document\Passenger 
$oPassenger)
    {
        $passengerId = new \MongoId($oPassenger->getId());
        $deviceId = new \MongoId($oDevice->getId());

        return $this->createQueryBuilder('Device')
            ->update()
            ->multiple(true)
            ->field('activated')->set(false)
            ->field('passenger')->unsetField()->equals($passengerId)
            ->field('_id')->notEqual($deviceId)
            ->getQuery()
            ->execute();
    }

it seems to me that the author is running multiple queries on the same 
document ie
find all documents where

- passenger == passengerId AND

- device != deviceId

I'm trying to recreate this query piece by piece  (in JSON and running it 
on the mongo console) to see where the problem is. this is the final input 
I got (to the mongo initiated, this may seem absurd.. but please bear with 
me):

    db.Device.update(
    {
    passenger:{
    $ne: "538c6eac3c0ab224080041aa"
      }
    },
    {
    _id:{
    $ne: "538eb8d205dafff40a0041ad"
    } 
    }
    {
    $unset:{ 
    passenger:""
    }
    },
    {
    $set:
    {
    activated:false
    }
    } 
    )
        

I wanted to test the first part, namely the multiple queries (obviously 
searching for passenger alone and _id alone work.. but when i combine them):

db.Device.find({
_id:{
$ne:ObjectId("538eb8d205dafff40a0041ad")
}
}, 
{
passenger:{
$ne:"538c6eac3c0ab224080041aa"
}
} 
)

I get this error:

    error: {
    "$err" : "Can't canonicalize query: BadValue Unsupported projection 
option: passenger: { $ne: \"538c6eac3c0ab224080041aa\" }",
    "code" : 17287
    }

any idea what i'm doing wrong here?


-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to