Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    nafg
    @nafg
    I'm trying to figure out how to use stringAgg. Here is the query I'm trying to convert:
    select last_name,
           first_name,
           (select string_agg(medical_specialty.name, '; ') from medical_specialty join doctor_medical_specialty dms on medical_specialty.id = dms.medical_specialty where dms.doctor = doctor.id)                                                   as specialties,
           (select string_agg(medical_subspecialty.name, '; ') from medical_subspecialty join doctor_medical_subspecialty dms on medical_subspecialty.id = dms.medical_subspecialty where dms.doctor = doctor.id)                                                   as subspecialties,
           cell_number,
           email_address,
           rating,
           (select string_agg(hospital.name, '; ') from hospital join doctor_hospital dh on hospital.id = dh.hospital where dh.doctor = doctor.id)                                                    as hospitals,
           (select string_agg(o.name, '; ') from doctoroffice o where o.doctor = doctor.id) as offices
    from doctor
    I'm trying this:
          Doctors
          .map { doc =>
            val specialties =
              ManageDoctorsDbActions.specialtiesQuery.filter(_._1 === doc.lookup).map(t => stringAgg(t._2.name, "; "))
            (doc, specialties)
          }
    and it fails pretty badly, and seems wrong. This is somewhat better?
          Doctors
            .map { doc =>
              val specialties =
                stringAgg(ManageDoctorsDbActions.specialtiesQuery.filter(_._1 === doc.lookup).map(t => t._2.name), "; ")
              (doc, specialties)
            }
    I get this:
    This message was deleted
    nafg
    @nafg
    image.png
    nafg
    @nafg
    It seems like stringAgg is essentially Rep[A] => Rep[String]
    nafg
    @nafg
    I gave up on using the slick-pg implementation. I wrote this instead and it compiles:
        import FunctionSymbolExtensionMethods._
    
    
        val StringAgg = new Library.SqlAggregateFunction("string_agg")
        def stringAgg(q: Query[Rep[String], _, Seq], delimiter: String)
                     (implicit tm: TypedType[Option[String]]): Rep[Option[String]] =
          StringAgg.column[Option[String]](q.toNode, LiteralNode(delimiter))
    
    ...
    
          Doctors
            .map { doc =>
              val specialties =
                stringAgg(ManageDoctorsDbActions.specialtiesQuery.filter(_._1 === doc.lookup).map(_._2.name), ", ")
              (doc, specialties)
            }
    @tminglei
    I based it off how slick's built in aggregate functions are defined
    nafg
    @nafg
    ...except it's generating the wrong SQL now
    nafg
    @nafg
    Gave up and went with plain sql query :(
    Gavin Bisesi
    @Daenyth
    I think there's issues with stringAgg.. check the bug tracker
    nafg
    @nafg
    @Daenyth don't see any bugs about it
    Gavin Bisesi
    @Daenyth
    not sure, I recall someone on our team hit weird issues with it but I don't remember what
    Naveen Kumar Parachur Cotha
    @naveencotha-zt
    Hi, is there a getting started guide or something to read up?
    Gavin Bisesi
    @Daenyth
    Essential Slick is what I recommend
    Naveen Kumar Parachur Cotha
    @naveencotha-zt
    does it talk about slick-pg specifics?
    Gavin Bisesi
    @Daenyth
    You really only need the README
    from github
    Naveen Kumar Parachur Cotha
    @naveencotha-zt
    ok sounds good.
    Tom Wang
    @TomWang41841655_twitter
    Hi there. Does anyone know if slick-pg 0.16.3 supports Postgres 9.6? I see in the README that slick-pg 0.16.3 is tested on Postgres 10.
    And is there any additional testing on Postgres 10 beyond the test suite? I had run the test suite on Postgres 9.6 and got the test suite to pass, but not sure if that is sufficient to be confident of using slick 0.16.3 with Postgres 9.6 in production.
    Gavin Bisesi
    @Daenyth
    we use it in prod with 9.6
    no problems so far
    Tom Wang
    @TomWang41841655_twitter
    Thanks!
    So when the README says slick-pg is tested with Postgres 10, is that saying support for other Postgres versions are excluded? Or is that simply saying that’s the Postgres version on which the tests are continually being run against? I saw that TravisCI is set up to run the test suite against Postgres 10.
    Gavin Bisesi
    @Daenyth
    it's saying that slick-pg is tested against pg 10
    10 is guaranteed, otherwise is not
    I mean, to the extent a 1-developer library is guaranteed about anything
    Tom Wang
    @TomWang41841655_twitter
    :D
    Thanks!
    František Kocun
    @fokot
    @TomWang41841655_twitter we aslo use slick pg with 9.6 - array support, window functions (partition by), json support, date support and all works
    nafg
    @nafg
    What's new in 10 that's relevant?
    Andrzej Sołtysik
    @asoltysik
    Hi, does anyone know how to use aggregate functions like mode with a groupedBy query?
    mode().within expects ColumnOrdered but I have a Seq from the groupBy
    Andrzej Sołtysik
    @asoltysik

    In short I want to translate a sql like this:

    SELECT a.id, mode() WITHIN GROUP (ORDER BY b.id) 
    FROM a INNER JOIN b on a.id = b.a_id
    GROUP BY a.id

    into Slick

    Tom Wang
    @TomWang41841655_twitter
    @nafg I do not think there's anything in pg 10 that is relevant for slick-pg. It's just that slick-pg is tested with pg 10.
    nafg
    @nafg
    But what's your concern
    Tom Wang
    @TomWang41841655_twitter
    My original concern was that the newest slick-pg would not work with pg 9.6. I think that concern has been addressed.
    Łukasz Dycjan
    @dycu
    Hi, do you know if there is a way of using date support while having value classes as column types rather than pure date types (case class extending AnyVal)?
    Tor Holm
    @holm.tor_gitlab
    Hi, is it possible to have an array of jsonb elements?
    I use play-json for serde
    nafg
    @nafg
    @holm.tor_gitlab did you have any particular trouble?
    Hmm I see, it seems array support is hardcoded for specific element types, although it looks easy to add more
    nafg
    @nafg
    But why would you use array when you can you json array?