This repository was archived by the owner on Jan 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
casbah-commons/src/main/scala
casbah-query/src/test/scala Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -91,12 +91,11 @@ class MongoDBObject(val underlying: DBObject = new BasicDBObject) extends mutabl
9191 }
9292 }
9393
94- // scalastyle:off null
95- override def get (key : String ): Option [AnyRef ] = underlying.get(key) match {
96- case null => None
97- case value => Some (value)
98- }
99- // scalastyle:on null
94+ override def get (key : String ): Option [AnyRef ] =
95+ /* underlying.get returns null both when the value is missing and when
96+ * it is null. Unlike nulls, Options can be nested, so we can allow clients
97+ * to see the difference. */
98+ Option (underlying.get(key)).orElse(if (containsField(key)) Some (None ) else None )
10099
101100 // scalastyle:off method.name
102101 def ++ (pairs : (String , Any )* ): DBObject = {
@@ -170,6 +169,7 @@ class MongoDBObject(val underlying: DBObject = new BasicDBObject) extends mutabl
170169 case (tryObj, n) =>
171170 tryObj.flatMap(obj => Try (obj.get(n).get.asInstanceOf [DBObject ]))
172171 }
172+
173173 val res = tryLeaf.flatMap(obj => Try (obj.get(path.last).get.asInstanceOf [A ])) match {
174174 case Success (list : BasicDBList ) => Some (new MongoDBList (list))
175175 case Success (x) => Some (x)
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ class DSLCoreOperatorsSpec extends CasbahMutableSpecification {
155155 timeQuery must haveEntry(" foo.$ne" -> timestamp)
156156 }
157157
158- " Accept a right hand value of None" in skipped {
158+ " Accept a right hand value of None" in {
159159 val neQuery = " foo" $ne None
160160 neQuery must haveEntry(" foo.$ne" -> None )
161161 }
You can’t perform that action at this time.
0 commit comments