Skip to content

Commit

Permalink
jsonOrJsonbArrayGet
Browse files Browse the repository at this point in the history
  • Loading branch information
salamonpavel committed Jul 11, 2024
1 parent e425aff commit f7b6bdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ package object implicits {
}
}

implicit val jsonArrayGet: Get[List[Json]] = {
Get.Advanced
.other[PgArray](
NonEmptyList.of("json[]")
)
.temap(pgArray => pgArrayToListOfJson(pgArray))
}

implicit val jsonbArrayPut: Put[List[Json]] = {
Put.Advanced
.other[PGobject](
Expand All @@ -64,6 +56,14 @@ package object implicits {
}
}

implicit val jsonOrJsonbArrayGet: Get[List[Json]] = {
Get.Advanced
.other[PgArray](
NonEmptyList.of("json[]")
)
.temap(pgArray => pgArrayToListOfJson(pgArray))
}

private def jsonListToPGJsonArrayString(jsonList: List[Json]): String = {
val arrayElements = jsonList.map { x =>
// Convert to compact JSON string and escape inner quotes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import za.co.absa.db.fadb.DBSchema
import za.co.absa.db.fadb.doobie.DoobieFunction.{DoobieMultipleResultFunction, DoobieSingleResultFunction}
import za.co.absa.db.fadb.testing.classes.DoobieTest

import za.co.absa.db.fadb.doobie.postgres.circe.implicits.jsonArrayGet
import za.co.absa.db.fadb.doobie.postgres.circe.implicits.jsonOrJsonbArrayGet

class JsonArrayIntegrationTests extends AnyFunSuite with DoobieTest {

Expand Down

0 comments on commit f7b6bdd

Please sign in to comment.