Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbols (foreach, list,...) using Slick-play

I'm beginning with slick and scala, using playframewok

I have configured my project to work with play 2.2.0 using play-slick 0.5.0.8

My problem is that I can't execute some essential methods like "list , foreach, for{}yield ..."

I have tried a stand alone example and it works with the same slick version 1.0.1??

Here is the project build file

import sbt._
import Keys._
import play.Project._

object Build extends Build {

  val appName         = "homePage"
  val appVersion      = "1.0-ALPHA"

  val appDependencies = Seq(
    // Add your project dependencies here,
    jdbc,
    "com.typesafe.play" %% "play-slick" % "0.5.0.8"  ,
    "postgresql" % "postgresql" % "9.1-901-1.jdbc4",
    "com.typesafe.slick" %% "slick" % "1.0.1"

  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // add web app as
    playAssetsDirectories <+= baseDirectory / "webapp"
  )

}

My model ::

package model

import java.util.Calendar
import scala.slick.driver.PostgresDriver.simple._

case class Article(id: Long,
                   content: String,
                   date: java.sql.Date)


object Articles extends Table[Article]("articles") {
  def id = column[Long]("art_id", O.PrimaryKey , O.AutoInc) // This is the primary key column

  def content = column[String]("art_content", O.NotNull)

  def date = column[java.sql.Date]("art_date", O.NotNull, O.Default(new java.sql.Date(Calendar.getInstance().getTime.getTime)))

  def * = id ~ content ~ date  <> (Article.apply _, Article.unapply _)

}

here is the code that doesn't work

 query foreach { case (content, date) =>
    println("  " + name + ": " + count)
  }
  //:: cannot resolve the symbol foreach

  same thing for [for , yield]
   (for(p <- Props if p.key === k) yield p.value).firstOption

I don't know what is the problem, so every help will be appreciated.

like image 866
Ben Rhouma Zied Avatar asked Oct 26 '13 07:10

Ben Rhouma Zied


1 Answers

import scala.slick.driver.PostgresDriver.simple._ in the file, where you try to call foreach.

like image 180
cvogt Avatar answered Oct 05 '22 21:10

cvogt