Slick getting unexpected results from a query using a select statement

25 views
Skip to first unread message

hernand...@gmail.com

unread,
Feb 3, 2016, 6:23:57 PM2/3/16
to Slick / ScalaQuery
I have a query select city from profiles where id=32; very simple, I executed inside the database and I always get a return of a city name. If I execute inside the playframework using Scala-Slick I get the result "()" . I get exactly that with no errors, it is almost as the results are getting truncated. This is my action

 def mycity() = Action.async 
{

val mprofiles = DBIO.seq(sql"""select city from profiles where id=32;""".as[String])
data.run(mprofiles).map { mdone =>Ok(mdone.toString) }
}

Why is my result : () and not the city name ...

Richard Dallaway

unread,
Feb 4, 2016, 5:12:19 AM2/4/16
to Slick / ScalaQuery
Hello - DBIO.seq combines a bunch of actions together, but disposes of the results.  It's not what you want here, and is why you're seeing a unit result. You can pass your sql"select...".as[String] directly to data.run, as it is an action.

Hope that helps
Richard

--

---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/1acbd583-03c5-42cd-95cc-9cdbb417448b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages