Search code examples
scalascalaquery

Raw result rows with named fields in ScalaQuery?


In ScalaQuery, I can do this to work with the "raw" result rows:

for (
  x <- queryNA[(String,Int)]("select * from foo")(
    GetResult(r => (r.<<[String], r.<<[Int]))
  )
) {
  println(x)
}

But this is entirely positional (r is a PositionedResult). Is there a way to work with the results using the column names? (E.g., row.getString("foo").)

I could use another DB API that supports this, like Querulous, but I'm already using ScalaQuery in my code for its type-safe queries, and would like to stick to just one library if possible.


Solution

  • From the ScalaQuery mailing list: you can get the underlying ResultSet with r.rs.