[DOCS-10622] Minor changes to update behavior in 3.6 Created: 02/Aug/17  Updated: 30/Oct/23  Resolved: 23/Oct/17

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 6 years, 16 weeks, 2 days ago
Epic Link: DOCS: 3.6 Server
Story Points: 1

 Description   

In MongoDB 3.6, when the featureCompatibilityVersion is 3.6, we use our new update system implementation, which supports arrayFilters. This system has some minor behavior differences from 3.4 that may be worth documenting in the release notes:

  • Conflict detection is done at parse time, rather than update time. For example, in 3.4, the update

    db.c.update({_id: 0}, {$set: {a: 0}, $unset: {a: true}})
    

    only fails if there is a document with _id=0, but this always fails in 3.6. In 3.4, the update

    db.c.update({_id: 0}, {$set: {a: 0}, $setOnInsert: {a: 1}}, {upsert: true}) 
    

    only fails if there is no document with _id=0 (so a document is inserted), but this always fails in 3.6.

  • New fields are added in lexicographic order, rather than the order they appear in the update statement. For example, in 3.4, the update

    db.c.update({_id: 0}, {$set: {b: 0, a: 0}})
    

    updates the document {_id: 0} to {_id: 0, b: 0, a: 0}. In 3.6, the document will be updated to {_id: 0, a: 0, b: 0}. (Note that since featureCompatibilityVersion is used to gate the new update system, you cannot end up with different field orderings for the document on different members of the replica set.)

  • The array filter identifier syntax is treated as an array update, rather than a fieldname. For example, in 3.4, the update

    db.c.update({_id: 0}, {$unset: {"a.$[]": true}})
    

    updates the document {_id: 0, a: {"$[]": 1}} to {_id: 0}. In 3.6, the update fails because a is not an array.

  • It is illegal to remove a required part of a DBRef using $unset or $rename. See SERVER-29819.

I will leave it to the discretion of the docs team which behavior changes are worth documenting. If you have any concerns about a backwards-breaking change, or any questions, feel free to reach out.



 Comments   
Comment by Githook User [ 23/Oct/17 ]

Author:

{'email': 'kevin.albertson@10gen.com', 'name': 'Kevin Albertson', 'username': 'kevinAlbs'}

Message: DOCS-10622 add release note about update changes
Branch: master
https://github.com/mongodb/docs/commit/7407291fdc17f49a035a4b096ab00d0e2d94136e

Comment by Kevin Albertson [ 20/Oct/17 ]

Thanks Charlie. As it happens:

db.test.insert({a: {"$[]": 1}})

doesn't work because the shell does some validation.
But:

db.runCommand({insert: "test", documents: [{"a": {"$[]": 1}}]})

does work. I'll document this behavior.

Comment by Charlie Swanson [ 20/Oct/17 ]

kevin.albertson it is possible if it is inserted as a field name within a nested document. Our field validation only checks top-level fields I think, though we document that any $-prefixed field name is disallowed.

Comment by Kevin Albertson [ 19/Oct/17 ]

tess.avitabile Is it possible to insert a document with the key "$[]"? I was unable to in 3.4 and 3.6.

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