2013-06-21 10 views
9

Podążam za Slick documentation example for autoincrementing fields i mam problem z utworzeniem mapped projection, który ... cóż, ma tylko jedną kolumnę.Wyświetlenia Scala w wersji zręcznej dla tylko jednej kolumny

case class UserRole(id: Option[Int], role: String) 

object UserRoles extends Table[UserRole]("userRole") { 
    def id = column[Int]("ID", O.PrimaryKey, O.AutoInc) 
    def role = column[String]("ROLE") 
    // ... 
    def * = id.? ~ role <> (UserRole, UserRole.unapply _) 
     // NEXT LINE ERRORS OUT 
    def forInsert = role <> ({t => UserRole(None, t._1)}, {(r: UserRole) => Some((r.role))}) returning id 
} 

Błąd jest „wartość <> nie jest członkiem scala.slick.lifted.Column [ciąg]”

ja też myślałem, że to będzie bardziej efektywne, aby zaprojektować schemat tak:

case class UserRole(role: String) 

object UserRoles extends Table[UserRole]("userRole") { 
    def role = column[Int]("ROLE", O.PrimaryKey) 
    // ... 
    def * = role <> (UserRole, UserRole.unapply _) 

} 

Ale wtedy zaczynam otrzymywać ten sam błąd, co powyżej. "wartość <> nie jest członkiem scala.slick.lifted.Column [String]"

Co tak naprawdę robię? Czy po prostu nie mam już projection, ponieważ mam tylko jedną kolumnę? Jeśli tak, to co powinienem zrobić?

Odpowiedz

Powiązane problemy