【问题标题】:Scala Slick Comprehension issuesScala Slick 理解问题
【发布时间】:2013-10-05 01:25:41
【问题描述】:

我在图书馆有以下内容:

案例分类:

case class Foo(
  id: Option[Long],
  bar: Long
...
)

表:

object Foos extends Mapper[Foo]("foo"){ //I'm using slick-inegration so the id is free
  def bar = column[Long]("bar")
  def cols = bar ~ ...
  def * = id.? ~: cols <> (Foo, Foo.unapply _)
  def returningId = cols returning id
  def insert(f: Foo)(implicit s: Session) = returningId.insert(Generic[Foo].to(f).tail.tupled)

...
}

数据访问层设置在利用这些模型的二进制文件中。如果我在 Foos 定义中尝试诸如“for(f

value map is not a member of object DB.this.Foos

我的猜测是它没有被提升到查询中,但我不完全确定。任何澄清将不胜感激。

【问题讨论】:

    标签: scala slick scalaquery


    【解决方案1】:

    尝试做:

      import slick.driver.MySQLDriver.simple._
    

    或您需要的任何驱动程序。您需要其中的隐式类在Foos 上提供map 'extension' 方法。

    【讨论】:

    • 这就是解决方案。希望它被记录得更好:)。谢谢!
    • 不客气!有时在 Scala 中找到正确的导入可能会有点痛苦,如果更多的示例实际列出它们会很酷,但幸运的是我们有 StackOverflow。 ;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 2012-12-04
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    • 2016-06-27
    相关资源
    最近更新 更多