can't find method result on TableQuery with sl

2019-03-14 08:13发布

I am trying out Slick 3.0.0-RC1 and I'm running in to an odd problem.

Such is my code:

import slick.driver.SQLiteDriver.api._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.duration.Duration

lazy val db = Database.forURL(
  url = "jdbc:sqlite:thebase.db",
  driver = "org.sqlite.JDBC"
)

case class Issue(id: Option[Int], name: String)     

class IssueTable(tag: Tag) extends Table[Issue](tag, "issue"){
  def id = column[Int]("issue_id", O.PrimaryKey)
  def name = column[String]("name")
  def * = (id.?, name) <> (Issue.tupled, Issue.unapply _)
}

val issueQuery = TableQuery[IssueTable]

Await.result(db.run(issueQuery.result), Duration.Inf) // This does not compile

The error is:

"Cannot resolve symbol result"

Reading the docs I can't really see why this should fail. Am I missing something here?

Resolution

szeiger pointed out that this could be a bug in 'IntelliJ's presentation compiler', and that was spot on.

4条回答
迷人小祖宗
2楼-- · 2019-03-14 08:58

If someone is facing a similar issue:

no result method on TableQuery

DOUBLE check whether you have import slick.jdbc.PostgresProfile.api._

查看更多
Juvenile、少年°
3楼-- · 2019-03-14 09:02

I did hit the same problem and here is what I did to get rid of it:

  1. Updated IntelliJ to version 14.1.3
  2. Used Scala Plugin version 1.5

My scala version is 2.11.6

I hope this helps somebody who might run into the same problem!

查看更多
疯言疯语
4楼-- · 2019-03-14 09:07

You may try

val result = db.withSession(implicit session => issueQuery.list)
查看更多
看我几分像从前
5楼-- · 2019-03-14 09:10

This is a regular problem I faced quite often with IntelliJ IDEA .

If using activator, the command - "activator idea" helped me resolve the issue.

It re-created the .idea and IdeaProject.iml files and then re-loaded the project. I currently use activator-1.3.4

查看更多
登录 后发表回答