2

I am having a problem similar to this

But I am using scala 2.11.1, slick 3.2.0, and compiling manually with SBT, not using IntelliJ.

I've defined an dntity for database:

case class ScheduleItem(id:Option[Int], cron:String, script:String, created_at:Long, updated_at:Long, created_by:String, updated_by:String)

object ScheduleItems {

  class ScheduleItemsT(tag: Tag) extends Table[ScheduleItem](tag, "schedule_items") {

    def id = column[Int]("id", O.PrimaryKey, O.AutoInc)

    def cron = column[String]("column")

    def script = column[String]("script")

    def created_at = column[Long]("created_at", SqlType("timestamp without time zone"))

    def updated_at = column[Long]("updated_at", SqlType("timestamp without time zone"))

    def created_by = column[String]("created_by")

    def updated_by = column[String]("updated_by")

    def * = (id.?, cron, script, created_at, updated_at, created_by, updated_by) <> (ScheduleItem.tupled, ScheduleItem.unapply)
  }

  val table = TableQuery[ScheduleItemsT]
}

I try to run a simple query to get all elements in databsae:

db.run(ScheduleItems.table.result)

When compiling, this is SBT output:

[info] Loading project definition from /home/claudino/Projetos/Testes/Agendador2_0/project
[info] Set current project to Agendador2_0 (in build file:/home/claudino/Projetos/Testes/Agendador2_0/)
[info] Compiling 3 Scala sources to /home/claudino/Projetos/Testes/Agendador2_0/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling...
[info]   Compilation completed in 10.646 s
[error] /home/claudino/Projetos/Testes/Agendador2_0/src/main/scala/com/webradar/qns/Main.scala:13: value result is not a member of slick.lifted.TableQuery[com.webradar.Main.schedule.model.ScheduleItems.ScheduleItemsT]
[error]     db.run(ScheduleItems.table.result)
[error]                                ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 13 s, completed 04/04/2017 11:42:20

That is, differ from slick 3.20 documentation, result is not a member of TableQuery[SomeType]. Any idea?

Community
  • 1
  • 1
André Claudino
  • 558
  • 4
  • 18
  • if you need a full working example, I built this minimal example sometime ago: https://github.com/pedrorijo91/play-slick3-steps. There's also a blog post that may become handy: http://pedrorijo.com/blog/play-slick/ – pedrorijo91 Apr 04 '17 at 22:30

1 Answers1

4

I guess you simply forgot to import the slick profile api. In your case:

import slick.jdbc.PostgresProfile.api._
Roman
  • 5,651
  • 1
  • 30
  • 41
  • Thanks, I've imported in another file, where I define database connection. This file is beeing imported, but looks it's not enough.Thanks. – André Claudino Apr 04 '17 at 20:12