Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slick 'n scala : a TableQuery object without .ddl field

using scala, slick 2.0 & eclipse I have an error I can't explain : "value ddl is not a member of scala.slick.lifted.TableQuery[SqliteSpec.this.Personnes]"

here is the code: I declare a trait like this :

trait sqlite {

val db = Database.forURL("jdbc:sqlite:rdvs.txt", driver = "org.sqlite.JDBC")

class Personnes(tag: Tag) extends Table[Rdv](tag, "RDV") {

  def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
  def nom = column[String]("NOM", O.NotNull)
  def prénom = column[String]("PRENOM")
  def sexe = column[Int]("SEXE")
  def télPortable = column[String]("TELPOR")
  def télBureau = column[String]("TELBUR")
  def télPrivé = column[String]("TELPRI")
  def siteRDV = column[String]("SITE")
  def typeRDV = column[String]("TYPE")
  def libelléRDV = column[String]("LIBELLE")
  def numRDV = column[String]("NUMRDV")
  def étape = column[String]("ETAPE")
  def dateRDV = column[Date]("DATE")
  def heureRDVString = column[String]("HEURE")
  def statut = column[String]("STATUT")
  def orderId = column[String]("ORDERID")

  def * = (id.?, nom, prénom, sexe, télPortable, télBureau, télPrivé,
    siteRDV, typeRDV, libelléRDV, numRDV, étape, dateRDV, heureRDVString,
    statut, orderId) <> (Rdv.tupled, Rdv.unapply _)

  } 
}

and here is the wrong code :

db.withDynSession{

        val personnes=TableQuery[Personnes]
        personnes.ddl.create 
}

althought I followed this official tutorial : http://slick.typesafe.com/doc/2.0.0/schemas.html (section DDL)

Do you know what's wrong? thanks.

like image 843
lolveley Avatar asked Feb 15 '23 00:02

lolveley


1 Answers

Maybe this is useful for somebody: I had the same problem, but my mistake was importing different driver simple implicits. In my main model class had Postgres', but in my tests had H2's (in order to make in-memory integration testing). Switching to the same drivers solved the issue.

like image 126
juanignaciosl Avatar answered Feb 23 '23 14:02

juanignaciosl