Questions tagged [slick-3.0]

Slick is a modern database query and access library for Scala by Typesafe.

Slick is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can write your database queries in Scala instead of SQL, thus profiting from the static checking, compile-time safety and compositionality of Scala. Slick features an extensible query compiler which can generate code for different backends.

New in Slick 3.0.0-M1

These are the major new features in this miletone:

  • A new API for composing and executing database actions.
  • Improved configuration of database connections via Typesafe Config, including built-in support for HikariCP.
  • Support for nested Option types and non-primtive Option types in the Lifted Embedding.
  • Properly typed outer join operators based on the improved Option support.

Useful Links

488 questions
4
votes
1 answer

How to use Future inside DBIOAction composition in slick 3?

Slick 3 offers DBIOAction composition by using flatMap method. Also, we can do some calculations in back-end between two DBIOActions. That's works fine in most cases, but what I should do when calculations result is in the monad like Future? There…
StopKran
  • 395
  • 5
  • 22
4
votes
1 answer

How to write readable nested join queries with Slick 3.0

This code is creating a query for use in retrieving a user's profile on a web back end. It creates a query that assembles the necessary information into a DTO (which is just a case class) that is subsequently sent back as JSON. def…
GreenAsJade
  • 14,459
  • 11
  • 63
  • 98
4
votes
1 answer

Slick 3 Postgresql void function raw sql

I have a function defined in postgresql db which return void and makes an update inside the function. when I do Await.result(db.run(sqlu"""select function_name()"""), Duration.Inf) I get this SlickException Update statements should not return a…
dtksmsl
  • 239
  • 4
  • 14
4
votes
1 answer

How should I handle database evolutions when using Play and Slick? Must I manually write SQL?

I'm looking at the "Hello Slick" tutorial. A users table is defined and then created using users.schema.create (the code on github is outdated so there it's users.ddl.create there, but when I create the app in Activator it's schema because it's…
4
votes
3 answers

Slick 3.0.0 - update row with only non-null values

Having a table with the columns class Data(tag: Tag) extends Table[DataRow](tag, "data") { def id = column[Int]("id", O.PrimaryKey) def name = column[String]("name") def state = column[State]("state") def price = column[Int]("price") def…
Ákos Vandra-Meyer
  • 1,890
  • 1
  • 23
  • 40
4
votes
1 answer

Best practice for Slick 2.1 / 3 execution context usage

We use Slick (2.1.0) with Spray-io (1.3.3). Currently we are facing an issue because we use the same execution context for both the Spray HTTP API part and background running jobs accessing the same database. All database / blocking calls are…
Chris
  • 75
  • 6
4
votes
3 answers

Reading from postgres using Akka Streams 2.4.2 and Slick 3.0

Trying out the newly minted Akka Streams. It seems to be working except for one small thing - there's no output. I have the following table definition: case class my_stream(id: Int, value: String) class Streams(tag: Tag) extends…
Mark J Miller
  • 4,751
  • 5
  • 44
  • 74
4
votes
0 answers

Slick 3.0 save an object with relationship (one-to-one or many-to-one)

I have following code like user and userAddress, which is kind of one-to-one or many-to-one relationship. case class User(id: Long, name: String, addressId: Long) case class Address(id: Long, street: String) class UserTable(tag: Tag) extends…
ttt
  • 3,934
  • 8
  • 46
  • 85
4
votes
2 answers

Close DB Connection in Slick 3.0

I am using Slick 3.x with Play 2.3.9 without play-slick because play-slick does not support this combination. I read http://blog.knoldus.com/2015/03/03/play-with-reactive-slick-a-simple-crud-application-in-play-framework-using-slick-3-0/ And it…
thlim
  • 2,908
  • 3
  • 34
  • 57
4
votes
1 answer

One-to-many relationship between tables on different files using Play with Scala and Slick

I am trying to map a relationship between musics and albums - a music belongs to an album, whereas one album may have many musics. According to Slick's docs this should be fairly simple... However, I do not have my tables in a single file like in…
Henrique Ferrolho
  • 912
  • 1
  • 10
  • 30
4
votes
2 answers

Slick 3 Updates with Optional Columns

Using Slick 3, I want to update my row depending on the property provided by the user. Say, I have 2 properties email and name. If email and name are provided I will update both properties in the database. If either one is provided I will only…
thlim
  • 2,908
  • 3
  • 34
  • 57
4
votes
1 answer

Where to initialize a database in Play framework 2.4 with Slick 3?

Slick 3.0.2 doesn't automatically create the database table when they don't exist so you have to do something like: val setup = DBIO.seq( (table1.schema ++ table2.schema).create, //... ) Where do you put this code in Play 2.4? On a…
Luis F.
  • 1,222
  • 1
  • 11
  • 12
4
votes
0 answers

Using Slick 3.0 with existing DataSource where auto-commit is false

I'm using Slick within an existing Spring app and I pass in the DataSource from the rest of the app with Database.forDataSource(ds). The connection pool in the data source is configured with auto-commit = false and I can't figure out how to get…
jon_wu
  • 1,113
  • 11
  • 26
4
votes
1 answer

Scala / Slick 3.0.1 - Update Multiple Columns

Whenever I get an update request for a given id , I am trying to update the masterId and the updatedDtTm columns in a DB table( I don't want to update my createdDtTm). The following is my code : case class Master(id:Option[Long] =…
4
votes
1 answer

Slick 3 - several db.run() calls in one transaction

I have model repository class with byId and save metdhods def byID(id:Long) = db.run{ query.filter(_.id === id).result }.map(_.headOption) def save(model:User) = db.run{ query.filter(_.id===model.id).update(model) } Now I want to use both these…
codez
  • 1,381
  • 1
  • 18
  • 28