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
6
votes
3 answers

slick 3 auto-generated - default value (timestamp) column, how to define a Rep[Date] function

I have the following postgres column definition: record_time TIMESTAMP WITHOUT TIME ZONE DEFAULT now() How would I map it to slick? Please take into account that I wish to map the default value generated by the now() function i.e: def…
Yaneeve
  • 4,751
  • 10
  • 49
  • 87
6
votes
1 answer

Query one row with max value in one column in Slick

It seems to me like a simple problem, but I still try to find a good solution. I am using Slick 3.0. I want to query the row of a table, which has the highest value in one column. But I don't want to only have the highest value (this is simple), I…
F. Böller
  • 4,194
  • 2
  • 20
  • 32
5
votes
1 answer

How to optionally update field if parameters not None

I have a table with non nullable columns: class Users(tag: Tag) extends Table[User](tag, "users") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) def name = column[String]("name") def surname = column[String]("surname") } I want update…
zella
  • 4,645
  • 6
  • 35
  • 60
5
votes
1 answer

Scala slick: filter using "in" on multiple columns

Suppose I have the following table structure: create table PEOPLE ( ID integer not null primary key, NAME varchar(100) not null ); create table CHILDREN ( ID integer not null primary key, PARENT_ID_1 integer not null references…
Ashley Mercer
  • 2,058
  • 1
  • 16
  • 16
5
votes
2 answers

Adding comments into Slick

Is there a way I can add comments into the sql that is formed by slick without writing a raw sql statement? This is to keep track of the code in application that launched the sql.
binshi
  • 1,248
  • 2
  • 17
  • 33
5
votes
1 answer

Spark Structured Streaming Multiple WriteStreams to Same Sink

Two Writestream to the same database sink is not happening in sequence in Spark Structured Streaming 2.2.1. Please suggest how to make them execute in sequence. val deleteSink = ds1.writestream .outputMode("update") .foreach(mydbsink) …
5
votes
0 answers

Setting a default value in Scala/Slick

I'm trying to persist data with Scala/Slick in play framework. I'm sending a request via json and I'm trying to validate said request by matching it to a model like this: request.body.asJson.map(_.validate[Foo] match {...} The question is: How do…
Nocebo
  • 1,927
  • 3
  • 15
  • 26
5
votes
1 answer

Why are these two Slick queries not equivalent?

As a result of trying to make a Slick query more readable, I have this query constructor, which works val q = Users.filter(_.id === userId) join People on { case (u, p) => u.personId === p.id } joinLeft Addresses on { case ((u, p), a) =>…
GreenAsJade
  • 14,459
  • 11
  • 63
  • 98
5
votes
1 answer

How to compile a parametrized update in Slick 3.1?

Although the docs say you can compile updates, I'm having trouble getting Slick 3.1 to compile an update where the value to be updated is passed into the compiled block. For my use case, I want to find a row with a given key where the deactivation…
Sarah G
  • 810
  • 1
  • 7
  • 14
5
votes
0 answers

Populate case class slick by column names in Plain SQL

Using Slick's plain SQL, I am pulling out case classes using getResult. case class Foo(a: String, b: String) def foos(): Future[Vector[Foo]] ={ val getFoo = GetResult(r => Foo(r.<<, r.<<)) sql"SELECT a, b FROM foo" .as(GetFoo) // could…
Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
5
votes
2 answers

How to omit column values when doing a bulk-insert slick 3.x?

I have a JOURNAL table where the INSERT_DATE column should be filled by the DB with the current date and time when the record is inserted. I did not use the TIMESTAMP type on purpose, because of its limited range. class Journal(tag: Tag) extends…
binford
  • 1,655
  • 1
  • 18
  • 36
5
votes
1 answer

How to regenerate SQL scripts by Play Slick Evolution

I am using Play 2.4.0 and Slick 3.1. I am trying to figure out how I can regenerate SQL by Slick evolution. I modified my classes in models.* but no sql scripts are regenerated. Please help. Here is my…
Yohei Onishi
  • 1,362
  • 1
  • 19
  • 42
5
votes
0 answers

How can I chain generic implicits in Scala?

There is this post that discusses chaining of implicits but I think it doesn't cover my case because I have generic implicits. Sample project that demonstrates the issue is located here. To reproduce these two lines should be commented out. So I…
expert
  • 29,290
  • 30
  • 110
  • 214
5
votes
1 answer

How to use Slick code generator to include database views as well?

I'm trying to generate the Scala code for the database tables and views in my schema using Slick 3.0.3. Taking this blog as example I have the following file build.sbt. However, this will generate code for my database tables and will not include the…
SkyWalker
  • 13,729
  • 18
  • 91
  • 187
5
votes
1 answer

Create custom column mapping for java.time.LocalDate with Slick

I'm using Slick 3.1.0-M2 and I wish to use the java.time.LocalDate and java.time.LocalTime in my tables. I do it like this: import java.sql.{Date, Time, Timestamp} import java.time.{LocalDate, LocalTime, LocalDateTime, ZoneOffset} trait…
Andreas Du Rietz
  • 1,151
  • 11
  • 16