Importing anorm.SQL in IntelliJ IDEA 13

666 views Asked by At
  • IntelliJ 13 Community Edition
  • Play Framework 2.2
  • Scala 2.10.2

I am importing anorm._ and using SQL in my object. The object starts off as follows:

package controllers

import play.api.mvc._
import play.api.db.DB
import play.api.Play.current
import anorm._

object Walks extends Controller {

 val futureWalksSql = SQL("SELECT * FROM walks where evt_date > now()")

IntelliJ cannot resolve symbol SQL. If I ctrl+Enter, after anorm. there is no SQL option, although there is a .Sql trait, object and class.

When I run the play project, it all works just fine, with no compilation errors so this Scala is syntactically correct but IntelliJ isn't picking this up. I have created the idea files by calling idea from within the play console and I've also tried idea with-sources=yes.

How do I get IntelliJ Community Editon to pick up anorm.SQL? What is so special about this object? I'm still learning Scala and so this might be a Scala issue.

1

There are 1 answers

0
serejja On

SQL is a method defined in a package object anorm. So when you import anorm._ you import the entire package with the package object as well. I have actually no clue why Idea does not pick this up. But if you look into the package object sources you can see that the SQL method is just a wrapper on anorm.Sql.sql(inSql: String).

As a workaround you may try to import anorm.Sql._ and use sql("select 1") instead of SQL("select 1")