slick-pg
slick-pg copied to clipboard
Ambiguous implicit values in GetResult when mixing in plain and standard converters
Hi,
I'm trying to combine this library with slick-codegen
but I am having some issues when mixing in both plain and standard converter traits. Here is my custom profile:
trait CustomPostgresProfile extends ExPostgresProfile with PgDate2Support {
def pgjson =
"jsonb" // jsonb support is in postgres 9.4.0 onward; for 9.3.x use "json"
override val api = MyAPI
object MyAPI
extends API
with DateTimeImplicits
with Date2DateTimePlainImplicits
}
object CustomPostgresProfile extends CustomPostgresProfile
The issue is when slick-codegen
is run, it produces this code:
implicit def GetResultAuthTokenRow(implicit e0: GR[java.util.UUID], e1: GR[Int], e2: GR[OffsetDateTime]): GR[AuthTokenRow] = GR{
prs => import prs._
AuthTokenRow.tupled((<<[java.util.UUID], <<[Int], <<[OffsetDateTime]))
}
which complains that there are two implicit converters of type slick.jdbc.GetResult[java.time.OffsetDateTime]
models/DbModels.scala:30:57: ambiguous implicit values:
[error] both value getOffsetDateTime in trait Date2DateTimePlainImplicits of type => slick.jdbc.GetResult[java.time.OffsetDateTime]
[error] and value e2 of type slick.jdbc.GetResult[java.time.OffsetDateTime]
[error] match expected type slick.jdbc.GetResult[java.time.OffsetDateTime]
[error] AuthTokenRow.tupled((<<[java.util.UUID], <<[Int], <<[OffsetDateTime]))
Do you know of any way to customize the generator to fix this?
Thanks
@mrwillis prs => import prs._
import implicit converters
duplicatedly?
BTW, you should change object MyAPI
to trait MyAPI
. object MyAPI
also brought us many issues.
Hi @tminglei, thanks for the response. Yes it is probably that line. Do you know of how to customize it with slick-codegen
? Something in here? https://github.com/tminglei/slick-pg/blob/master/examples/codegen-customization/codegen/src/main/scala/demo/CustomizedCodeGenerator.scala
Yes, you should customize this class.