Skip to content

Commit bf3e5da

Browse files
committed
pr review fixes
1 parent 9e8c7ce commit bf3e5da

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

modules/postgres-circe/src/main/scala/doobie/postgres/circe/Instances.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,17 @@ object Instances {
3434
).temap(a =>
3535
parse(a.getValue).leftMap(_.show))
3636

37+
private implicit val showString: Show[Array[String]] = Show.show(_.mkString("Array(", ", ", ")"))
38+
3739
implicit val arrayJsonGet: Get[Array[Json]] =
3840
Get.Advanced.array[String](NonEmptyList.of("jsonb[]", "_jsonb"))
39-
.map(_.map(jsonStr => parse(jsonStr).fold(throw _, identity)))
41+
.temap(_.toList.traverse(jsonStr =>
42+
parse(jsonStr).leftMap(_.getMessage)).map(_.toArray))
4043

4144
implicit val arrayJsonPut: Put[Array[Json]] =
4245
Put.Advanced.array[String](NonEmptyList.of("_jsonb"), "jsonb")
4346
.tcontramap(_.map(_.noSpaces))
4447

45-
implicit val listJsonGet: Get[List[Json]] =
46-
arrayJsonGet.map(_.toList)
47-
48-
implicit val listJsonPut: Put[List[Json]] =
49-
arrayJsonPut.contramap(_.toArray)
50-
5148
def pgEncoderPutT[A: Encoder]: Put[A] =
5249
Put[Json].tcontramap(_.asJson)
5350

0 commit comments

Comments
 (0)