Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error : MappedEncoding[X, JsonValue[X]] with None #2637

Open
mazers0129 opened this issue Oct 28, 2022 · 0 comments
Open

Type Error : MappedEncoding[X, JsonValue[X]] with None #2637

mazers0129 opened this issue Oct 28, 2022 · 0 comments

Comments

@mazers0129
Copy link

This template isn't a strict requirement to open issues, but please try to provide as much information as possible.

Version: 4.6.0
Module: quill-jdbc-zio
Database: postgresql

case class TestData(first: String)
case class Test(id: String, data: Option[TestData])
implicit val encoder: JsonEncoder[TestData] = DeriveJsonEncoder.gen
implicit val dbEncoder: MappedEncoding[TestData, JsonValue[TestData]] = MappedEncoding(JsonValue(_))

throw exception : org.postgresql.util.PSQLException: ERROR: column "data" is of type json but expression is of type character varying
with this code

ctx.run(query[Test].insertValue(lift(Test("test", None)))).provideEnvironment(layer)

work fine with this code

ctx.run(query[Test].insertValue(lift(Test("test", Some(TestData("1")))))).provideEnvironment(layer)

work fine if use

implicit val dbOptionEncoder: MappedEncoding[Option[TestData], JsonValue[Option[TestData]]] = MappedEncoding(JsonValue(_))

instead of

implicit val dbEncoder: MappedEncoding[TestData, JsonValue[TestData]] = MappedEncoding(JsonValue(_))

but if use both code throw exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant