[GODRIVER-1796] Upsert with $inc: write errors: '$inc' is not valid for storage Created: 17/Nov/20 Updated: 27/Oct/23 Resolved: 19/Nov/20 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | 1.4.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Rubi N/A | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 20.04 |
||
| Description |
|
given this code with update data :
resulting in error :
but when i disable the upsert, the error gone |
| Comments |
| Comment by Kevin Albertson [ 19/Nov/20 ] | |
|
Hello jihantoro8@gmail.com! Thank you for your interest in MongoDB's Go driver. I do not believe this is a Go driver issue. This is a current limitation in MongoDB servers. Top-level fields cannot start with a "$" character. See https://docs.mongodb.com/manual/reference/limits/#naming-restrictions for more information. For example, you can reproduce the same error in the shell by running a raw update command:
Gives back an error containing "The dollar ($) prefixed field '$inc' in '$inc' is not valid for storage."
That makes sense. If the filter does not match anything, and upsert is false, then nothing is updated or inserted. Since this isn't a bug or feature request we're closing the issue. For further assistance please create a post in our community forum here |