Compilation Errors while definning Table Schema - Slick 3.1.1

274 views
Skip to first unread message

Sujit Pradhan

unread,
Aug 18, 2016, 2:15:50 PM8/18/16
to Slick / ScalaQuery
Hello All,

             I am trying to evaluate "Slick" for my Scala Project to connect to "PostgreSQl" db backend. I am using the following version of Slick in my "Gradle Configuration":

compile group: 'com.typesafe.slick', name: 'slick_2.10', version: '3.1.0'.
compile group: 'postgresql', name: 'postgresql', version: '9.1-901-1.jdbc4'
compile group: 'org.slf4j', name: 'slf4j-nop', version: '1.6.4'

But while defining the schema table and mapped class, as given in the "Slick-3.1.3" documentation manual , I am getting compilation errors in my "Eclipse" and gradle.

I am using the following example from documentation:

class Suppliers(tag: Tag) extends Table[(Int, String, String, String, String, String)](tag, "SUPPLIERS") {
  def id = column[Int]("SUP_ID", O.PrimaryKey) // This is the primary key column
  def name = column[String]("SUP_NAME")
  def street = column[String]("STREET")
  def city = column[String]("CITY")
  def state = column[String]("STATE")
  def zip = column[String]("ZIP")
  // Every table needs a * projection with the same type as the table's type parameter
  def * = (id, name, street, city, state, zip)
}

I am getting following compilation errors: 

1. error: slick.model.Table does not take type parameters
2. error: too many arguments for constructor Object: ()Object
3. error: not found: value column

Any help will be appreciated.

Eric Aldinger

unread,
Nov 16, 2016, 7:26:20 PM11/16/16
to Slick / ScalaQuery
You may want to import lifted,
Remove any import of slick.model.table as it could shadow the table trait you want from the driver (from slick.profile)
add Rep[T] type to each column and a ProvenShape type to the def *

This is a sample from the 3.1 hello world template


import slick.driver.PostgresDriver.api._
import slick.lifted.{ProvenShape, ForeignKeyQuery}

class Coffees(tag: Tag)
extends Table[(String, Int, Double, Int, Int)](tag, "COFFEES") {

def name: Rep[String] = column[String]("COF_NAME", O.PrimaryKey)
def supID: Rep[Int] = column[Int]("SUP_ID")
def price: Rep[Double] = column[Double]("PRICE")
def sales: Rep[Int] = column[Int]("SALES")
def total: Rep[Int] = column[Int]("TOTAL")

def * : ProvenShape[(String, Int, Double, Int, Int)] =
(name, supID, price, sales, total)

// A reified foreign key relation that can be navigated to create a join
def supplier: ForeignKeyQuery[Suppliers, (Int, String, String, String, String, String)] =
foreignKey("SUP_FK", supID, TableQuery[Suppliers])(_.id)
}

snehalata nagaje

unread,
Aug 12, 2018, 12:04:08 PM8/12/18
to Slick / ScalaQuery

Thanks ,This solution works.
Reply all
Reply to author
Forward
0 new messages