scalaquery 问题没有隐式 session

标签 scala scalaquery

这是我想要执行的 scalaquery 查询,

...
def generateFares(scheduleId:NamedColumn[Int], toCityId:NamedColumn[Int], fromCityId:NamedColumn[Int]):List[(String,Int,String)] = {
      var list:List[(String,Int,String)] = Nil;
      val q = for {
        tf <- ticketingDB.ticketFares if (( tf.scheduleId is scheduleId ) && ( tf.fromCityId is fromCityId ) && ( tf.toCityId is toCityId ))
        tft <- ticketingDB.ticketFareType if tft.id is tf._7
      }{
        list = (tft._2, tf._5, tf._6)::list
      }
      list
    }
...

在这个连接中,我收到一个编译错误:
 could not find implicit value for parameter session: org.scalaquery.session.Session

在第二次通话中。 (tft <-ticketingDB)

我无法理解 scalaquery 的这种行为。

ps:我可以确保在 withSession 块内调用该方法。

请帮我调试并创建无错误连接。

最佳答案

抱歉,我将解决方案作为评论发布,

我自己想出了答案。您应该导入 threadLocalSession 以获取 session 对象。

import org.scalaquery.session.Database.threadLocalSession 

关于scalaquery 问题没有隐式 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7468853/

相关文章:

scala - 如何使用ScalaQuery仅选择符合where子句的第一条或最后一条记录?

scala - SBT,从依赖项目运行一个主类

scala - 可以通过 ISNUMERIC 函数过滤 Spark 数据帧吗?

scala - 为什么在 ScalaQuery 的 "Missing parameter type"子句中访问表时会出现 "withTransaction"?

scala - SLICK 3.0 - 多个查询相互依赖 - db.run(action)

scalaquery - 如何在 ScalaQuery 中指定 Postgresql 模式?

scala - _ :type? 的 scala 表示法是什么

scala - 在 PairRDDFunctions.reduceByKey() 中使用 'case'

scala - 如何一次匹配选项映射值?

scala - 如何从运行时参数指定 SLICK Query sortBy 列?