I am trying to abstract the insertion of objects of different types into sql tables of a similar structure. Here is what I am trying to do:
class TableAccess[A : Meta](table: String) { def insert(key: String, a: A): ConnectionIO[Unit] = { (fr"insert into " ++ Fragment.const(table) ++ fr" values ($key, $a);").update.run.map(_ => ()) } }
But I get this compilation error:
[error] diverging implicit expansion for type doobie.util.param.Param[A] [error] starting with method fromMeta in object Param [error] (fr"insert into " ++ Fragment.const(table) ++ fr" values ($key, $a);").update.run.map(_ => ())
All I can find in the documentation:
doobie allows you to interpolate values โโof any type (and parameters) with an instance of Meta, which includes ...
But this does not seem to be enough; What correct types / imports / conversions do I need?
source share