I have the following play/slick 3.0 code that reads an entire table. It works well with the exception that the SQL statement doesn't add the order by
(even though it applies sortBy
. What could be the problem?
def readMany = {
val db = Database.forConfig("dbconfig")
var list = new ListBuffer[UserVO]()
try {
val users = TableQuery[UserDB]
val action = users.result
users.sortBy(_.userid)
val future = db.run(action).map(_.foreach {
case (u) => list += u
})
val result = Await.result(future, 10 seconds)
println(action.statements.head) // <-- prints "select userid,col1,col2 from users"
} finally db.close
list
}