slick-3.0

How to use Slick code generator to include database views as well?

蓝咒 提交于 2019-12-06 04:43:15
问题 I'm trying to generate the Scala code for the database tables and views in my schema using Slick 3.0.3. Taking this blog as example I have the following file build.sbt . However, this will generate code for my database tables and will not include the database views. How can I get the views generated as well? According to slick issue 1022 I see it is possible to do but the API doesn't look alike and slick.codegen.SourceCodeGenerator doesn't have a getTables or defaultTables to include view

Slick 3.0 how to update variable column list, which number is know only in Runtime

微笑、不失礼 提交于 2019-12-05 07:57:58
Is it possible to update variable column list, which number is know only in runtime by slick 3.0? Below is example what I want to do (won't compile) var q: Query[UserTable, UserTable#TableElementType, Seq] = userTable var columns = List[Any]() var values = List[Any]() if (updateCommands.name.isDefined) { columns = q.name :: columns values = updateCommands.name.get :: values } if (updateCommands.surname.isDefined) { columns = q.surname :: columns values = updateCommands.surname.get :: values } q = q.filter(_.id === updateCommands.id).map(columns).update(values) Here is what I've done in Slick 3

How can I omit case class fields in a slick table mapping?

一曲冷凌霜 提交于 2019-12-04 22:29:34
问题 I'm teaching myself some Scala and am currently getting my feet wet with slick (3.1) + play framework, so maybe the answer is simple here and I'm missing something obvious. I have the following model and Table case class User(id: Long = -1, username: String, passwordHash: String, email: Option[String] = None) class Users(tag: Tag) extends Table[User](tag, "USERS") { def id = column[Long]("ID", O.PrimaryKey, O.AutoInc) def username = column[String]("USERNAME") def email = column[Option[String]

Slick 3.0 many-to-many query with the join as an iterable

一笑奈何 提交于 2019-12-04 20:52:44
问题 I've created a many-to-many collection using Slick 3.0, but I'm struggling to retrieve data in the way I want. There is a many-to-many relationship between Events and Interests. Here are my tables: case class EventDao(title: String, id: Option[Int] = None) class EventsTable(tag: Tag) extends Table[EventDao](tag, "events") { def id = column[Int]("event_id", O.PrimaryKey, O.AutoInc) def title = column[String]("title") def * = ( title, id.?) <> (EventDao.tupled, EventDao.unapply) def interests =

How to apply manually evolutions in tests with Slick and Play! 2.4

白昼怎懂夜的黑 提交于 2019-12-04 02:33:05
I would like to manually run my evolution script at the beginning of each test file. I'm working with Play! 2.4 and Slick 3. According to the documentation, the way to go seems to be: Evolutions.applyEvolutions(database) but I don't manage to get an instance of my database. In the documentation play.api.db.Databases is imported in order to get a database instance but if I try to import it, I get this error: object Databases is not a member of package play.api.db How can I get an instance of my database in order to run the evolution script? Edit: as asked in the comments, here is the entire

How can I omit case class fields in a slick table mapping?

送分小仙女□ 提交于 2019-12-03 14:54:56
I'm teaching myself some Scala and am currently getting my feet wet with slick (3.1) + play framework, so maybe the answer is simple here and I'm missing something obvious. I have the following model and Table case class User(id: Long = -1, username: String, passwordHash: String, email: Option[String] = None) class Users(tag: Tag) extends Table[User](tag, "USERS") { def id = column[Long]("ID", O.PrimaryKey, O.AutoInc) def username = column[String]("USERNAME") def email = column[Option[String]]("EMAIL") def passwordHash = column[String]("PASSWD_HASH") def * = (id, username, passwordHash, email)

Slick 3.0 many-to-many query with the join as an iterable

回眸只為那壹抹淺笑 提交于 2019-12-03 13:26:02
I've created a many-to-many collection using Slick 3.0, but I'm struggling to retrieve data in the way I want. There is a many-to-many relationship between Events and Interests. Here are my tables: case class EventDao(title: String, id: Option[Int] = None) class EventsTable(tag: Tag) extends Table[EventDao](tag, "events") { def id = column[Int]("event_id", O.PrimaryKey, O.AutoInc) def title = column[String]("title") def * = ( title, id.?) <> (EventDao.tupled, EventDao.unapply) def interests = EventInterestQueries.query.filter(_.eventId === id) .flatMap(_.interestFk) } object EventQueries {

can't find method result on TableQuery with slick 3.0.0-RC1

纵然是瞬间 提交于 2019-12-03 11:37:46
问题 I am trying out Slick 3.0.0-RC1 and I'm running in to an odd problem. Such is my code: import slick.driver.SQLiteDriver.api._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Await import scala.concurrent.duration.Duration lazy val db = Database.forURL( url = "jdbc:sqlite:thebase.db", driver = "org.sqlite.JDBC" ) case class Issue(id: Option[Int], name: String) class IssueTable(tag: Tag) extends Table[Issue](tag, "issue"){ def id = column[Int]("issue_id", O

What is the right way to work with slick's 3.0.0 streaming results and Postgresql?

限于喜欢 提交于 2019-12-03 09:16:32
问题 I am trying to figure out how to work with slick streaming. I use slick 3.0.0 with postgres driver The situation is following: server have to give client sequences of data split into chunks limited by size(in bytes). So, I wrote following slick query: val sequences = TableQuery[Sequences] def find(userId: Long, timestamp: Long) = sequences.filter(s ⇒ s.userId === userId && s.timestamp > timestamp).sortBy(_.timestamp.asc).result val seq = db.stream(find(0L, 0L)) I combined seq with akka

can't find method result on TableQuery with slick 3.0.0-RC1

為{幸葍}努か 提交于 2019-12-03 01:11:53
I am trying out Slick 3.0.0-RC1 and I'm running in to an odd problem. Such is my code: import slick.driver.SQLiteDriver.api._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Await import scala.concurrent.duration.Duration lazy val db = Database.forURL( url = "jdbc:sqlite:thebase.db", driver = "org.sqlite.JDBC" ) case class Issue(id: Option[Int], name: String) class IssueTable(tag: Tag) extends Table[Issue](tag, "issue"){ def id = column[Int]("issue_id", O.PrimaryKey) def name = column[String]("name") def * = (id.?, name) <> (Issue.tupled, Issue.unapply _) }