Eric Hartford
Eric Hartford

Reputation: 18002

diverging implicit expansion in implicit val GetResult

Using slick and following the examples, I have created a implicit val to convert my result like this:

implicit val getLocationResult = GetResult(r => LkpLocation(r.<<, r.<<, r.<<, r.<<))
val marketsQuery1 = sql"exec get_locations @ProjectId = ${projectID.get}, @ObjectId = $objectID, @ComponentTypeID = 1".as[LkpLocation]

However I get a strange error message:

diverging implicit expansion for type scala.slick.jdbc.GetResult[T] starting with method createGetTuple22 in object GetResult

What is the cause of this error? Is there perhaps another way I can declare the implicit conversion that would be more stable?

Upvotes: 3

Views: 1269

Answers (1)

tfh
tfh

Reputation: 620

Ensure the class you're converting to contains only types slick's PositionedResult can handle using it's << method. For a list of all types see the other methods of PositionedResult.

I got this error when using a java.util.Date on my target class while PositionedResult's method nextDate returns a java.sql.Date. Declaring the target class's date field as java.sql.Date then solved the problem.

Upvotes: 2

Related Questions