Skip to content

Commit

Permalink
- Forward port from 1.0.8.1 bugfix branch
Browse files Browse the repository at this point in the history
    * Factory & Builder for MongoDBObject always return as DBObject
    * Unit test for reported issue
  • Loading branch information
bwmcadams committed Aug 29, 2010
1 parent 5bbce8c commit 68c52a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions casbah-commons/src/main/scala/MongoDBObject.scala
Expand Up @@ -149,7 +149,7 @@ object MongoDBObject {

}

sealed class MongoDBObjectBuilder extends scala.collection.mutable.Builder[(String, Any), MongoDBObject] {
sealed class MongoDBObjectBuilder extends scala.collection.mutable.Builder[(String, Any), DBObject] {
import com.mongodb.BasicDBObjectBuilder

protected val empty = BasicDBObjectBuilder.start
Expand All @@ -160,7 +160,7 @@ sealed class MongoDBObjectBuilder extends scala.collection.mutable.Builder[(Stri
}

def clear() { elems = empty }
def result: MongoDBObject = new MongoDBObject { val underlying = elems.get }
def result: DBObject = new MongoDBObject { val underlying = elems.get }
}

// vim: set ts=2 sw=2 sts=2 et:
15 changes: 14 additions & 1 deletion casbah-commons/src/test/scala/MongoDBObjectSpec.scala
Expand Up @@ -20,7 +20,7 @@
*/

package com.novus.casbah
package conversions
package test

import com.novus.casbah.commons.Imports._

Expand Down Expand Up @@ -62,6 +62,19 @@ class MongoDBObjectSpec extends Specification with PendingUntilFixed {
c must beSome(List(5, 4, 3, 2, 1))
}
}

"MongoDBObject issues reported by users" should {
"Not break like tommy chheng reported" in {
val q = MongoDBObject.empty

val fields = MongoDBObject("name" -> 1)

// Simple test of Is it a DBObject?
q must haveSuperClass[DBObject]
fields must haveSuperClass[DBObject]
}
}

}


Expand Down

0 comments on commit 68c52a4

Please sign in to comment.