27

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.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
brujoand
  • 815
  • 8
  • 15
  • 5
    What does "compile" mean here? There is a known bug in IntelliJ's presentation compiler which prevents it from finding the method. The actual Scala compiler should be able to compile it. – szeiger Feb 23 '15 at 09:11
  • You are right on the money. I never bothered to compile with sbt as IDEA gave me an error. Thanks! – brujoand Feb 23 '15 at 19:38
  • Too bad IntelliJ doesn't get it. Ruins everything when using it for a large project where IDE is a must. Which is kinda the whole point - to get compile time checking and autocompletions – kornfridge Mar 27 '15 at 16:43
  • Nothing in https://github.com/slick/slick/blob/master/slick/src/main/scala/slick/lifted/Query.scala suggests that the method exists. Is it implemented with macros somehow? (forgive my ignorance if this doesn't make sense, I'm not experienced with macros) – Bogdan Mar 31 '15 at 09:13
  • For the reference, I believe that the issue link on the Jetbrains website is: https://youtrack.jetbrains.com/issue/SCL-8079 – Bogdan Mar 31 '15 at 09:50
  • 5
    Note for people encountering the same unresolved symptom "result": you may (as i did) have forgotten to import api – anmorand Oct 25 '15 at 23:23
  • 2
    For me importing slick.driver.MySQLDriver.api._ solved the problem. – Everton Mendonça Nov 13 '15 at 18:03

4 Answers4

11

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!

joesan
  • 13,963
  • 27
  • 95
  • 232
3

If someone is facing a similar issue:

no result method on TableQuery

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

0

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

Bhavya Latha Bandaru
  • 1,078
  • 12
  • 21
-4

You may try

val result = db.withSession(implicit session => issueQuery.list)
Arseniy Zhizhelev
  • 2,381
  • 17
  • 21