Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change mongodb.fields' type param to BsonRecord

  • Loading branch information...
commit cad135a7f5a3870880d3a5fc52b149a0fd3653e5 1 parent d7daee7
@eltimn eltimn authored
Showing with 219 additions and 42 deletions.
  1. +2 −2 persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/BsonRecordField.scala
  2. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/DBRefField.scala
  3. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/DateField.scala
  4. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/JsonObjectField.scala
  5. +3 −3 persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoListField.scala
  6. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoMapField.scala
  7. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoPasswordField.scala
  8. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/ObjectIdField.scala
  9. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/PatternField.scala
  10. +1 −1  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/UUIDField.scala
  11. +25 −8 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/Fixtures.scala
  12. +112 −14 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoFieldSpec.scala
  13. +69 −7 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordSpec.scala
View
4 ...ence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/BsonRecordField.scala
@@ -31,7 +31,7 @@ import com.mongodb._
import scala.xml._
/** Field that contains an entire record represented as an inline object value. Inspired by JSONSubRecordField */
-class BsonRecordField[OwnerType <: MongoRecord[OwnerType], SubRecordType <: BsonRecord[SubRecordType]]
+class BsonRecordField[OwnerType <: BsonRecord[OwnerType], SubRecordType <: BsonRecord[SubRecordType]]
(rec: OwnerType, valueMeta: BsonMetaRecord[SubRecordType])(implicit subRecordType: Manifest[SubRecordType])
extends Field[SubRecordType, OwnerType]
with MandatoryTypedField[SubRecordType]
@@ -75,7 +75,7 @@ class BsonRecordField[OwnerType <: MongoRecord[OwnerType], SubRecordType <: Bson
/*
* List of BsonRecords
*/
-class BsonRecordListField[OwnerType <: MongoRecord[OwnerType], SubRecordType <: BsonRecord[SubRecordType]]
+class BsonRecordListField[OwnerType <: BsonRecord[OwnerType], SubRecordType <: BsonRecord[SubRecordType]]
(rec: OwnerType, valueMeta: BsonMetaRecord[SubRecordType])
extends MongoListField[OwnerType, SubRecordType](rec: OwnerType) {
View
2  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/DBRefField.scala
@@ -32,7 +32,7 @@ import org.bson.types.ObjectId
/*
* Field for storing a DBRef
*/
-class DBRefField[OwnerType <: MongoRecord[OwnerType], RefType <: MongoRecord[RefType]](rec: OwnerType, ref: RefType)
+class DBRefField[OwnerType <: BsonRecord[OwnerType], RefType <: MongoRecord[RefType]](rec: OwnerType, ref: RefType)
extends Field[DBRef, OwnerType] with MandatoryTypedField[DBRef] {
/*
View
2  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/DateField.scala
@@ -32,7 +32,7 @@ import net.liftweb.util.Helpers._
/*
* Since MongoDB only stores UTC dates, Calendar data is not necessary.
*/
-class DateField[OwnerType <: MongoRecord[OwnerType]](rec: OwnerType)
+class DateField[OwnerType <: BsonRecord[OwnerType]](rec: OwnerType)
extends Field[Date, OwnerType]
with MandatoryTypedField[Date]
{
View
2  ...ence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/JsonObjectField.scala
@@ -28,7 +28,7 @@ import net.liftweb.util.Helpers.tryo
import com.mongodb.DBObject
-abstract class JsonObjectField[OwnerType <: MongoRecord[OwnerType], JObjectType <: JsonObject[JObjectType]]
+abstract class JsonObjectField[OwnerType <: BsonRecord[OwnerType], JObjectType <: JsonObject[JObjectType]]
(rec: OwnerType, valueMeta: JsonObjectMeta[JObjectType])
extends Field[JObjectType, OwnerType] with MandatoryTypedField[JObjectType] with MongoFieldFlavor[JObjectType] {
View
6 ...tence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoListField.scala
@@ -37,7 +37,7 @@ import org.bson.types.ObjectId
* List field. Compatible with most object types,
* including Pattern, ObjectId, Date, and UUID.
*/
-class MongoListField[OwnerType <: MongoRecord[OwnerType], ListType](rec: OwnerType)
+class MongoListField[OwnerType <: BsonRecord[OwnerType], ListType](rec: OwnerType)
extends Field[List[ListType], OwnerType]
with MandatoryTypedField[List[ListType]]
with MongoFieldFlavor[List[ListType]]
@@ -112,14 +112,14 @@ class MongoListField[OwnerType <: MongoRecord[OwnerType], ListType](rec: OwnerTy
* List of Dates. Use MongListField[OwnerType, Date] instead.
*/
@deprecated("Use MongListField[OwnerType, Date] instead")
-class MongoDateListField[OwnerType <: MongoRecord[OwnerType]](rec: OwnerType)
+class MongoDateListField[OwnerType <: BsonRecord[OwnerType]](rec: OwnerType)
extends MongoListField[OwnerType, Date](rec: OwnerType) {
}
/*
* List of JsonObject case classes
*/
-class MongoJsonObjectListField[OwnerType <: MongoRecord[OwnerType], JObjectType <: JsonObject[JObjectType]]
+class MongoJsonObjectListField[OwnerType <: BsonRecord[OwnerType], JObjectType <: JsonObject[JObjectType]]
(rec: OwnerType, valueMeta: JsonObjectMeta[JObjectType])
extends MongoListField[OwnerType, JObjectType](rec: OwnerType) {
View
2  ...stence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoMapField.scala
@@ -30,7 +30,7 @@ import net.liftweb.util.Helpers.tryo
import com.mongodb._
-class MongoMapField[OwnerType <: MongoRecord[OwnerType], MapValueType](rec: OwnerType)
+class MongoMapField[OwnerType <: BsonRecord[OwnerType], MapValueType](rec: OwnerType)
extends Field[Map[String, MapValueType], OwnerType] with MandatoryTypedField[Map[String, MapValueType]]
with MongoFieldFlavor[Map[String, MapValueType]] {
View
2  ...e/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/MongoPasswordField.scala
@@ -43,7 +43,7 @@ object MongoPasswordField {
def encrypt(s: String, salt: String) = hash("{"+s+"} salt={" + salt + "}")
}
-class MongoPasswordField[OwnerType <: MongoRecord[OwnerType]](rec: OwnerType, minLen: Int) extends JsonObjectField[OwnerType, Password](rec, Password) {
+class MongoPasswordField[OwnerType <: BsonRecord[OwnerType]](rec: OwnerType, minLen: Int) extends JsonObjectField[OwnerType, Password](rec, Password) {
def this(rec: OwnerType) = {
this(rec, 3)
View
2  ...stence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/ObjectIdField.scala
@@ -34,7 +34,7 @@ import org.bson.types.ObjectId
/*
* Field for storing an ObjectId
*/
-class ObjectIdField[OwnerType <: MongoRecord[OwnerType]](rec: OwnerType)
+class ObjectIdField[OwnerType <: BsonRecord[OwnerType]](rec: OwnerType)
extends Field[ObjectId, OwnerType]
with MandatoryTypedField[ObjectId]
{
View
2  ...istence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/PatternField.scala
@@ -26,7 +26,7 @@ import net.liftweb.mongodb.record._
import net.liftweb.record.{Field, FieldHelpers, MandatoryTypedField}
import net.liftweb.util.Helpers.tryo
-class PatternField[OwnerType <: MongoRecord[OwnerType]](rec: OwnerType)
+class PatternField[OwnerType <: BsonRecord[OwnerType]](rec: OwnerType)
extends Field[Pattern, OwnerType]
with MandatoryTypedField[Pattern]
{
View
2  persistence/mongodb-record/src/main/scala/net/liftweb/mongodb/record/field/UUIDField.scala
@@ -29,7 +29,7 @@ import net.liftweb.mongodb.record._
import net.liftweb.record.{Field, FieldHelpers, MandatoryTypedField}
import net.liftweb.util.Helpers._
-class UUIDField[OwnerType <: MongoRecord[OwnerType]](rec: OwnerType)
+class UUIDField[OwnerType <: BsonRecord[OwnerType]](rec: OwnerType)
extends Field[UUID, OwnerType]
with MandatoryTypedField[UUID]
{
View
33 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/Fixtures.scala
@@ -298,10 +298,17 @@ class SubRecord extends BsonRecord[SubRecord] {
def meta = SubRecord
object name extends StringField(this, 12)
+ object subsub extends BsonRecordField(this, SubSubRecord)
+ object subsublist extends BsonRecordListField(this, SubSubRecord)
+ object when extends DateField(this)
+ object slist extends MongoListField[SubRecord, String](this)
+ object smap extends MongoMapField[SubRecord, String](this)
+ object oid extends ObjectIdField(this)
+ object pattern extends PatternField(this)
+ object uuid extends UUIDField(this)
override def equals(other: Any): Boolean = other match {
- case that:SubRecord =>
- this.name.value == that.name.value
+ case that:SubRecord => this.toString == that.toString
case _ => false
}
}
@@ -309,6 +316,21 @@ object SubRecord extends SubRecord with BsonMetaRecord[SubRecord] {
override def formats = allFormats
}
+class SubSubRecord extends BsonRecord[SubSubRecord] {
+ def meta = SubSubRecord
+
+ object name extends StringField(this, 12)
+
+ override def equals(other: Any): Boolean = other match {
+ case that:SubSubRecord =>
+ this.name.value == that.name.value
+ case _ => false
+ }
+}
+object SubSubRecord extends SubSubRecord with BsonMetaRecord[SubSubRecord] {
+ override def formats = allFormats
+}
+
class SubRecordTestRecord extends MongoRecord[SubRecordTestRecord] with MongoId[SubRecordTestRecord] {
def meta = SubRecordTestRecord
@@ -323,12 +345,7 @@ class SubRecordTestRecord extends MongoRecord[SubRecordTestRecord] with MongoId[
}
override def equals(other: Any): Boolean = other match {
- case that:SubRecordTestRecord =>
- this.id == that.id &&
- this.mandatoryBsonRecordField.value == that.mandatoryBsonRecordField.value &&
- this.legacyOptionalBsonRecordField.valueBox == that.legacyOptionalBsonRecordField.valueBox &&
- this.mandatoryBsonRecordListField.value == that.mandatoryBsonRecordListField.value &&
- this.legacyOptionalBsonRecordListField.valueBox == that.legacyOptionalBsonRecordListField.valueBox
+ case that:SubRecordTestRecord => this.toString == that.toString
case _ => false
}
View
126 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoFieldSpec.scala
@@ -28,7 +28,7 @@ import org.bson.types.ObjectId
import org.specs.Specification
import common._
-import json.JsonAST._
+import json.{Num => JsonNum, _}
import util.FieldError
import util.Helpers.randomString
import http.{LiftSession, S}
@@ -43,14 +43,12 @@ import net.liftweb.record._
object MongoFieldSpec extends Specification("MongoField Specification") with MongoTestKit {
import fixtures._
- def passBasicTests[A](example: A, mandatory: MandatoryTypedField[A], legacyOptional: MandatoryTypedField[A])(implicit m: scala.reflect.Manifest[A]): Unit = {
-
- val canCheckDefaultValues =
- !mandatory.defaultValue.isInstanceOf[Date] && // don't try to use the default value of date/time typed fields, because it changes from moment to moment!
- !mandatory.defaultValue.isInstanceOf[ObjectId] && // same with ObjectId
- !mandatory.defaultValue.isInstanceOf[Pattern] &&
- !mandatory.defaultValue.isInstanceOf[UUID] &&
- !mandatory.defaultValue.isInstanceOf[DBRef]
+ def passBasicTests[A](
+ example: A,
+ mandatory: MandatoryTypedField[A],
+ legacyOptional: MandatoryTypedField[A],
+ canCheckDefaultValues: Boolean = true
+ )(implicit m: scala.reflect.Manifest[A]): Unit = {
def commonBehaviorsForAllFlavors(field: MandatoryTypedField[A]) = {
@@ -180,7 +178,7 @@ object MongoFieldSpec extends Specification("MongoField Specification") with Mon
val rec = MongoFieldTypeTestRecord.createRecord
val now = new Date
val nowStr = rec.meta.formats.dateFormat.format(now)
- passBasicTests(now, rec.mandatoryDateField, rec.legacyOptionalDateField)
+ passBasicTests(now, rec.mandatoryDateField, rec.legacyOptionalDateField, false)
passConversionTests(
now,
rec.mandatoryDateField,
@@ -196,7 +194,7 @@ object MongoFieldSpec extends Specification("MongoField Specification") with Mon
if (isMongoRunning) { // Even if this gets skipped, the vals still get set.
val rec = MongoFieldTypeTestRecord.createRecord
val dbref = DBRefTestRecord.createRecord.getRef // This makes a call to MongoDB.use and needs a MongoDB connection.
- passBasicTests(dbref, rec.mandatoryDBRefField, rec.legacyOptionalDBRefField)
+ passBasicTests(dbref, rec.mandatoryDBRefField, rec.legacyOptionalDBRefField, false)
}
}
@@ -216,7 +214,7 @@ object MongoFieldSpec extends Specification("MongoField Specification") with Mon
"ObjectIdField" should {
val rec = MongoFieldTypeTestRecord.createRecord
val oid = ObjectId.get
- passBasicTests(oid, rec.mandatoryObjectIdField, rec.legacyOptionalObjectIdField)
+ passBasicTests(oid, rec.mandatoryObjectIdField, rec.legacyOptionalObjectIdField, false)
passConversionTests(
oid,
rec.mandatoryObjectIdField,
@@ -229,7 +227,7 @@ object MongoFieldSpec extends Specification("MongoField Specification") with Mon
"PatternField" should {
val rec = MongoFieldTypeTestRecord.createRecord
val ptrn = Pattern.compile("^Mo", Pattern.CASE_INSENSITIVE)
- passBasicTests(ptrn, rec.mandatoryPatternField, rec.legacyOptionalPatternField)
+ passBasicTests(ptrn, rec.mandatoryPatternField, rec.legacyOptionalPatternField, false)
passConversionTests(
ptrn,
rec.mandatoryPatternField,
@@ -242,7 +240,7 @@ object MongoFieldSpec extends Specification("MongoField Specification") with Mon
"UUIDField" should {
val rec = MongoFieldTypeTestRecord.createRecord
val uuid = UUID.randomUUID
- passBasicTests(uuid, rec.mandatoryUUIDField, rec.legacyOptionalUUIDField)
+ passBasicTests(uuid, rec.mandatoryUUIDField, rec.legacyOptionalUUIDField, false)
passConversionTests(
uuid,
rec.mandatoryUUIDField,
@@ -369,5 +367,105 @@ object MongoFieldSpec extends Specification("MongoField Specification") with Mon
)
}
}
+
+ "BsonRecordField" should {
+ "function correctly" in {
+ val rec = SubRecordTestRecord.createRecord
+ val subRec = SubRecord.createRecord.name("subrecord")
+
+ val srJson =
+ JObject(List(
+ JField("name", JString("subrecord")),
+ JField("subsub", JObject(List(
+ JField("name", JString(""))
+ ))),
+ JField("subsublist", JArray(List())),
+ JField("when", JObject(List(
+ JField("$dt", JString(rec.meta.formats.dateFormat.format(subRec.when.value)))
+ ))),
+ JField("slist", JArray(List())),
+ JField("smap", JObject(List())),
+ JField("oid", JObject(List(JField("$oid", JString(subRec.oid.value.toString))))),
+ JField("pattern", JObject(List(
+ JField("$regex", JString(subRec.pattern.value.pattern)),
+ JField("$flags", JInt(subRec.pattern.value.flags))
+ ))),
+ JField("uuid", JObject(List(JField("$uuid", JString(subRec.uuid.value.toString)))))
+ ))
+
+ val srJsExp = new JsExp {
+ def toJsCmd = Printer.compact(render(srJson))
+ }
+
+ passBasicTests(subRec, rec.mandatoryBsonRecordField, rec.legacyOptionalBsonRecordField, false)
+ passConversionTests(
+ subRec,
+ rec.mandatoryBsonRecordField,
+ srJsExp,
+ srJson,
+ Empty
+ )
+ }
+ }
+
+ "BsonRecordListField" should {
+ "function correctly" in {
+ val rec = SubRecordTestRecord.createRecord
+ val lst = List(SubRecord.createRecord.name("subrec1"), SubRecord.createRecord.name("subrec2"))
+ val sr1Json =
+ JObject(List(
+ JField("name", JString("subrec1")),
+ JField("subsub", JObject(List(
+ JField("name", JString(""))
+ ))),
+ JField("subsublist", JArray(List())),
+ JField("when", JObject(List(
+ JField("$dt", JString(rec.meta.formats.dateFormat.format(lst(0).when.value)))
+ ))),
+ JField("slist", JArray(List())),
+ JField("smap", JObject(List())),
+ JField("oid", JObject(List(JField("$oid", JString(lst(0).oid.value.toString))))),
+ JField("pattern", JObject(List(
+ JField("$regex", JString(lst(0).pattern.value.pattern)),
+ JField("$flags", JInt(lst(0).pattern.value.flags))
+ ))),
+ JField("uuid", JObject(List(JField("$uuid", JString(lst(0).uuid.value.toString)))))
+ ))
+ val sr2Json =
+ JObject(List(
+ JField("name", JString("subrec2")),
+ JField("subsub", JObject(List(
+ JField("name", JString(""))
+ ))),
+ JField("subsublist", JArray(List())),
+ JField("when", JObject(List(
+ JField("$dt", JString(rec.meta.formats.dateFormat.format(lst(1).when.value)))
+ ))),
+ JField("slist", JArray(List())),
+ JField("smap", JObject(List())),
+ JField("oid", JObject(List(JField("$oid", JString(lst(1).oid.value.toString))))),
+ JField("pattern", JObject(List(
+ JField("$regex", JString(lst(1).pattern.value.pattern)),
+ JField("$flags", JInt(lst(1).pattern.value.flags))
+ ))),
+ JField("uuid", JObject(List(JField("$uuid", JString(lst(1).uuid.value.toString)))))
+ ))
+ val sr1JsExp = new JsExp {
+ def toJsCmd = compact(render(sr1Json))
+ }
+ val sr2JsExp = new JsExp {
+ def toJsCmd = compact(render(sr2Json))
+ }
+
+ passBasicTests(lst, rec.mandatoryBsonRecordListField, rec.legacyOptionalBsonRecordListField)
+ passConversionTests(
+ lst,
+ rec.mandatoryBsonRecordListField,
+ JsArray(sr1JsExp, sr2JsExp),
+ JArray(List(sr1Json, sr2Json)),
+ Empty
+ )
+ }
+ }
}
View
76 persistence/mongodb-record/src/test/scala/net/liftweb/mongodb/record/MongoRecordSpec.scala
@@ -47,7 +47,7 @@ object MongoRecordSpec extends Specification("MongoRecord Specification") with M
} yield flavor + typeName + "Field").toList
"introspect only the expected fields" in {
- rec.fields().map(_.name).sortWith(_ < _) must_== allExpectedFieldNames.sortWith(_ < _)
+ rec.fields().map(_.name).filterNot(allExpectedFieldNames.contains(_)) must_== Nil
}
"correctly look up fields by name" in {
@@ -167,10 +167,18 @@ object MongoRecordSpec extends Specification("MongoRecord Specification") with M
"MongoRecord" should {
checkMongoIsRunning
+ val ssr1 = SubSubRecord.createRecord.name("SubSubRecord1")
+ val ssr2 = SubSubRecord.createRecord.name("SubSubRecord2")
+
val sr1 = SubRecord.createRecord
.name("SubRecord1")
- val sr2 = SubRecord.createRecord
- .name("SubRecord2")
+ .subsub(ssr1)
+ .subsublist(ssr1 :: ssr2 :: Nil)
+ .slist("s1" :: "s2" :: Nil)
+ .smap(Map("a" -> "s1", "b" -> "s2"))
+ .pattern(Pattern.compile("^Mo", Pattern.CASE_INSENSITIVE))
+
+ val sr2 = SubRecord.createRecord.name("SubRecord2")
val fttr = FieldTypeTestRecord.createRecord
//.mandatoryBinaryField()
@@ -218,13 +226,59 @@ object MongoRecordSpec extends Specification("MongoRecord Specification") with M
val ljson = Printer.compact(render(ltr.asJValue))
val mjson = Printer.compact(render(mtr.asJValue))
+ val sr1Json =
+ JObject(List(
+ JField("name", JString("SubRecord1")),
+ JField("subsub", JObject(List(
+ JField("name", JString("SubSubRecord1"))
+ ))),
+ JField("subsublist", JArray(List(
+ JObject(List(JField("name", JString("SubSubRecord1")))),
+ JObject(List(JField("name", JString("SubSubRecord2"))))
+ ))),
+ JField("when", JObject(List(
+ JField("$dt", JString(srtr.meta.formats.dateFormat.format(sr1.when.value)))
+ ))),
+ JField("slist", JArray(List(JString("s1"), JString("s2")))),
+ JField("smap", JObject(List(
+ JField("a", JString("s1")),
+ JField("b", JString("s2"))
+ ))),
+ JField("oid", JObject(List(JField("$oid", JString(sr1.oid.value.toString))))),
+ JField("pattern", JObject(List(
+ JField("$regex", JString(sr1.pattern.value.pattern)),
+ JField("$flags", JInt(sr1.pattern.value.flags))
+ ))),
+ JField("uuid", JObject(List(JField("$uuid", JString(sr1.uuid.value.toString)))))
+ ))
+
+ val sr2Json =
+ JObject(List(
+ JField("name", JString("SubRecord2")),
+ JField("subsub", JObject(List(
+ JField("name", JString(""))
+ ))),
+ JField("subsublist", JArray(List())),
+ JField("when", JObject(List(
+ JField("$dt", JString(srtr.meta.formats.dateFormat.format(sr2.when.value)))
+ ))),
+ JField("slist", JArray(List())),
+ JField("smap", JObject(List())),
+ JField("oid", JObject(List(JField("$oid", JString(sr2.oid.value.toString))))),
+ JField("pattern", JObject(List(
+ JField("$regex", JString(sr2.pattern.value.pattern)),
+ JField("$flags", JInt(sr2.pattern.value.flags))
+ ))),
+ JField("uuid", JObject(List(JField("$uuid", JString(sr2.uuid.value.toString)))))
+ ))
+
val srtrJson = JObject(List(
JField("_id", JObject(List(JField("$oid", JString(srtr.id.toString))))),
- JField("mandatoryBsonRecordField", JObject(List(JField("name", JString("SubRecord1"))))),
+ JField("mandatoryBsonRecordField", sr1Json),
JField("legacyOptionalBsonRecordField", JNothing),
JField("mandatoryBsonRecordListField", JArray(List(
- JObject(List(JField("name", JString("SubRecord1")))),
- JObject(List(JField("name", JString("SubRecord2"))))
+ sr1Json,
+ sr2Json
))),
JField("legacyOptionalBsonRecordListField", JArray(List()))
))
@@ -241,6 +295,15 @@ object MongoRecordSpec extends Specification("MongoRecord Specification") with M
}
}
+ "delete record properly" in {
+ checkMongoIsRunning
+
+ fttr.save
+ FieldTypeTestRecord.find(fttr.id) must notBeEmpty
+ fttr.delete_!
+ FieldTypeTestRecord.find(fttr.id) must beEmpty
+ }
+
"save and retrieve Mongo type fields" in {
checkMongoIsRunning
@@ -316,7 +379,6 @@ object MongoRecordSpec extends Specification("MongoRecord Specification") with M
mtr.asJValue mustEqual JObject(List(
JField("_id", JObject(List(JField("$oid", JString(mtr.id.toString))))),
- JField("_id", JObject(List(JField("$oid", JString(mtr.id.toString))))),
JField("mandatoryStringMapField", JObject(List(
JField("a", JString("abc")),
JField("b", JString("def")),
Please sign in to comment.
Something went wrong with that request. Please try again.