File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ extension (bv: BsonValue)
76
76
*
77
77
* In a case of key collision bson1 values takes priority
78
78
*/
79
- @ inline def :+ (other : BsonValue ): BsonValue = merge(other, bv , false )
79
+ @ inline def :+ (other : BsonValue ): BsonValue = merge(bv, other , false )
80
80
81
81
/**
82
82
* Merges two bson values
Original file line number Diff line number Diff line change
1
+ package oolong .bson
2
+
3
+ import org .mongodb .scala .bson .*
4
+ import org .scalatest .funsuite .AnyFunSuite
5
+ import org .scalatest .matchers .should .Matchers
6
+
7
+ class BsonMergeSpec extends AnyFunSuite with Matchers {
8
+ test(" :+ document merge" ) {
9
+ val doc1 = BsonDocument (" field1" -> 10 , " field2" -> 30 )
10
+ val doc2 = BsonDocument (" field1" -> 20 , " field3" -> 40 )
11
+
12
+ val res = doc1 :+ doc2
13
+
14
+ res shouldBe BsonDocument (" field1" -> 10 , " field2" -> 30 , " field3" -> 40 )
15
+ }
16
+
17
+ test(" +: document merge" ) {
18
+ val doc1 = BsonDocument (" field1" -> 10 , " field2" -> 30 )
19
+ val doc2 = BsonDocument (" field1" -> 20 , " field3" -> 40 )
20
+
21
+ val res = doc1 +: doc2
22
+
23
+ res shouldBe BsonDocument (" field1" -> 20 , " field2" -> 30 , " field3" -> 40 )
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments