RoboMongo can't use array filters?

流过昼夜 提交于 2019-12-01 20:44:10

问题


Following on from "How to update collection and increment hours for ISO date".

It seem that RoboMongo can't execute a query with an array filter:

This same query if find when executed through the Mongo shell though:

> db.collection.update({
...     "results.score": {
...         "$exists": true
...     }
... }, {
...     "$mul": {
...         "results.$[result].score": 10
...     }
... }, {
...     "arrayFilters": [{
...         "result.score": {
...             "$exists": true
...         }
...     }],
...     "multi": true
... })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

Looking at the logging in the Mongo server, it looks like the query is passed over correctly, but still fails:

D COMMAND  [conn4] run command test.$cmd { update: "collection", updates: [ { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, multi: true, upsert: false } ], ordered: true, $db: "test" }
D -        [conn4] User Assertion: 2:No array filter found for identifier 'result' in path 'results.$[result].score' src\mongo\db\update\update_driver.cpp 132
D WRITE    [conn4] Caught Assertion in update: BadValue: No array filter found for identifier 'result' in path 'results.$[result].score'
I WRITE    [conn4] update test.collection appName: "MongoDB Shell" command: { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, multi: true, upsert: false } exception: No array filter found for identifier 'result' in path 'results.$[result].score' code:BadValue numYields:0 locks:{} 4ms
D REPL     [conn4] Waiting for write concern. OpTime: { ts: Timestamp(0, 0), t: -1 }, write concern: { w: 1, wtimeout: 0 }
I COMMAND  [conn4] command test.$cmd appName: "MongoDB Shell" command: update { update: "collection", updates: [ { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, multi: true, upsert: false } ], ordered: true, $db: "test" } numYields:0 reslen:183 locks:{} protocol:op_command 7ms
D COMMAND  [conn4] run command test.$cmd { getlasterror: 1.0, w: 1.0, $readPreference: { mode: "secondaryPreferred" }, $db: "test" }
I COMMAND  [conn4] command test.$cmd appName: "MongoDB Shell" command: getLastError { getlasterror: 1.0, w: 1.0, $readPreference: { mode: "secondaryPreferred" }, $db: "test" } numYields:0 reslen:169 locks:{} protocol:op_command 0ms

The logs from the shell are different:

D COMMAND  [conn8] run command test.$cmd { update: "collection", ordered: true, $db: "test" }
D STORAGE  [conn8] NamespaceUUIDCache: registered namespace test.collection with UUID a5f7f2ef-a7e3-4189-a9c4-29fdb5a18db9
D QUERY    [conn8] Only one plan is available; it will be run but will not be cached. query: { results.score: { $exists: true } } sort: {} projection: {}, planSummary: COLLSCAN
D STORAGE  [conn8] WT begin_transaction for snapshot id 367
D STORAGE  [conn8] WT commit_transaction for snapshot id 367
D STORAGE  [conn8] WT begin_transaction for snapshot id 368
D STORAGE  [conn8] WT rollback_transaction for snapshot id 368
I WRITE    [conn8] update test.collection appName: "MongoDB Shell" command: { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, arrayFilters: [ { result.score: { $exists: true } } ], multi: true, upsert: false } planSummary: COLLSCAN keysExamined:0 docsExamined:1 nMatched:1 nModified:1 numYields:0 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } 3ms
D REPL     [conn8] Waiting for write concern. OpTime: { ts: Timestamp(0, 0), t: -1 }, write concern: { w: 1, wtimeout: 0 }
I COMMAND  [conn8] command test.$cmd appName: "MongoDB Shell" command: update { update: "collection", ordered: true, $db: "test" } numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_msg 4ms
D COMMAND  [conn8] run command test.$cmd { isMaster: 1.0, forShell: 1.0, $db: "test" }
D NETWORK  [conn8] Starting server-side compression negotiation
D NETWORK  [conn8] Compression negotiation not requested by client
I COMMAND  [conn8] command test.$cmd appName: "MongoDB Shell" command: isMaster { isMaster: 1.0, forShell: 1.0, $db: "test" } numYields:0 reslen:208 locks:{} protocol:op_msg 1ms

I can't see anything that would imply that something is wrong though (other than the assertion failure of course).

  • What's causing RoboMongo to fail where Mongo shell succeeds?
  • Is there anything in these logs that tells me what's wrong?

来源:https://stackoverflow.com/questions/48322834/robomongo-cant-use-array-filters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!