Scala 在Slick中使用选项而不是NOTNULL
我有一门课:Scala 在Slick中使用选项而不是NOTNULL,scala,h2,slick,Scala,H2,Slick,我有一门课: class Sitestats(tag: Tag) extends Table[(Int,String,String,Int,String)](tag, "SITESTATS"){ def id = column[Int]("STAT_ID", O.PrimaryKey, O.AutoInc) def url = column[String]("STAT_URL") def httpstatus = column[String]("STAT_HTTPSTATUS")
class Sitestats(tag: Tag) extends Table[(Int,String,String,Int,String)](tag, "SITESTATS"){
def id = column[Int]("STAT_ID", O.PrimaryKey, O.AutoInc)
def url = column[String]("STAT_URL")
def httpstatus = column[String]("STAT_HTTPSTATUS")
def contentlength = column[Int]("STAT_CONTENTLENGTH")
def description = column[String]("STAT_DESC")
def * : ProvenShape[(Int,String,String,Int,String)] = (id,url,httpstatus,contentlength,description)
}
允许我做(使用滑头)
产生预期(snip):
我希望httpstatus能够为null,所以我将行更改为
def httpstatus = column[Option[String]]("STAT_HTTPSTATUS")
导致
[error] found : (scala.slick.lifted.Column[Int], scala.slick.lifted.Column[String], scala.slick.lifted.Column[Option[String]], scala.slick.lifted.Column[Int], scala.slick.lifted.Column[String])
[error] required: scala.slick.lifted.ProvenShape[(Int, String, String, Int, String)]
我遗漏了什么?尝试如下更新:
def * : ProvenShape[(Int,String,Option[String],Int,String)] = (id,url,httpstatus,contentlength,description)
您忘记更新表定义。:)
更新
尝试如下更新:
def * : ProvenShape[(Int,String,Option[String],Int,String)] = (id,url,httpstatus,contentlength,description)
您忘记更新表定义。:)
更新
尝试如下更新:
def * : ProvenShape[(Int,String,Option[String],Int,String)] = (id,url,httpstatus,contentlength,description)
您忘记更新表定义。:)
更新
尝试如下更新:
def * : ProvenShape[(Int,String,Option[String],Int,String)] = (id,url,httpstatus,contentlength,description)
您忘记更新表定义。:)
更新
在[error]中找到的结果:字符串(“404”)[error]必需:选项[String][error]sitestats+=((234,))在[error]中找到的结果:字符串(“404”)[error]必需:选项[String][error]sitestats+=((234,))在[error]中找到的结果:字符串(“404”)[error]必需:选项[String][error errorsitestats+=((234,))导致[error]找到:字符串(“404”)[error]必需:选项[String][error]sitestats+=((234,))