slick

Play Slick exception in Specs “Task slick.backend.DatabaseComponent rejected from java.util.concurrent.ThreadPoolExecutor”

随声附和 提交于 2019-12-08 02:11:44
问题 I am getting a ThreadPoolException from Slick using Play when running my Spec tests, This is using Play 2.4.x, Slick 3, Specs 2? My test looks like: val jsonHeaders = FakeHeaders(Seq((CONTENT_TYPE, MimeTypes.JSON))) def fakeApp: FakeApplication = FakeApplication(additionalConfiguration = Map( "slick.dbs.default.driver" -> "slick.driver.H2Driver$", "slick.dbs.default.db.driver" -> "org.h2.Driver", "slick.dbs.default.db.url" -> "jdbc:h2:mem:test;MODE=PostgreSQL;DATABASE_TO_UPPER=FALSE" )) "Add

Scala Type Mismatch issue when using import from different scope

久未见 提交于 2019-12-07 23:15:59
问题 In my project(play 2.4 with slick 3.0), I have a setup: using MySQL for production and H2 for unit testing(start to feel that it is a horrible idea). To do that, I have to import slick.driver.JdbcProfile instead of any specific driver (e.g. slick.driver.MySQLDriver ) and import its api._ in my DAO class, like this: class SomeDAO(val context: MyContext){ import context.profile.api._ import context.SOME_TYPE def invoke(para: SOME_TYPE) = { ... } // other DBIO... } Everything is OK so far,

How to retrieve the auto incremented ID using slick / plainSQL?

非 Y 不嫁゛ 提交于 2019-12-07 17:48:28
Isn't there a slick/plainSQL native solution to retrieve the auto incremented id of the current INSERT? userId is an auto incremental field in my mySQL table. sql""" INSERT INTO `table`(`email`) OUTPUT INSERTED.userId VALUES ("theEmailAdress@test.de") """.as[Int].firstOption Help would be greatly appreciated. Cheers Oliver Ziouas Depends on the database. For MS SQL it's SCOPE_IDENTITY(), for mySQL it's LAST_INSERT_ID(). Try searching for equivalent for your DB if it's none of the above. Added by cvogt : There is currently no slick-built-in feature for plain SQL for this and no way to access

Calling stored procedures with Slick

烈酒焚心 提交于 2019-12-07 17:04:08
问题 How do I use Slick to call a stored procedure? I want it to be type safe / injection safe. (ie, I don't want any SQL query strings in my code...) According to the docs, Slick includes "Type-safe support of stored procedures" (http://slick.typesafe.com/doc/1.0.0/introduction.html) But I do not see any example in the docs of how to do it. 回答1: That's a typo. It should read "Type-safe support of scalar database functions". At the moment you have to use plain SQL to call stored procedures. Also

Scala Play 2.2 Slick 1.0.1 - future { Try {…} } Timed out waiting for a free available connection

不打扰是莪最后的温柔 提交于 2019-12-07 17:03:53
问题 I have a scala.html page that makes AJAX calls in a Play 2.2.1, Scala 2.10.2, Slick 1.0.1, Postgres 9.3 application. The following synchronous code works fine. It parses the request query string and calls the method Schools.findSchoolsByFilter , which makes a scala slick call to a table and filters the results based upon the SchoolFilter object and returns a Try[List[School]] def listSchools = Action { implicit request => db.withSession { implicit s: Session => Schools.findSchoolsByFilter

Dynamic query parameters in Slick (sorting)

随声附和 提交于 2019-12-07 13:57:47
问题 I'm trying to convert anorm queries to slick in one of Play 2.3 samples, but I'm not sure how to implement dynamic sorting. This is the original method: def list(page: Int = 0, pageSize: Int = 10, orderBy: Int = 1, filter: String = "%"): Page[(Computer, Option[Company])] = { val offest = pageSize * page DB.withConnection { implicit connection => val computers = SQL( """ select * from computer left join company on computer.company_id = company.id where computer.name like {filter} order by

Slick 3: how to drop and take on collections with some relations

三世轮回 提交于 2019-12-07 12:47:49
问题 I'm working with Play! Scala 2.4 and Slick 3. I have a many to many relations as following: class Artists(tag: Tag) extends Table[Artist](tag, "artists") { def id = column[Long]("artistid", O.PrimaryKey, O.AutoInc) def name = column[String]("name") def * = (id.?, name) <> ((Artist.apply _).tupled, Artist.unapply) } The relation table: class ArtistsGenres(tag: Tag) extends Table[ArtistGenreRelation](tag, "artistsgenres") { def artistId = column[Long]("artistid") def genreId = column[Int](

Describing optional fields in Slick

落爺英雄遲暮 提交于 2019-12-07 10:43:32
问题 The Slick DSL allows two ways to create optional fields in tables. For this case class: case class User(id: Option[Long] = None, fname: String, lname: String) You can create a table mapping in one of the following ways: object Users extends Table[User]("USERS") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) def fname = column[String]("FNAME") def lname = column[String]("LNAME") def * = id.? ~ fname ~ lname <> (User, User.unapply _) } and object Users extends Table[User]("USERS") { def

组件集合

匆匆过客 提交于 2019-12-07 10:00:57
收集常用的组件 React UI框架 - antd 轮播图组件 - react-slick( https://github.com/akiran/react-slick) 来源: CSDN 作者: 最亮的心 链接: https://blog.csdn.net/cs840610862/article/details/90027068

slick error : type TupleXX is not a member of package scala (XX > 22)

浪尽此生 提交于 2019-12-07 09:32:08
问题 I want to write a database schema using lifted slick. I have huge tables with more than 100 columns. So i have this error for all the tables that exceed 22 columns : type Tuple45 is not a member of package scala Here is the code of one of the tables : object adrepost extends Table[(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, Date, Boolean, Date, Int, Boolean, String, String, String, String, String,