Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala, Play Framework Slick issue - could not find implicit value for parameter rconv

I'm following guidelines of Slick documentation and I don't understand what I'm doing wrong here:

package models

import scala.slick.session.Database
import Database.threadLocalSession
import scala.slick.jdbc.{GetResult, StaticQuery => Q}
import javax.sql.DataSource
import Q.interpolation

object Data {

    case class User(user: String, password: String)

    lazy val db = Database.forName("default")

    def result: Option[User] = {
        db.withSession {
            sql"SELECT user, password FROM user WHERE user = 'user' AND password = 'pass'".as[User]
        }
    }

}

The line

sql"SELECT user, password FROM user WHERE user = 'user' AND password = 'pass'".as[User]

is giving me this:

Multiple markers at this line
    - could not find implicit value for parameter rconv: scala.slick.jdbc.GetResult[models.Data.User]
    - could not find implicit value for parameter rconv: scala.slick.jdbc.GetResult[models.Data.User]

What am I doing wrong here?

Play Framework 2.2.0, Scala 2.10.3, Slick 1.0.1

like image 802
Caballero Avatar asked Oct 27 '13 20:10

Caballero


1 Answers

You need to provide the conversion function from result to user. Copied and adapted straight from the slick home:

implicit val getUserResult = GetResult(r => User(r.<<, r.<<))

Or this section from the documentation you linked

like image 56
pedrofurla Avatar answered Nov 03 '22 11:11

pedrofurla