Skip to content

Commit 1ffe08d

Browse files
committed
Add warning in Scala documentation against the use of duplicate key names
JAVA-3547
1 parent 3835b14 commit 1ffe08d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/reference/content/driver-scala/bson/documents.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ there are immutable and mutable implementations of documents. The underlying imp
1616
namespace, which includes type aliases and companion objects. In general this should suffice but for advanced use cases you may need to
1717
use `org.bson` directly.
1818

19+
{{% note class="important" %}}
20+
21+
The server's behavior related to duplicate key names in a document is undefined. When a
22+
document with duplicate key names is decoded, the driver will assign the last
23+
value associated with the duplicate key. Storing such a document will cause
24+
the other values to be lost.
25+
26+
{{% /note %}}
27+
1928
{{% note %}}
2029
The scala `Document` classes implement `TraversableLike[(String, BsonValue)]` and the general API mirrors that of a `Map[String, BsonValue]`.
2130
However, unlike `Map` implementations of `TraversableLike` enables strict type safety as there is no variance in the value type.

0 commit comments

Comments
 (0)