Skip to content

Commit

Permalink
Bump circe
Browse files Browse the repository at this point in the history
  • Loading branch information
domaspoliakas committed Mar 29, 2024
1 parent c6df962 commit 9a70664
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion circe/src/main/scala/mongo4cats/circe.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ object circe extends JsonCodecs {
}

implicit def circeDecoderToDecoder[A: Decoder]: BsonDecoder[A] = new BsonDecoder[A] {

val decoder = Decoder.instance[A](_.as[A])

def apply(b: BsonValue) = {
val doc = BsonDocument(RootTag -> (if (b == null) new BsonNull else b)).toJson()
val json = parser.parse(doc)
val jsonWithoutRoot = json.flatMap(_.hcursor.get[Json](RootTag))
val decoder = Decoder.instance[A](_.as[A])
jsonWithoutRoot
.flatMap(decoder.decodeJson(_))
.leftMap(x =>
Expand Down
2 changes: 1 addition & 1 deletion circe/src/test/scala/mongo4cats/circe.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CirceSpec extends AnyWordSpec with Matchers with EitherValues {

val res = circe.implicits.circeDecoderToDecoder[String](deco).apply(new BsonString("hek"))

res.left.value.msg shouldBe "An error occured during decoding BsonValue BsonString{value='hek'}: DecodingFailure(Attempt to decode value on failed cursor, List(DownField(hek)))"
res.left.value.msg shouldBe "An error occured during decoding BsonValue BsonString{value='hek'}: DecodingFailure at .hek: Missing required field"

}
}
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Dependencies {
val mongodb = "4.11.1"
val fs2 = "3.10.2"
val scalaCompat = "2.6.0"
val circe = "0.14.1"
val circe = "0.14.6"
val findbugsJsr305Version = "1.3.9"

val logback = "1.2.10"
Expand Down

0 comments on commit 9a70664

Please sign in to comment.