Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Richard Dallaway
    @d6y
    @felipebonezi Not that I know of. There was some investigation some years back (there are still open tickets mentioning MongoDB).
    Felipe Bonezi
    @felipebonezi
    @d6y Do you know any way to study more about Slick implementations and your archicture?
    I'm intended to try implement MongoProfile or to improve my skills hehehe.
    Richard Dallaway
    @d6y
    Jump over to https://scala-slick.org/docs/, and in the Talks section there are a couple there from Stefan. The Compiling Collections to SQL talk gives you insight into the query compiler (the steps Slick implements to go from a collection to SQL). Maybe start with the talk before that about Lifted embedding.
    Felipe Bonezi
    @felipebonezi
    Thanks @d6y
    I've already downloaded the Essential Slick Book
    Georgios Larkou
    @glarkou
    Hello guys one question, we observed that .filterNot(_.name === "test") does not include the null values as intended. Is there a better way to construct my queries instead of filter(x=> x.name.isEmpty || x.name =!= "test")
    Artsiom Miklushou
    @mikla
    Hi,
    How can I do constant query similar to SELECT 1 (Query(1)), but I need List(1) for example?
    Richard Dallaway
    @d6y
    Hi @mikla - you can use .to[T[_]], for example: Query(1).to[List]
    Artsiom Miklushou
    @mikla
    @d6y thx, interesting!
    What i'm trying to achieve is: mix some constant values to left join.
    Something similar to:
    SELECT * FROM (VALUES
                          (CAST('316df2ac-14d0-468e-8e2e-0e5a54a8abca' as uuid)),
                          (CAST('47700d3b-b1fc-402f-80e5-a113ae792aca' as uuid)),
                          (CAST('965c0657-0bdd-4842-a127-9547b9c58ca3' as uuid))
                          ) AS q (col1)
    left join table on col1 = employee_id;
    Guillaume Noireaux
    @gnoireaux
    Hello people, is it possible to read a bigint column as a String? Rather than as a Long? Thanks!
    Richard Dallaway
    @d6y
    @gnoireaux I believe you can do a table.map(row => row.myBigIntCol.asInstanceOf[String]) but not 100% sure. I'd expect that would CAST as the SQL level. Let us know how you get on.
    1 reply
    Richard Dallaway
    @d6y
    @mikla ooh. That's kind of odd looking, but I think you want to have a fixed query of uuids so you can go:
    ids.join(table).on(_ === _.employee_id)
    The type id ids would need to be a Query[Rep[X]], X, Seq] where X is whatever the type is for the uuid. I
    If, for the sake of argument, we were looking at Longs I think ids could be:
      val ids: Query[Rep[Long], Long, Seq] = Query(1L) ++ Query(3L) ++ Query(5L)
    Maybe there's something in that you can try. (I've never had to use Query.apply directly like that for a real application)
    Artsiom Miklushou
    @mikla
    @d6y Thank you very much!
    Anirudh Vyas
    @AnirudhVyas
    hi

    I am trying to run this query:

    sql"""select  distinct r_.server_request_id, r_.raw_request from  #$tableName r_  where  r_.server_request_id in ( #$sids ) and r_.created < #$downTime  and r_.created > #$tillTime""".as[(String, String)]

    when I look at raw sql

    s""" select  distinct r_.server_request_id, r_.raw_request from  #$tableName r_  where  r_.server_request_id in (#$sids) and r_.created < #$downTime  and r_.created > #$tillTime""".stripMargin

    And paste it to run on postgres with values it prints - I get correct result, however with above sql""" syntax I get empty result -- any suggestions for me would be great

    I tried writing non sql way too:

    table.map(server_request_id, raw_request, created_date).filter(dates).filter(_.server_request_id inSet serverRequestIdList).map(server_request_id, created_date).result

    but seems to give me same empty vector as result...

    Anirudh Vyas
    @AnirudhVyas
    the map, filter seems to work. still would be curious to know whats wrong with above sql
    Lalli Nuorteva
    @lalnuo

    Hi,

    I have a plain sql statement like this:

        val foobar = Seq("foo", "bar")
        sql"""
          SELECT * FROM foo where x in $foobar    
        """

    However placing a Seq inside the plain sql query does not seem to work. Is there any way to make it work?

    Antoine Doeraene
    @sherpal
    you will need a # before your $, see here https://scala-slick.org/doc/3.3.2/sql.html
    Lalli Nuorteva
    @lalnuo
    That will introduce possibility for SQL injection, right?
    Antoine Doeraene
    @sherpal
    yes you should not do that in information from the external world :(
    Lalli Nuorteva
    @lalnuo
    array_position($foobar, foo::text) is not null
    seems to be one way to do this, but its not the nicest one
    Richard Dallaway
    @d6y
    @lalnuo @sherpal I've been trying/tracking reasonable ways to do plain sql IN clauses. This is what I have: https://github.com/d6y/plain-in (it's not a library; just example code).
    Antoine Doeraene
    @sherpal
    Oh that's nice! Thanks for sharing
    Lalli Nuorteva
    @lalnuo
    Thats cool! Thanks
    Felipe Bonezi
    @felipebonezi

    Hey guys, I've opened a Pull Request to an issue, but AppVeyor is broking and I don't have idea why.
    Can anyone help me? :pray:

    slick/slick#2134

    Richard Dallaway
    @d6y
    Looks like the link to download SBT as part of the build is failing. Not sure if it's transitory, but right now https://piccolo.link/sbt-0.13.17.zip is failing with a 500 error. I can't figure out who runs piccolo.link to report this.
    Richard Dallaway
    @d6y
    Let's see if piccolo comes back today... but then someone with AppVeyor permissions will need to request a rebuild (probably, maybe)
    Lalli Nuorteva
    @lalnuo
    Is there a built in way to retry queries in slick? I have some queries running in transaction and i'd like to retry them N times
    nafg
    @nafg
    No
    Richard Dallaway
    @d6y
    ...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
    @d6y
    ...or maybe at the level of Future.
    Lalli Nuorteva
    @lalnuo
    Ok, I'll retry on the future level then, thanks!
    dan-vidican
    @dan-vidican
    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)
      }

    Hi,
    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
    @sherpal
    Are you using the slick-pg extension ?
    dan-vidican
    @dan-vidican
    nope
    Miklos Szots
    @smiklos

    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 🇮🇳
    @dheerajkarande_twitter
    Guys i need some help. I am looking for slick oracle example. Please share a link if there is any.
    Anirudh Vyas
    @AnirudhVyas
    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
    @AnirudhVyas

    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
    maha-dot
    @maha-dot

    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
    @d6y
    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
    maha-dot
    @maha-dot
    thanks @d6y
    etandon-coatue
    @etandon-coatue

    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())
            query.list
          }.map(_.toMap(keys))

    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?

    nafg
    @nafg
    Wow that's an old version
    Dheeraj Karande 🇮🇳
    @dheerajkarande_twitter
    Hi all, anyone using slick with Oracle?