play-slick

How to apply play-evolutions when running tests in play-framework?

陌路散爱 提交于 2019-12-10 12:42:22
问题 I have problems with evolutions when running tests in play framework using playframework v2.6.6 for scala play-slick v3.0.2 play-slick-evolutions v3.0.2 The test looks like this: class TestFooController extends PlaySpec with GuiceOneServerPerSuite { "foo endpoint should store some data" in { val wsClient = app.injector.instanceOf[WSClient] val url = s"http://localhost:$port/foo" val requestData = Json.obj("foo" -> "bar") val response = await(wsClient.url(url).post(requestData)) response

Scala/Slick plain SQL: retrieve multiple results into list of maps

守給你的承諾、 提交于 2019-12-10 12:13:20
问题 I have a simple method that retrieves single row from a db table: object Data { implicit val getListStringResult = GetResult[List[Object]] ( r => (1 to r.numColumns).map(_ => r.nextObject).toList ) def getUser(id: Int): Option[Map[String, Object]] = DB.withSession { val columns = MTable.getTables(None, None, None, None).list.filter(_.name.name == "user").head.getColumns.list.map(_.column) sql"""SELECT * FROM "user" WHERE "id" = $id""".as[List[Object]].firstOption.map(columns zip _ toMap) } }

Run Evolutions in Command Line

谁说胖子不能爱 提交于 2019-12-10 03:19:21
问题 It's my first day tinkering with the Play framework, and I'm having a hard time with evolutions. I'm using Play 2.4. I picked a sample app from the many that come up in activator ui , it uses play-slick and play-slick-evolutions for DB connection and evolutions. I've perused the docs, but I can't seem to find a way to run the evolutions from the command line. When I run activator on bash I get thrown into a shell, and the help doesn't bring up anything about running evolutions, or slick. I've

Start generating auto increment column value from default in slick

♀尐吖头ヾ 提交于 2019-12-08 09:58:26
问题 I having a table column holds auto increment value. I want to start incrementing from specified vlaue. How can i specify this functionality in slick ddl. Code i am using for column of table creation in slick is : def id = column[Long]("id", O.PrimaryKey, O.AutoInc, O.NotNull) I have come across this article but didn't find exact solution. create table "COCKTAIL" ( "ID" BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 100000) NOT NULL PRIMARY KEY, "NAME" VARCHAR NOT NULL) Can someone help me

How to use a Non Supported Database in Slick 3.1

无人久伴 提交于 2019-12-05 08:02:49
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, how? My database config is: slick.dbs.default.driver="slick.driver.JdbcDriver" slick.dbs.default.db

Run Evolutions in Command Line

不想你离开。 提交于 2019-12-05 02:07:36
It's my first day tinkering with the Play framework, and I'm having a hard time with evolutions. I'm using Play 2.4. I picked a sample app from the many that come up in activator ui , it uses play-slick and play-slick-evolutions for DB connection and evolutions. I've perused the docs , but I can't seem to find a way to run the evolutions from the command line. When I run activator on bash I get thrown into a shell, and the help doesn't bring up anything about running evolutions, or slick. I've been doing PHP for a while, so I'm used to being able to run these up/down from the command line. I

unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found

此生再无相见时 提交于 2019-12-02 00:31:15
问题 I am getting unresolved dependencies errors when trying to use slick or play-slick with Play Framework 2.2.2, sbt 0.13.0 and Scala 2.10.3 on Mac OS X Mavericks. [info] Updating {file:/Users/michaelrichardson/Documents/Play/glasgowEffect/}glasgoweffect... [info] Resolving com.typesafe.play#slick_2.10;2.0.0 ... [warn] module not found: com.typesafe.play#slick_2.10;2.0.0 [warn] ==== Typesafe Releases Repository: tried [warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/slick_2.10

unresolved dependency: com.typesafe.play#play-slick_2.10;0.6.0.1: not found

丶灬走出姿态 提交于 2019-12-01 21:02:35
I am getting unresolved dependencies errors when trying to use slick or play-slick with Play Framework 2.2.2, sbt 0.13.0 and Scala 2.10.3 on Mac OS X Mavericks. [info] Updating {file:/Users/michaelrichardson/Documents/Play/glasgowEffect/}glasgoweffect... [info] Resolving com.typesafe.play#slick_2.10;2.0.0 ... [warn] module not found: com.typesafe.play#slick_2.10;2.0.0 [warn] ==== Typesafe Releases Repository: tried [warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/slick_2.10/2.0.0/slick_2.10-2.0.0.pom [info] Resolving com.typesafe.play#play-slick_2.10;0.6.0.1 ... [warn]

Play tests with database: “Too many connections”

两盒软妹~` 提交于 2019-12-01 17:06:10
To have a database available in scalatest with evolutions I use this extension of the default PlaySpec inspired by this SO question : trait ResetDbSpec extends PlaySpec with BeforeAndAfterAll { lazy val appBuilder = new GuiceApplicationBuilder() lazy val injector = appBuilder.injector() lazy val databaseApi = injector.instanceOf[DBApi] override def beforeAll() = { Evolutions.applyEvolutions(databaseApi.database("default")) } override def afterAll() = { Evolutions.cleanupEvolutions(databaseApi.database("default")) databaseApi.database("default").shutdown() } } It applies database evolutions

Play tests with database: “Too many connections”

狂风中的少年 提交于 2019-12-01 16:58:13
问题 To have a database available in scalatest with evolutions I use this extension of the default PlaySpec inspired by this SO question: trait ResetDbSpec extends PlaySpec with BeforeAndAfterAll { lazy val appBuilder = new GuiceApplicationBuilder() lazy val injector = appBuilder.injector() lazy val databaseApi = injector.instanceOf[DBApi] override def beforeAll() = { Evolutions.applyEvolutions(databaseApi.database("default")) } override def afterAll() = { Evolutions.cleanupEvolutions(databaseApi