1

I am a new Slick user and I have a problem with the "*" method of a table. I can't get it right. Here the code : package models

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

import scala.concurrent.ExecutionContext.Implicits.global

case class Coordonnee (id:Option[Long],
                       email:String,email_publique:Boolean,email_publique_assoc:Boolean,
                       rue:String,rue_publique:Boolean,rue_publique_assoc:Boolean,
                       codepostal:String,codepostal_publique:Boolean,codepostal_publique_assoc:Boolean,
                       ville:String,ville_publique:Boolean,ville_publique_assoc:Boolean,
                       phone:String,phone_publique:Boolean,phone_publique_assoc:Boolean,
                       phonemaison:String,phonemaison_publique:Boolean,phonemaison_publique_assoc:Boolean
                      )
class Coordonnees(tag:Tag) extends extends Table[Coordonnee](tag, "COORDONNEES"){

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

  def email = column[String]("EMAIL")
  def email_publique = column[Boolean]("EMAIL_PUBLIQUE")
  def email_publique_assoc = column[Boolean]("EMAIL_PUBLIQUE_ASSOC")

  def rue = column[String]("RUE")
  def rue_publique = column[Boolean]("RUE_PUBLIQUE")
  def rue_publique_assoc = column[Boolean]("RUE_PUBLIQUE_ASSOC")

  def codepostal = column[String]("CODEPOSTAL")
  def codepostal_publique = column[Boolean]("CODEPOSTAL_PUBLIQUE")
  def codepostal_publique_assoc = column[Boolean]("CODEPOSTAL_PUBLIQUE_ASSOC")

  def ville = column[String]("VILLE")
  def ville_publique = column[Boolean]("VILLE_PUBLIQUE")
  def ville_publique_assoc = column[Boolean]("VILLE_PUBLIQUE_ASSOC")

  def phone = column[String]("PHONE")
  def phone_publique = column[Boolean]("PHONE_PUBLIQUE")
  def phone_publique_assoc = column[Boolean]("PHONE_PUBLIQUE_ASSOC")

  def phonemaison = column[String]("PHONEMAISON")
  def phonemaison_publique = column[Boolean]("PHONEMAISON_PUBLIQUE")
  def phonemaison_publique_assoc = column[Boolean]("PHONEMAISON_PUBLIQUE_ASSOC")

  def * : ProvenShape[(Long,
    String,Boolean,Boolean,
    String, Boolean,Boolean,
    String,Boolean,Boolean,
    String,Boolean,Boolean,
    String,Boolean,Boolean,
    String,Boolean,Boolean)]=
    (id,
    email, email_publique, email_publique_assoc,
    rue,rue_publique,rue_publique_assoc,
    codepostal,codepostal_publique, codepostal_publique_assoc,
    ville,ville_publique,ville_publique_assoc,
    phone,phone_publique,phone_publique_assoc,
    phonemaison,phonemaison_publique,phonemaison_publique_assoc
    ) <> (Coordonnee.tupled, Coordonnee.unapply)
}

the error in the Idea IDE is :

Error:Play 2 Compiler: Required level: slick.lifted.FlatShapeLevel Source type: (slick.lifted.Rep[Long], slick.lifted.Rep[String], slick.lifted.Rep[Boolean], slick.lifted.Rep[Boolean], slick.lifted.Rep[String], slick.lifted.Rep[Boolean], slick.lifted.Rep[Boolean], slick.lifted.Rep[String], slick.lifted.Rep[Boolean], slick.lifted.Rep[Boolean], slick.lifted.Rep[String], slick.lifted.Rep[Boolean], slick.lifted.Rep[Boolean], slick.lifted.Rep[String], slick.lifted.Rep[Boolean], slick.lifted.Rep[Boolean], slick.lifted.Rep[String], slick.lifted.Rep[Boolean], slick.lifted.Rep[Boolean]) Unpacked type: (Option[Long], String, Boolean, Boolean, String, Boolean, Boolean, String, Boolean, Boolean, String, Boolean, Boolean, String, Boolean, Boolean, String, Boolean, Boolean)

I am using Slick v3.1.1. If I delete the

<> (Coordonnee.tupled, Coordonnee.unapply)

it works but I need it.

first edit : modification of "extends Table[..." as suggested by pamu

1 Answer 1

3

Instead of Table[(....)] use Table[Coordonnee]

Instead of this code

 class Coordonnees(tag:Tag) extends Table[(Long,
  String,Boolean,Boolean,
  String, Boolean,Boolean,
  String,Boolean,Boolean,
  String,Boolean,Boolean,
  String,Boolean,Boolean,
  String,Boolean,Boolean

  )](tag, "COORDONNEES") { //.... }

Use this code

 class Coordonnees(tag:Tag) extends Table[Coordonnee] { //... }

Complete code that compiles

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

import scala.concurrent.ExecutionContext.Implicits.global

case class Coordonnee(id: Option[Long],
                      email: String, email_publique: Boolean, email_publique_assoc: Boolean,
                      rue: String, rue_publique: Boolean, rue_publique_assoc: Boolean,
                      codepostal: String, codepostal_publique: Boolean, codepostal_publique_assoc: Boolean,
                      ville: String, ville_publique: Boolean, ville_publique_assoc: Boolean,
                      phone: String, phone_publique: Boolean, phone_publique_assoc: Boolean,
                      phonemaison: String, phonemaison_publique: Boolean, phonemaison_publique_assoc: Boolean
                     )

class Coordonnees(tag: Tag) extends Table[Coordonnee](tag, "COORDONNEES") {

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

  def email = column[String]("EMAIL")

  def email_publique = column[Boolean]("EMAIL_PUBLIQUE")

  def email_publique_assoc = column[Boolean]("EMAIL_PUBLIQUE_ASSOC")

  def rue = column[String]("RUE")

  def rue_publique = column[Boolean]("RUE_PUBLIQUE")

  def rue_publique_assoc = column[Boolean]("RUE_PUBLIQUE_ASSOC")

  def codepostal = column[String]("CODEPOSTAL")

  def codepostal_publique = column[Boolean]("CODEPOSTAL_PUBLIQUE")

  def codepostal_publique_assoc = column[Boolean]("CODEPOSTAL_PUBLIQUE_ASSOC")

  def ville = column[String]("VILLE")

  def ville_publique = column[Boolean]("VILLE_PUBLIQUE")

  def ville_publique_assoc = column[Boolean]("VILLE_PUBLIQUE_ASSOC")

  def phone = column[String]("PHONE")

  def phone_publique = column[Boolean]("PHONE_PUBLIQUE")

  def phone_publique_assoc = column[Boolean]("PHONE_PUBLIQUE_ASSOC")

  def phonemaison = column[String]("PHONEMAISON")

  def phonemaison_publique = column[Boolean]("PHONEMAISON_PUBLIQUE")

  def phonemaison_publique_assoc = column[Boolean]("PHONEMAISON_PUBLIQUE_ASSOC")

  def *
  = (id.?,
    email, email_publique, email_publique_assoc,
    rue, rue_publique, rue_publique_assoc,
    codepostal, codepostal_publique, codepostal_publique_assoc,
    ville, ville_publique, ville_publique_assoc,
    phone, phone_publique, phone_publique_assoc,
    phonemaison, phonemaison_publique, phonemaison_publique_assoc
    ) <> (Coordonnee.tupled, Coordonnee.unapply)
}

notice in the * method id replaced with id.?

2
  • Thank you for the tip. But this does not solve my problem.
    – f7h
    Sep 25, 2016 at 14:54
  • See if sbt compile works first. Intellij isn't the ultimate answer. Sep 25, 2016 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.