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

I start with slick and scala using playframewok

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

My problem is that I cannot execute some important methods, such as "list, foreach" for {} yield ... "

I tried a standalone example and works with the same smooth 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 do not know what the problem is, so every help would be appreciated.

+4
source share
2 answers

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

+2
source

import scala.slick.driver.PostgresDriver.simple._ :

import model._
import scala.slick.lifted.Query
import scala.slick.driver.PostgresDriver.simple._

object ArticlesService {

  val PAGE_SIZE  :Int = 100

    def getPaginatedResult(pageNumber : Int) (implicit s: scala.slick.session.Session)= {
      val query= Query(Articles)
      query.drop(pageNumber * PAGE_SIZE).take(PAGE_SIZE).list()
    }

}
0

All Articles