Questions tagged [slick]

Slick acronym for Scala Language-Integrated Connection Kit, is a modern database query and access library for Scala by Lightbend.

Slick

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.

Slick (Scala Language-Integrated Connection Kit) is Lightbend‘s Functional Relational Mapping (FRM) library for Scala that makes it easy to work with relational databases. 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 also use SQL directly. Execution of database actions is done asynchronously, making Slick a perfect fit for your reactive applications based on Play and Akka.

2469 questions
16
votes
1 answer

Slick 3.1 - Printing SQL from DBIOAction (insert statements)

In Slick 3.1, with the complete redesign of the new API, it seems to be impossible to view the generated SQL statements when doing an insert. If you have something like this val action = DBIO.seq( SomeTables ++=…
mdedetrich
  • 1,899
  • 1
  • 18
  • 29
16
votes
3 answers

How to COUNT(*) in Slick 2.0?

According to the Slick 2.0 documentation, to get the count of rows in a table: val q1 = coffees.length // compiles to SQL (simplified): // select count(1) from "COFFEES" However, it turns out that coffees.length is of type Column[Int]. How…
kes
  • 5,983
  • 8
  • 41
  • 69
16
votes
2 answers

Play!: Does Slick's DDL replace Evolutions?

This may be a dumb question but I'm new to Play! & Slick. While using Slick's table.ddl.create I noticed that it doesn't create an evolution but the application still works. Does this replace evolutions? Can I use it in production? Should I? Thanks…
goo
  • 2,230
  • 4
  • 32
  • 53
16
votes
2 answers

How can I use the new Slick 2.0 HList to overcome 22 column limit?

I'm currently writing Slick code to target an old schema with two tables > 22 columns. How do I use the new HList code? I've got 2.0-M3 working fine in other respects under Scala 2.10.3. Here's the syntax I'm currently using with case classes /…
sventechie
  • 1,859
  • 1
  • 22
  • 51
16
votes
1 answer

Slick and filtering by Option columns

I'm trying to filter against an optional date column with Scala Slick 1.0.1. It may be I just don't see it, but I've got a table that looks something like this: case class UserRole(id:UUID, userID:UUID, role:String) object UserRole extends…
Michael Kohout
  • 1,073
  • 1
  • 14
  • 26
15
votes
2 answers

Transforming Slick Streaming data and sending Chunked Response using Akka Http

The aim is to stream data from a database, perform some computation on this chunk of data(this computation returns a Future of some case class) and send this data as chunked response to the user. Currently I am able to stream data and send the…
user3294786
  • 177
  • 2
  • 10
15
votes
2 answers

Slick 3 Transactions

I'm confused by the way the slick 3 documentation describes transactions. I have slick 2 code that looks like this: def doSomething(???) = DB.withTransaction { implicit session => userDao.doSomething(???) addressDao.doSomething(???) …
Bomgar
  • 553
  • 1
  • 3
  • 13
15
votes
2 answers

scala slick one-to-many collections

I have a database that contain activities with a one-to-many registrations relation. The goal is to get all activities, with a list of their registrations. By creating a cartesian product of activities with registrations, all necessary data to get…
A.J.Rouvoet
  • 1,203
  • 1
  • 14
  • 29
15
votes
1 answer

Updating db row scala slick

I have following code which inserts row into table named luczekInfo and function to get data from database. My question is how to make function to update columns from table luczekInfo, on rows returned by get(id) function. What is the best way to…
pmalecki
  • 229
  • 1
  • 2
  • 12
15
votes
1 answer

SLICK How to define bidirectional one-to-many relationship for use in case class

I am using SLICK 1.0.0-RC2. I have defined the following two tables Directorate and ServiceArea where Directorate has a one to many relationship with ServiceArea case class Directorate(dirCode: String, name: String) object Directorates extends…
Magnus Smith
  • 827
  • 2
  • 11
  • 28
14
votes
1 answer

Slick 3: insertOrUpdate not working

I'm using slick with Postgresql 9.6.1, Plya! 2.5 and play-slick 2.0.2. (I also use slick-pg 0.14.3 but I don't think that it changes anything here.) I'm using insertOrUpdate in a very straight forward way but I still get a unique exception. I have a…
Simon
  • 6,025
  • 7
  • 46
  • 98
14
votes
1 answer

Creating a composition Primary Key using Scala Slick

I'm trying to use two column's as my primary key for a Scala Slick table. Here is how my table is defined: class NbaPlayerBoxScoreTable(tag : Tag) extends Table[NbaPlayerBoxScore](tag, "player_box_scores") { import…
Chris Stewart
  • 1,641
  • 2
  • 28
  • 60
14
votes
1 answer

Slick 3 multiple outer joins

from Slick documentation, it's clear how to make a single left join between two tables. val q = for { (t, v) <- titles joinLeft volumes on (_.uid === _.titleUid) } yield (t, v) Query q will, as expected, have attributes: _1 of type Titles and _2…
Bruno Batarelo
  • 315
  • 2
  • 11
14
votes
3 answers

Error: value seq is not a member of object slick.dbio.DBIO

I am writing a web application in play framework. I decided to use slick (FRM) to query in my database (postgre). I am new to slick so I started following slick official document for revision 3.0.0…
Vinay
  • 1,280
  • 2
  • 13
  • 18
14
votes
1 answer

How to do "OR" filter in slick

In slick we can use query.filter( m => (m.state === state1 && m.status === status1) || (m.state === state2 && m.status == status2)) for an "OR" condition in where clause. However my requirement is I have "OR" conditions in a list (passed by user…
Gaurav
  • 331
  • 2
  • 9