Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Richard Dallaway
    ...but you might be able to roll your own with cleanUp perhaps. https://books.underscore.io/essential-slick/essential-slick-3.html#andfinally-and-cleanup
    Richard Dallaway
    ...or maybe at the level of Future.
    Lalli Nuorteva
    Ok, I'll retry on the future level then, thanks!
    private class DbWeatherCalculations(tag: Tag)
        extends Table[WeatherCalculationRepresentation](tag, Some("bill_management_v2"), "weather_calculations") {
        def id           = column[Long]("id", O.PrimaryKey, O.AutoInc)
        def createdAt    = column[Timestamp]("created_at", O.AutoInc)
        def billItemId   = column[Long]("bill_item_id")
        def name         = column[String]("name")
        def value        = column[Double]("value")
        def units        = column[String]("units")
        def billRecordId = column[Long]("bill_record_id")
        def * = (id.?, createdAt.?, billItemId, name, value, units, billRecordId)
            .<>( (WeatherCalculationRepresentation.apply _).tupled, WeatherCalculationRepresentation.unapply)

    I have this problem where 'units' has it's own data type in postgresql which is kind of enumeration. When I try to make an insertion I get this error:

    ERROR: column \"units\" is of type public.units but expression is of type character varying\n Hint: You will need to rewrite or cast the expression.\n

    Any suggestion about how I can cast the column 'units' to the one from db? Thanks

    Antoine Doeraene
    Are you using the slick-pg extension ?
    Miklos Szots

    Hi folks,

    I'm having an issue when using intellj and slick.
    In any of our slick heavy classes, autocomplete doesn't show implicit extension methods (imported via the postgres api).
    I blame intellj for this but they do show up in the very same codebase using the same intellj version on a colleague's pc.
    Implicits from ColumnExtensionMethods do show up, but extensions from AnyOptionExtensionMethods don't show up.

    Have someone encountered a similar issue before?

    Dheeraj Karande 🇮🇳
    Guys i need some help. I am looking for slick oracle example. Please share a link if there is any.
    Anirudh Vyas
    I noted an exception this morning:
    failed to ingest due to: java.util.concurrent.RejectedExecutionException: Task slick.basic.BasicBackend$DatabaseDef$$anon$2@727ea248 rejected from slick.util.AsyncExecutor$$anon$2$$anon$1@7cb95277[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 23] any ideas on what it means? supposedly my connection pool terminated?
    Anirudh Vyas

    it fails during an insert:

    failed to ingest due to: java
    .util.concurrent.RejectedExecutionException: Task slick.basic.BasicBackend$DatabaseDef$$anon$2@727ea248 rejected from slick.util.AsyncExecutor$$anon$2
    $$anon$1@7cb95277[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 23]
            at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
            at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
            at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369)
            at slick.util.AsyncExecutor$$anon$2$$anon$3.execute(AsyncExecutor.scala:118)
            at slick.basic.BasicBackend$DatabaseDef.runSynchronousDatabaseAction(BasicBackend.scala:231)
            at slick.basic.BasicBackend$DatabaseDef.runSynchronousDatabaseAction$(BasicBackend.scala:229)
            at slick.jdbc.JdbcBackend$DatabaseDef.runSynchronousDatabaseAction(JdbcBackend.scala:37)
            at slick.basic.BasicBackend$DatabaseDef.runInContext(BasicBackend.scala:208)
            at slick.basic.BasicBackend$DatabaseDef.runInContext$(BasicBackend.scala:140)
            at slick.jdbc.JdbcBackend$DatabaseDef.runInContext(JdbcBackend.scala:37)
            at slick.basic.BasicBackend$DatabaseDef.runInternal(BasicBackend.scala:76)
            at slick.basic.BasicBackend$DatabaseDef.runInternal$(BasicBackend.scala:75)
            at slick.jdbc.JdbcBackend$DatabaseDef.runInternal(JdbcBackend.scala:37)
            at slick.basic.BasicBackend$DatabaseDef.run(BasicBackend.scala:73)
            at slick.basic.BasicBackend$DatabaseDef.run$(BasicBackend.scala:73)
            at slick.jdbc.JdbcBackend$DatabaseDef.run(JdbcBackend.scala:37)
            at com.workday.perftool.query.persistence.RequestPersistors$.com$workday$perftool$query$persistence$RequestPersistors$$save(Persistor.scala:35)

    code for insert is pretty simple and obvious and works most of the time,

    b.run[Unit](DBIO.seq(executableRequestQueryTable += a))

    any suggestions welcome

    nvm race condition :) pool was shutdown

    hello !
    I need your help I have a case class like

    case class SystemResult(id: Int, centerPublicId: CenterPublicId, url: String, username: String, externalId: Option[String], updatedAt: LocalDateTime, lastSync: Option[LocalDateTime] = None)

    and I need to display implicit val with complex values

    implicit val getSystemResults: GetResult[SystemResult] = GetResult(r => SystemResult(r.<<, r.<<, r.<<, r.<<, r.<<, r.<<, r.<<))

    can someone help me please

    Richard Dallaway
    Hi @maha-dot - you'll need to implement an implicit GetResult for CenterPublicId, LocalDateTime and take care with the option values. There's a tutorial on this here: https://books.underscore.io/essential-slick/essential-slick-3.html#select-with-custom-types
    thanks @d6y

    Seeing some stage behavior. We are setting a statement timeout on postgres at code level to 1 min (global setting for DB is 15 mins):

    db.withDynSession {
            sqlu"SET STATEMENT_TIMEOUT = 60000".logAndExecute())

    However we are seeing some other flow inherit this timeout value.
    My assumption is that the STATEMENT_TIMEOUT value will reset after this execution. Is that not true?
    Slick version: 2.1.0
    Should we explicitly reset the statement timeout in this case?

    Wow that's an old version
    Dheeraj Karande 🇮🇳
    Hi all, anyone using slick with Oracle?
    Alessandro Buggin
    Hello, I'm getting could not find implicit value for parameter e: slick.jdbc.SetParameter[TRAIT]
    any hint of what should I provide?
    You have to make your own implicit SetParameter[TRAIT]
    It's probably documented on the site
    Peter Robinson
    Hello. I've been seeing my slick app sometimes permanently timing out all postgress calls until a restart. I believe it's because all the connections in the Hikari pool end up leaked. I set leakDetectionThreshold to 40 seconds and I also upgraded slick from 3.2.1 to 3.2.3. Since then (a few days) I see some suspected leaks logged, but only a handful and no total lockups. I have a couple of questions:
    Re leakDetectionThreshold, when it fires, does it just log or does it reclaim the slot in the pool as well?
    Peter Robinson
    I've read scary comments about the perils of setting the hikari connection pool size without telling slick about it, and that here's a particular combination of hickari pool size vs slick thread pool size which causes problems. Could that explain it? What is the exact rule? I am calling HikariCPJdbcDataSource.forConfig(config, ...) where config comes via ConfigFactory.empty()....withParameter("maxConnections", 20).withParameter("minConnections", 20)
    Yes Slick works with Oracle with the DatabaseConfig.forConfig. I have trouble however getting to work with proxy user. While doing it in code, we will do conn.unwrap(classOf[OracleConnection]).openProxyConnection. I am not sure if there is a way to tell slick this either through forConfig or pass java.sql.Connection and create Slick JDBCProfile.
    Hello, all. I am trying to work out how Hikari options fit in the typesafe config for slick. https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby How do I configure Hikari? Specifically, I'm wondering about how to set autoCommit = false. Is this the right idea?
    slick {
      profile = "slick.jdbc.SQLServerProfile$"
      db {
        poolName = "mypool"
        readOnly = false
        autoCommit = false
        connectionTimeout = 10000
    Also, I can't find much mention at all about autoCommit in the Slick 3 documention. Will this setting actually change anything?
    Richard Dallaway
    The Slick homepage points users towards a product called Activator to get started (https://scala-slick.org/ - see the "NEW TO SLICK? on the right, and the video introduction). Given that activator is dead...
    ... what should we replace them with? Any thoughts?
    Luis Martinez


    Is it possible to batch update with slick?

    Richard Dallaway
    Hi @luis3m - in the most general case, plain sql lets you do a batch update.
    Luis Martinez
    @d6y hi, you mean something like update Table set Table.column = values.value from (values(?, ?)) values where condition?
    Richard Dallaway
    Well. I don't mean any particular kind of update SQL. The regular Slick update (table.filter(whetever).map(columns).update(values)) will update multiple rows (depending on the filter), but the update values are fixed and the same for all rows updated. Plain SQL lets you do anything you can in SQL: sqlu"update table set column = column +1" for example.
    Maybe I don't know what we mean by batch update :-)
    Luis Martinez
    So per each row I want to set a different value for a particular column
    Richard Dallaway
    Ok - then Plain SQL is what wouldn't probably best fit.
    Luis Martinez
    Something like this is what I'm looking for: update Products p set p.inventory = temp.inventory from (values(1 as id, 5 as inventory) ...) temp where p.id = temp.id
    Richard Dallaway
    Take a look at https://scala-slick.org/doc/3.3.3/sql.html for how to execute that
    It's sqlu you'll need.
    Luis Martinez
    Hello, is there a Slick way to do conditional upsert? I would like to upsert, but only if a certain condition holds true: insert into "table" (...) values (?...) on conflict (primary_keys) do update set ... where .... Slick's insertOrUpdate is able to do everything except adding that condition.
    Pascal Danek
    Hello, i am curious about scala 3 support. Does someone know what we should expect ?
    In @djspiewak's talk he said it was already ported. I know @szeiger was working on it a long time ago but I didn't know he finished it. In anyone knows more info I'm interested too
    Daniel Spiewak
    if I misspoke I apologize; I was under the impression it was fully ported
    @djspiewak I have no idea, I was wondering where you got your info from
    Maybe it is fully ported in that fork+branch, do you know if it's published?
    Daniel Spiewak
    rewinding back several months and evesdropping on @szeiger in the dotty channel
    I don't know, but I'd assume it hasn't been published
    I remember him saying he was working on it