Migration from 0.10.5.0.akka23 to 0.11.7.play23

55 views
Skip to first unread message

David Sanchez

unread,
Sep 28, 2015, 8:22:01 AM9/28/15
to ReactiveMongo - http://reactivemongo.org
Hi,

In my 2.3.10 scala-based play application, i'm using "play2-reactivemongo" 0.10.5.0.akka23 and "reactivemongo-extensions-json" 0.10.5.0.0.akka23.

Now, I want to use 0.11.7.play23 stable version.

Is there a migration doc somewhere ?
Because I have now a lot of compilation error...

One of my lot of errors :

case class MyTest(_id: BSONObjectID = BSONObjectID.generate, someField: string)


object MyTest {


 
import play.api.libs.json.Json
 
import play.modules.reactivemongo.json.BSONFormats._


 
implicit val format = Json.format[MyTest]


 
def anthoreFormat = new Writes[MyTest] {
 
 implict val overrideBSONObjectIDFormat
= MyBSONObjectID.defaultWrite


 
def writes(obj: MyTest) = format.writes(obj) ++ Json.obj(
 
// Override to just return "_id" -> "stringify"
 
"_id" -> obj._id
 
)
 
}


}


object MyBSONObjectID {


 
def defaultWrite = new Writes[BSONObjectID] {


   
def writes(obj: BSONObjectID) = JsString(obj.stringify)


 
}


}




I have the following error
found   : reactivemongo.bson.BSONObjectID
required
: play.api.libs.json.Json.JsValueWrapper
   
"_id" -> obj._id

The implicit does not work anymore...
Any idea ?

Thanks !

David Sanchez

unread,
Sep 28, 2015, 8:49:56 AM9/28/15
to ReactiveMongo - http://reactivemongo.org
Ok for this error, I just forgot to specify the return type 

def writes(obj: BSONObjectID):JsValue = JsString(obj.stringify)

...

David Sanchez

unread,
Sep 28, 2015, 9:46:54 AM9/28/15
to ReactiveMongo - http://reactivemongo.org
Now compilation is ok. But not execution.

The BSONObjectID implicit writes is not applied. Any idea on why it is not applied since I use the new module version ?

Thanks

Cédric Chantepie

unread,
Sep 29, 2015, 5:25:30 PM9/29/15
to ReactiveMongo - http://reactivemongo.org
Either the implicit is found at compile time, or you get a compilation error. If runtime exception, I doubt that's related to an implicit.

David Sanchez

unread,
Sep 30, 2015, 6:11:08 AM9/30/15
to ReactiveMongo - http://reactivemongo.org
There is NO runtime exception.
I just notice that my custom implicit write is no more applied (the default one is used ie. the one containing the $oid sub object}...
As if my implicit write is ignored...

Cédric Chantepie

unread,
Oct 1, 2015, 3:30:14 AM10/1/15
to ReactiveMongo - http://reactivemongo.org
Hi, what's the code where the implicit should be used, and what's the implicit code?

David Sanchez

unread,
Oct 1, 2015, 4:10:28 AM10/1/15
to ReactiveMongo - http://reactivemongo.org
With the old version, when I define the given implicit val format 

implicit val overrideBSONObjectIDFormat

the output string
Json.toJson(myTestVal)
was
  {
   
"_id": "560b987f81501835022f8162",
"someField": "something"
}

And now, with the same code but new version the output string is
 
 {
   
"_id": {
 $oid
: "560b987f81501835022f8162"
 
},
 
"someField": "something"
 
}


What am I misunderstanding ?

Cédric Chantepie

unread,
Oct 1, 2015, 7:45:50 AM10/1/15
to ReactiveMongo - http://reactivemongo.org
Please add the type of your implicit val.

David Sanchez

unread,
Oct 1, 2015, 1:51:53 PM10/1/15
to ReactiveMongo - http://reactivemongo.org
You mean 

implicit val overrideBSONObjectIDFormat:Writes[BSONObjectID] = MyBSONObjectID.defaultWrite

?
Reply all
Reply to author
Forward
0 new messages