From 9e58ef887c0034578343c9b923c13c08c579a404 Mon Sep 17 00:00:00 2001 From: Rodolfo Hansen Date: Fri, 1 Aug 2014 18:37:19 -0400 Subject: [PATCH] Convert Double -> Int and Int -> Double as necesary --- mongo/src/main/scala/BSONPickler.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mongo/src/main/scala/BSONPickler.scala b/mongo/src/main/scala/BSONPickler.scala index 1b6b196..b021b1d 100644 --- a/mongo/src/main/scala/BSONPickler.scala +++ b/mongo/src/main/scala/BSONPickler.scala @@ -39,13 +39,15 @@ object BSONPickler { implicit def DoubleBSONPickler: BSONPickler[Double] = new BSONPickler[Double] { def pickle(s: Double): BSONValue = BSONDouble(s) def unpickle(v: BSONValue, path: List[String]): String \/ Double = - typecheck[BSONDouble](v, path)(_.value) + typecheck[BSONDouble](v, path)(_.value) ||| + typecheck[BSONInteger](v, path)(_.value).map(_.toDouble) } implicit def IntBSONPickler: BSONPickler[Int] = new BSONPickler[Int] { def pickle(s: Int): BSONValue = BSONInteger(s) def unpickle(v: BSONValue, path: List[String]): String \/ Int = - typecheck[BSONInteger](v, path)(_.value) + typecheck[BSONInteger](v, path)(_.value) ||| + typecheck[BSONDouble](v, path)(_.value).map(_.toInt) } implicit def DateTimeBSONPickler: BSONPickler[DateTime] = new BSONPickler[DateTime] {