Details
-
Bug
-
Resolution: Works as Designed
-
Major - P3
-
None
-
1.4.4
-
None
-
Linux 4.14
Description
This fails:
|
|
update := bson.D{
|
|
|
{"$set", f},
|
|
|
{"$addToSet", bson.E{"outsideIp", "string"}},
|
|
|
}
|
|
|
|
|
|
updateResult, err := collection.UpdateOne(context.TODO(), filter, update)
|
|
This works:
|
|
update := bson.D{
|
|
|
{"$set", f},
|
|
|
}
|
|
|
|
|
|
updateResult, err := collection.UpdateOne(context.TODO(), filter, update)
|
|
Here is the error message:
|
|
multiple write errors: [\{write errors: [{Cannot apply $addToSet to non-array field. Field named 'key' has non-array type string}]}, \{<nil>}]
|
|
I only want to use $addToSet with a single string, as documented in the mongodb docs:
|
|
db.inventory.update( { _id: 1 }, { $addToSet: { tags: "accessories" } } )
|
|
What's going on here?
Attachments
Issue Links
- is duplicated by
-
GODRIVER-1820 CLONE - BSON encoding, passing single string to $addToSet field
-
- Closed
-
-
GODRIVER-1821 Different with $addToSet in NodeJS and Go drivers
-
- Closed
-
- related to
-
GODRIVER-1819 BSON encoding, passing single string to $addToSet field
-
- Closed
-