【发布时间】:2021-11-19 18:01:24
【问题描述】:
Schema 是从 PostgreSQl 数据库自动生成的:
class Geopointtable(_tableTag: Tag) extends profile.api.Table[GeopointtableRow](_tableTag, "geopointtable") {
def * = (id, latitude, longitude, date, time) <> (GeopointtableRow.tupled, GeopointtableRow.unapply)
def ? = ((Rep.Some(id), Rep.Some(latitude), Rep.Some(longitude), Rep.Some(date), Rep.Some(time))).shaped.<>({r=>import r._; _1.map(_=> GeopointtableRow.tupled((_1.get, _2.get, _3.get, _4.get, _5.get)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported."))
val id: Rep[Int] = column[Int]("id", O.AutoInc, O.PrimaryKey)
val latitude: Rep[Int] = column[Int]("latitude")
val longitude: Rep[Int] = column[Int]("longitude")
val date: Rep[java.sql.Date] = column[java.sql.Date]("date")
val time: Rep[java.sql.Time] = column[java.sql.Time]("time")
}
lazy val Geopointtable = new TableQuery(tag => new Geopointtable(tag))
}
我正在尝试在表中插入一些值:
val db = Database.forConfig("geodb")
val date = java.sql.Date.valueOf(LocalDateTime.now().toLocalDate.toString)
val time = java.sql.Time(LocalDateTime.now().toLocalTime)
var point = TableQuery[Tables.Geopointtable]
Await.result(
db.run(
point += Tables.GeopointtableRow(1, 2, 3, date, time))
, Duration.Inf)
但对于“Tables.GeopointtableRow(1, 2, 3, date, time)) 行,编译器指定 2 种类型不匹配:
- 必需的字符串,找到 Tables.GeopointtableRow"。
- 必需的 DBIOAction[NotInferedR,NoStream,Nothing],找到单位
【问题讨论】: