[SERVER-23632] Take field value from $setOnInsert when it cannot be inferred otherwise Created: 11/Apr/16  Updated: 06/Dec/22  Resolved: 15/Apr/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Sietse de Kaper Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13843 Upsert fails with error when query do... Backlog
Assigned Teams:
Query
Participants:

 Description   

Take the following update:

db.test.update(
  {"someField" : {"$all": ["a", "b"]}}, 
  {"$addToSet": {"someOtherField": 123}, 
    "$setOnInsert": {"someField": ["a", "b"]}},
  {"upsert": true})

This results in the following error, because of the $all query:

"writeError" : {
  "code" : 54,
  "errmsg" : "cannot infer query fields to set, path 'someField' is matched twice"}

Given that I explicitly stated what I want the value for someField to be using $setOnInsert, it doesn't have to be a problem that the value can't be inferred from the query. It could just use value I specified as a fallback for inference, or even instead of inference.



 Comments   
Comment by J Rassi [ 15/Apr/16 ]

I'm closing this as a dup of SERVER-13843. Please add yourself as a watcher to that ticket for updates on the resolution of this issue.

Generated at Thu Feb 08 04:03:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.