Created
November 1, 2019 13:57
-
-
Save patientplatypus/e31275e833fbde09cae9553f124d27e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I have the following scala code that I'm trying to use an onComplete to unwrap (to access the option) | |
//it seems to be the way you're supposed to do it but I keep getting a type mismatch error | |
//What is the proper way to access the id after writing the SQL? | |
[error] /Users/patientplatypus/Documents/platypusNEST/blog_scala_play/blog/app/models/Commands.scala:44:16: constructor cannot be instantiated to expected type; | |
[error] found : anorm.Success[A] | |
[error] required: scala.util.Try[Option[Long]] | |
[error] case Success(e) => println("inside success") | |
[error] ^ | |
[error] /Users/patientplatypus/Documents/platypusNEST/blog_scala_play/blog/app/models/Commands.scala:45:16: not found: value Failure | |
[error] case Failure(e) => println("inside failure") | |
[error] ^ | |
[error] two errors found | |
val id: Future[Option[Long]] = Future { database.db.withConnection { implicit c => | |
SQL( | |
""" | |
insert into Test(msg, typ) values ( | |
{msg}, {typ} | |
) | |
""" | |
).bind(newCase).executeInsert() | |
} | |
}(ec) | |
println("after parse") | |
println(id) | |
id onComplete { | |
case Success(e) => println("inside success") | |
case Failure(e) => println("inside failure") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment