slick

Dynamic order by in scala slick with several columns

主宰稳场 提交于 2019-12-22 05:59:09
问题 I have been learning scala, playframework and slick, but i have found a problem. I am trying to make a simple CRUD, with a list controllers that receives a custom filter field, some pagination info (page size and number) and a Seq of string tuples with the field name and the order (asc or desc), and everything is working fine, except for the order by seq, i can not make the order by dynamic. I got the basic structure from Scadiddle blog. So, the basic code is as follows: I have my basic color

How to use a Non Supported Database in Slick 3.1

孤街醉人 提交于 2019-12-22 05:15:21
问题 In the past I have used Slick to access a Vertica database in a server. I recently upgraded my version of Slick from 2.0 to 3.1. Since the upgrade, I am encountering an error (stack trace below). The error indicates that the slick driver cannot be found. According to the Slick 3.2.1 docs, "Other SQL databases can be accessed right away with a reduced feature set". What I am wondering is - Is it still possible to use an "Other" type of database from those directly supported by slick? If so,

slick exception when trying to connect to MySql

99封情书 提交于 2019-12-22 04:39:25
问题 I am trying to follow the slick2 examples using MySql. however when trying to connect to the database I am getting end exception import scala.slick.driver.MySQLDriver.simple._ import slickTest.DB.SuppliersEntity object slickTestDB { def main(args: Array[String]) { println("CreateDb!") val schemaName = "slickTest" val conn_str = "jdbc:mysql://localhost:3306/" + schemaName val database = Database.forURL(conn_str,user="",password="",driver="com.mysql.jdbc.Driver") } } getting this exception

Slick issue when going with PostgreSQL

大憨熊 提交于 2019-12-22 03:53:04
问题 I'm using slick in a scala project to query some tables. //define table object Addresses extends Table[Address]("assetxs.address") { def id = column[Int]("id", O.PrimaryKey) def street = column[String]("street") def number = column[String]("number") def zipcode = column[String]("zipcode") def country = column[String]("country") def * = id ~ street ~ number ~ zipcode ~ country <> (Address, Address.unapply _) } If I use any query of this table it does not work (it says it cannot find my table)

Slick 2.1.0 Filter Max Version in a Table

那年仲夏 提交于 2019-12-22 00:29:17
问题 I'm trying to get the max version number from a table. My table contents are: id externalId name version 1 10 n1 1 2 65 n2 2 3 10 n3 2 4 77 n4 1 In the table above, we have rows that has the maximum version as 2, so my query has to return this maximum version row for the given externalId that I pass into my query. I'm now stuck up with writing the Slick version of it. Any suggestions, pointers? This is what I have so far: (I pass in the externalId) for { myTable1 <- myTable1Elems if myTable1

compose slick dbaction with authenticated action

有些话、适合烂在心里 提交于 2019-12-21 21:49:36
问题 I have my custom authenticated action that is like def Authenticated(rights: String*) = new ActionBuilder[MyAuthenticatedRequest] { *** } In my controller I use this action to check the user has the right to view the page def password = Authenticated(UserRights.USER) { implicit request: MyAuthenticatedRequest[_] => Users.findById(request.account.id) match { case Some(user) => Ok(views.html.settings.password(frontUser, user)) case _ => NotFound } } My oject Users uses slick to retrieve the

Slick 3 - upsert works too slow

こ雲淡風輕ζ 提交于 2019-12-21 17:57:20
问题 I use flowing code for upsert list items case class Item(id: String, text: String) class Items(tag: Tag) extends Table[Item](tag, "items"){ ... } val tbl = TableQuery[Items] def insertItems(items: List[Item]):Future[Int] = { val q = DBIO.sequence(items.map(tbl.insertOrUpdate).toSeq).map(_.sum) db.run(q) } For items list with length 2000, upsert takes ~10 seconds. It's too long... I think, most part time takes compiling queries. How should I rewrite insertItems for acceleration it? 回答1: Use

Higher order functions with Scala Slick for DRY goodness

可紊 提交于 2019-12-21 05:14:20
问题 I have an idea how my data access layer with Scala Slick should look like, but I'm not sure if it's really possible. Let's assume I have a User table which has the usual fields like id, email, password, etc. object Users extends Table[(String, String, Option[String], Boolean)]("User") { def id = column[String]("id", O.PrimaryKey) def email = column[String]("email") def password = column[String]("password") def active = column[Boolean]("active") def * = id ~ email ~ password.? ~ active } And I

LWJGL 3.2.0+ fonts

前提是你 提交于 2019-12-21 02:42:18
问题 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

Why does Slick generate a subquery when take() method is called

依然范特西╮ 提交于 2019-12-20 23:25:49
问题 I use Slick 1.0.0-RC1. I have this definition for table object: object ProductTable extends Table[(Int, String, String, String, Double, java.sql.Date, Int, Option[Int], Int, Boolean)]("products") { def id = column[Int]("productId", O.PrimaryKey, O.AutoInc) def title = column[String]("title") def description = column[String]("description") def shortDescription = column[String]("shortDescription") def price = column[Double]("price") def addedDate = column[java.sql.Date]("addedDate") def brandId