이 테이블 정의는 null 입력 가능 열을 가짐으로써 String 대신 Option [String]을 사용해야한다는 것을 알게되었습니다. 그게 내가 만든 유일한 변화 였고 지금은 내 코드가 어떻게 생겼는지입니다.Null 허용 열이있는 매끄러운 테이블 정의는 어떻게 작성합니까?
class RespondentTableDef(tag: Tag) extends Table[Respondent](tag, "respondent") {
def id = column[Long]("id", O.PrimaryKey)
def uuid = column[String]("uuid")
def version = column[Long]("version")
def task = column[Long]("task")
def firstName = column[Option[String]]("first_name")
def lastName = column[Option[String]]("last_name")
def ageGroup = column[Option[String]]("age_group")
def incomeLevel = column[Option[String]]("income_level")
def employmentStatus = column[Option[String]]("employment_status")
def maritalStatus = column[Option[String]]("marital_status")
def housingStatus = column[Option[String]]("housing_status")
def educationStatus = column[Option[String]]("education_status")
def gender = column[Option[String]]("gender")
override def * =
(id, uuid, version, task, firstName, lastName, ageGroup, incomeLevel, employmentStatus, maritalStatus, housingStatus, educationStatus, gender) <> (Respondent.tupled, Respondent.unapply)
}
컴파일 할 때이 오류가 발생합니다.
[error] /Users/roy/adivinate/survey2/app/model/Respondent.scala:45: 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: slick.lifted.FlatShapeLevel
[error] Source type: (slick.lifted.Rep[Long], slick.lifted.Rep[String], slick.lifted.Rep[Long], slick.lifted.Rep[Long], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]], slick.lifted.Rep[Option[String]])
[error] Unpacked type: (Long, String, Long, Long, String, String, String, String, String, String, String, String, String)
[error] Packed type: Any
[error] (id, uuid, version, task, firstName, lastName, ageGroup, incomeLevel, employmentStatus, maritalStatus, housingStatus, educationStatus, gender) <> (Respondent.tupled, Respondent.unapply)
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 5 s, completed Dec 21, 2016 8:53:17 PM
당신이 공유 할 수 없습니다 : 당신이 (TableQuery에서) 업데이트 할 경우에도 옵션을
을 정의? –
열이 Null 인 경우 Option을 사용해야합니다. –