Slick 'n scala: TableQuery object without .ddl field

using scala, slick 2.0 and eclipse I have an error that I cannot explain: "The ddl value is not a member of scala.slick.lifted.TableQuery [SqliteSpec.this.Personnes]"

here is the code: I declare this trait:

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 
}

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

Do you know what happened? thanks.

+4
source share
2 answers

, -: , , . Postgres ', H2 ( ). .

+8

, "edit" ; :

package tests {

@RunWith(classOf[JUnitRunner])
class SqliteSpec extends Specification with sqlite {

"la base sqlite" should {

  "create a new database file" in new Sqlite_avant_chaque_test {

    todo
  }
}

class Sqlite_avant_chaque_test extends Scope {

  println("avant test")

  def abc = {
    db.withDynSession {

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

  }

}
}
}

ok, ; :

import org.specs2.execute.AsResult
import org.specs2.runner.JUnitRunner
import scala.collection.GenTraversableOnce
import org.specs2.time.TimeConversions$longAsTime
import org.specs2.collection.BiMap
import org.specs2.control.Debug$Debuggable
import scala.collection.mutable.ListBuffer
import org.specs2.internal.scalaz.TreeLoc
import org.specs2.mutable.Specification
import scala.xml.NodeSeq
import scala.collection.immutable.List
import org.specs2.text.LinesContent
import org.specs2.specification.Fragments
import scala.math.Numeric
import java.net.URL
import org.specs2.matcher.MatchSuccess
import scala.runtime.Nothing$
import scala.reflect.ClassTag
import org.specs2.main.Arguments
import java.io.InputStream
import org.specs2.data.Sized
import org.junit.runner.RunWith
import org.specs2.specification.Scope
import java.sql.SQLInvalidAuthorizationSpecException
import models.sqlite
import scala.slick.lifted.TableQuery
//import scala.slick.driver.JdbcDriver.simple._
import scala.slick.driver.SQLiteDriver.simple._
import play.api.test.Helpers
import play.test.Helpers

package tests {

@RunWith(classOf[JUnitRunner])
class SqliteSpec extends Specification with sqlite {

sequential

"la base sqlite" should {

  "create a new database file" in new Sqlite_avant_chaque_test {

    todo
  }
}

class Sqlite_avant_chaque_test extends Scope {

  println("avant test")

  //db.withDynSession {
  db.withSession { implicit session: Session =>
    val personnes = TableQuery[Personnes]
    personnes.ddl.create
    println("avant tests, après création base")
  }

}

}
}
0

Source: https://habr.com/ru/post/1523389/


All Articles