2013-02-21 5 views
3

제 경우에는 간단한 Slick 테이블 선언조차 작동하지 않습니다. 나는 매끄러운 2.10 (1.0.0)을 사용하고 있는데, 이는 중앙 저장소에서 최신 버전이다.매끄러운 투영이 작동하지 않는 이유

case class DeviceType(id: Option[Int] = None, name: String, version: String) 

object DeviceTypes extends Table[DeviceType]("device_types") { 

    def id = column[Int]("id", O.PrimaryKey, O.AutoInc) 
    def name = column[String]("name", O.NotNull) 
    def version = column[String]("version") 

    def * = id.? ~ name ~ version <> (DeviceType, DeviceType.unapply _) 


    def delete(device_type: DeviceType): Unit = { 
database withSession { implicit session : Session => 
    val dt_query = for(dt <- DeviceTypes if dt.id == device_type.id.get) yield dt 
    //Query(DeviceTypes).filter(_.id == device_type.id.get) 
    dt_query.delete 
} 
    } 
} 

[warn] /home/salil/Scala/sd_ventures/app/models/DeviceType.scala:38: scala.slick.lifted.Column[Int] and Int are unrelated: they will most likely never compare equal 
[warn]  val dt_query = for(dt <- DeviceTypes if dt.id == device_type.id.get) yield dt 
[warn]       ^

And if I use Query class directly, I get the same warning: 
[warn] /home/salil/Scala/sd_ventures/app/models/DeviceType.scala:38: scala.slick.lifted.Column[Int] and Int are unrelated: they will most likely never compare equal 
[warn]  val dt = Query(DeviceTypes).filter(_.id == device_type.id.get) 
[warn]            ^

누군가가 왜 작동하지 않는지 말할 수 있습니까?

답변

10

슬릭에서 평등성을 테스트하려면 "==="를 사용해야합니다.

val dt_query = for(dt <- DeviceTypes if dt.id === device_type.id.get) yield dt 

참조 : http://slick.typesafe.com/doc/1.0.0/gettingstarted.html

+0

오의 하단에, 알고하지 않았다. 정말 고맙습니다. – Salil

+0

문자열에 대해서는 작동하지 않습니다. 적어도 v1.0.1-RC1에서는 작동하지 않습니다. 비교'val q = for {u <- 사용자 인 경우 u.name === 사용자 이름} yield u '는 결코 동일하지 않습니다. –