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

479 questions
36
votes
2 answers

Slick 3.0 Insert and then get Auto Increment Value

I have written this code which works perfectly class Items(tag: Tag) extends Table[Item](tag, "ITEMS") { def id = column[Long]("ITEMS_ID", O.PrimaryKey, O.AutoInc) def name = column[String]("ITEMS_NAME") def price =…
Knows Not Much
  • 26,151
  • 46
  • 158
  • 314
28
votes
4 answers

can't find method result on TableQuery with slick 3.0.0-RC1

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…
brujoand
  • 815
  • 8
  • 14
26
votes
1 answer

Executing non-database actions in a transaction in Slick 3

I'm having trouble understanding the new Slick DBIOAction API, which does not seem to have a lot of examples in the docs. I am using Slick 3.0.0, and I need to execute some DB actions and also some calculations with the data received from the…
Sergei
  • 5,942
  • 1
  • 19
  • 32
26
votes
1 answer

How to convert Rep[T] to T in slick 3.0?

I used a code, generated from slick code generator. My table has more than 22 columns, hence it uses HList It generates 1 type and 1 function: type AccountRow def AccountRow(uuid: java.util.UUID, providerid: String, email: Option[String],…
kingcw
  • 269
  • 2
  • 3
19
votes
1 answer

Optimizing Slick generated SQL query

I have a very simple query which in SQL can be represented as follows: SELECT c.id, count(cp.product_id) FROM cart c LEFT OUTER JOIN cart_product cp ON c.id = cp.cart_id WHERE c.id = 3 GROUP BY c.id; I was very surprised when using Slick DSL to…
Mon Calamari
  • 4,225
  • 2
  • 23
  • 40
19
votes
2 answers

Slick 3.0.0: How to query one-to-many / many-to-many relations

Basically the same question has been asked about a year ago for slick 2.x (scala slick one-to-many collections). I'm wondering if there has any progression been made with the release of reactive slick. Let's say for example we have three tables.…
Roman
  • 5,323
  • 1
  • 27
  • 39
17
votes
1 answer

Slick 3.1 - Retrieving subset of columns as a case class

I'm working with Slick 3.1.1 and the problem is that in some cases I want to omit some columns that are fairly heavy and still materialize that subset of columns as a case class. Consider the following table definition: class AuditResultTable(tag:…
BrokenGlass
  • 149,257
  • 27
  • 271
  • 318
14
votes
1 answer

How to encode/decode Timestamp for json in circe?

While using circe in slick to get data in json,I could fetch data having no date(Timestamp/DateTime) fields in Entities. But when I use Timestamp fields in Entities, the error is thrown: [error]…
Sujit Baniya
  • 775
  • 5
  • 22
14
votes
2 answers

What is the right way to work with slick's 3.0.0 streaming results and Postgresql?

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…
13
votes
1 answer

Mapping Between Enumeration on Scala and Slick

I am newbie to Play Scala and Slick. I am trying to map between Enumeration on Scala to String/Int on Slick. I wrote the following code but I got an error. Could you please let me know how I can fix this. I am using Scala 2.11.6, Slick 3.1.0, Play…
Yohei Onishi
  • 684
  • 8
  • 27
13
votes
1 answer

Check table existence in slick 3.0

How do you check if a table exists with slick 3.0? There was a way in previous versions of slick by using: MTable.getTables.list() But this doesn't compile anymore. The idea behind this question is to dynamically create a table when it doesn't…
Benjamin B.
  • 133
  • 2
  • 7
12
votes
5 answers

How to apply manually evolutions in tests with Slick and Play! 2.4

I would like to manually run my evolution script at the beginning of each test file. I'm working with Play! 2.4 and Slick 3. According to the documentation, the way to go seems to be: Evolutions.applyEvolutions(database) but I don't manage to get…
Simon
  • 4,844
  • 4
  • 32
  • 69
11
votes
1 answer

SLICK 3.0 - multiple queries depending on one another - db.run(action)

I am new to Slick 3 and so far I have understood that db.run are asynchronous call. the .map or .flatMap is run once the Future is returned. The problem in my code below is that all the sub queries do not work (nested db.run). Conceptually speaking,…
user1237981
  • 165
  • 1
  • 8
10
votes
3 answers

How are reactive streams used in Slick for inserting data

In Slick's documentation examples for using Reactive Streams are presented just for reading data as a means of a DatabasePublisher. But what happens when you want to use your database as a Sink and backpreasure based on your insertion rate? I've…
tonicebrian
  • 4,555
  • 5
  • 37
  • 59
10
votes
1 answer

How can I omit case class fields in a slick table mapping?

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, …
user5504273
  • 128
  • 6
1
2 3
31 32