Tuple in table projection "No matching Shape found"

1,366 views
Skip to first unread message

badeleux

unread,
Mar 13, 2014, 4:21:38 PM3/13/14
to scala...@googlegroups.com
I am trying to map Coffee class via slick but with no luck:

object GlobalCoffee {
  case class Coffee(uid: Long, coffeeType: String, h: PasswordInfo)
  object Coffee
  class Coffees(tag: Tag) extends Table[Coffee](tag, "Coffee") {

    def uid = column[Long]("id", O.PrimaryKey, O.AutoInc)
    def coffeeType = column[String]("coffeeType")
        // passwordInfo
    def hasher = column[String]("hasher")
    def password = column[String]("password")
    def salt = column[String]("salt")

    def * = (uid, coffeeType, hasher, password, salt) <> ((t : (Long, String, String, String, Option[String])) => Coffee(t._1, t._2, PasswordInfo(t._3, t._4, t._5)), (c: Coffee) => Some((c.uid, c.coffeeType, c.h.hasher, c.h.password, c.h.salt)))
  }

}

I am getting:
 No matching Shape found.
[error] Slick does not know how to map the given types.
[error] Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
[error]   Required level: scala.slick.lifted.ShapeLevel.Flat
[error]      Source type: (scala.slick.lifted.Column[Long], scala.slick.lifted.Column[String], scala.slick.lifted.Column[String], scala.slick.lifted.Column[String], scala.slick.lifted.Column[String])
[error]    Unpacked type: (Long, String, String, String, Option[String])
[error]      Packed type: Any
[error]     def * = (uid, coffeeType, hasher, password, salt) <> ((t : (Long, String, String, String, Option[String])) => Coffee(t._1, t._2, PasswordInfo(t._3, t._4, t._5)), (c: Coffee) => Some((c.uid, c.coffeeType, c.h.hasher, c.h.password, c.h.salt)))
[error]                                                       ^
[error] one error found

Does anybody have an idea what's messed up?

Christopher Vogt

unread,
Mar 13, 2014, 4:42:15 PM3/13/14
to scala...@googlegroups.com

> def salt = column[String]("salt")

You are trying to map a column which is not an Option to an Option. You
need to make it one.

def salt = column[Option[String]]("salt")

If salt is nullable that is. Otherwise don't expect an Option or make it
one.

Chris
Reply all
Reply to author
Forward
0 new messages