Ich habe eine Starter-Anwendung mit Play Framework 2.5 und Slick 3.1, git here heruntergeladen.Playframe Scala play-slick3-Beispielprojekt: JdbcSQLException: Spalte "TEST" nicht gefunden
Wenn ich eine einfache Spalte namens "test" zu Project.scala hinzufügen. Ich bekomme diese Fehlermeldung:
[JdbcSQLException: Column "TEST" not found; SQL statement:
select "ID", "NAME", "TEST" from "PROJECT" [42122-187]]
ich ändern Sie einfach den Projekt Fall-Klasse durch Hinzufügen des Arguments Test und ProjectsTable Klasse mit Funktionen Test, * und:
case class Project(id: Long, name: String, test: String)
private class ProjectsTable(tag: Tag) extends Table[Project](tag, "PROJECT") {
def id = column[Long]("ID", O.AutoInc, O.PrimaryKey)
def name = column[String]("NAME")
def test = column[String]("TEST")
def * = (id, name, test) <> (Project.tupled, Project.unapply)
def ? = (id.?, name.?, test.?).shaped.<>({ r => import r._; _1.map(_ => Project.tupled((_1.get, _2.get, _3.get))) }, (_: Any) => throw new Exception("Inserting into ? projection not supported."))
}
Und die Funktion: create
def create(name: String): Future[Long] = {
val project = Project(0, name, "d")
db.run(Projects returning Projects.map(_.id) += project)
}
Vielen Dank für Ihre Hilfe!
Vielen Dank !! – Lauriane