0
我有以下play/slick 3.0代碼讀取整個表。它運作良好,所不同的是SQL語句不加order by
(即使它適用sortBy
可能是什麼問題玩滑動:選擇*從表忽略sortBy
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
}