slick

How to define generic type in Scala?

佐手、 提交于 2019-12-03 15:03:54
In Slick 2, we can map tables like this: case class Cooler(id: Option[Int], minTemp: Option[Double], maxTemp: Option[Double]) /** * Define table "cooler". */ class Coolers(tag: Tag) extends Table[Cooler](tag, "cooler") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) def minTemp = column[Double]("min_temp", O.Nullable) def maxTemp = column[Double]("max_temp", O.Nullable) def * = (id.?, minTemp.?, maxTemp.?) <> (Cooler.tupled, Cooler.unapply _) } object Coolers { val tableQuery = TableQuery[Coolers] } because I have a lot of tables, I want to define generic methods for them, like find ,

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)

How to call a stored procedure and get return value in Slick (using Scala)

扶醉桌前 提交于 2019-12-03 14:32:29
I'm trying to call a stored procedure from Slick 3.0 (in Play Framework). I've been over and over the documentation, but unfortunately the plain SQL docs at Typesafe never show calling a stored procedure. What seems pretty straightforward is causing a typically obscure Scala error message: val f = Try { val call: DBIO[Int] = sqlu"?=call app_glimpulse_invitation_pkg.n_send_invitation(${i.token}, ${i.recipientAccountId.getOrElse(None)}, ${i.email}, ${i.phoneNumber}, ${requestType})" val result: Future[Int] = db.run(call) val r = Await.result(result, Duration.Inf) // should only return one; use

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 {

How can I use the new Slick 2.0 HList to overcome 22 column limit?

谁都会走 提交于 2019-12-03 11:38:16
问题 I'm currently writing Slick code to target an old schema with two tables > 22 columns. How do I use the new HList code? I've got 2.0-M3 working fine in other respects under Scala 2.10.3. Here's the syntax I'm currently using with case classes / tuples. What would I do to use the new HLists mentioned in the docs? case class Joiner( id: Int, name: Option[String], contact: Option[String] ) class Joiners(tag: Tag) extends Table[Joiner](tag, "joiner") { def id = column[Int]("id", O.PrimaryKey, O

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

Connecting to Mysql using Slick 3.0 - No username, no password and bogus driver does not equal error

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm writing a veery simple scala script to connect to Mysql using slick 3. My build.sbt looks like this: name := "slick_sandbox" version := "1.0" scalaVersion := "2.11.7" libraryDependencies ++= Seq ( "com.typesafe.slick" %% "slick" % "3.0.3" , "org.slf4j" % "slf4j-nop" % "1.6.4" , "mysql" % "mysql-connector-java" % "5.1.6" ) application.conf : Drivder is an intentional mistake; also, I did not provide a db username or password! mysqldb = { url = "jdbc:mysql://localhost/slickdb" driver = com . mysql . jdbc . Drivder connectionPool

Slick 3 Transactions

孤街醉人 提交于 2019-12-03 09:50:15
问题 I'm confused by the way the slick 3 documentation describes transactions. I have slick 2 code that looks like this: def doSomething(???) = DB.withTransaction { implicit session => userDao.doSomething(???) addressDao.doSomething(???) contactDao.doSomething(???) } How can i span a transaction in slick 3? 回答1: Please have a look at the documentation here http://slick.typesafe.com/doc/3.0.0/dbio.html#transactions-and-pinned-sessions The idea is that you wrap a sequence of IO operations into a

LWJGL 3.2.0+ fonts

眉间皱痕 提交于 2019-12-03 09:31:40
I've been working with lwjgl for some time, and recently I've decided to switch from fixed function pipeline to shaders. So, the first thing when I'm starting my program, I set the ContextAttrib(3, 2) so I will be using GL 3.2+. The problem is that when I switch on higher version of GL a lot of functions become unsupported. Before switching to higher GL, I've used Slick's font (TrueTypeFont) to render the text I needed, but now the drawString method of TrueTypeFont has an unsupported function within itself. I've tried to google for solution, but nothing came up. Does anyone know if it is

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