From 692114ec5461e04880961aee41c00a8dc711fc37 Mon Sep 17 00:00:00 2001 From: Benjamin Rewis <32186188+benjirewis@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:57:20 -0400 Subject: [PATCH] GODRIVER-852 Add documentation warning against the use of duplicate key names (#614) --- bson/bson.go | 2 ++ bson/doc.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bson/bson.go b/bson/bson.go index ae1a87faa7..0c739dd0ac 100644 --- a/bson/bson.go +++ b/bson/bson.go @@ -25,6 +25,8 @@ type Zeroer interface { // D is an ordered representation of a BSON document. This type should be used when the order of the elements matters, // such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead. // +// A D should not be constructed with duplicate key names, as that can cause undefined server behavior. +// // Example usage: // // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} diff --git a/bson/doc.go b/bson/doc.go index 16341568dc..07ba9d8f84 100644 --- a/bson/doc.go +++ b/bson/doc.go @@ -29,6 +29,8 @@ // slice and M is a map. For more information about the use cases for these types, see the documentation on the type // definitions. // +// Note that a D should not be constructed with duplicate key names, as that can cause undefined server behavior. +// // Example: // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} // bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}