我試圖落實 https://github.com/ArchDev/akka-http-rest 提供的阿卡-HTTP其餘的例子,但我堅持用如何解決單自動遞增列的油滑異常返回上INSERT
slick.SlickException: This DBMS allows only a single column to be returned from an INSERT, and that column must be an AutoInc column.
at slick.jdbc.JdbcStatementBuilderComponent$JdbcCompiledInsert.buildReturnColumns(JdbcStatementBuilderComponent.scala:67)
這裏是Scala代碼: 註冊API:
path("signUp") {
pathEndOrSingleSlash {
post {
entity(as[UsernamePasswordEmail]) { userEntity =>
complete(Created -> signUp(userEntity.username, userEntity.email, userEntity.password))
}
}
}
}
AuthService.scala
def signUp(login: String, email: String, password: String): Future[AuthToken] =
authDataStorage
.saveAuthData(AuthData(UUID.randomUUID().toString, login, email, password.sha256.hex))
.map(authData => encodeToken(authData.id))
AuthDataStorage.scala
...
override def saveAuthData(authData: AuthData): Future[AuthData] =
db.run((auth returning auth).insertOrUpdate(authData)).map(_ => authData)
...
由於我是新來的Scala和油滑,反正可以提供,爲什麼即使我在模型中定義O.AutoInc
此異常發生的信息。我正在使用MySQL RDBMS
上面的代碼給出了同樣的問題: –
你可以看看這個分叉的回購:[akka-http-rest](https://github.com/itsursujit/akka-http-rest) –