Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Assen Kolov
    @kolov
    That's great, thank a lot!
    adilkurniaramdan
    @adilkurniaramdan
    hi I am using play-slick 3.0, slick-pg 0.15.4 and I followed the instruction from github and example, but I got following error when I performed query "Caused by: java.lang.ClassCastException: slick.jdbc.PostgresProfile$ cannot be cast to utils.H2hPostgresDriver"
    • and scala 2.12.2
    @tminglei can u help me ? thanks
    Niels Pedersen
    @nielspedersen
    Hi! I’m trying to add slick-pg to my project. Am following the README, but I get stuck on (s) => utils.SimpleArrayUtils.fromString[JsValue](Json.parse(_))(s).orNull,, since Json is not a value. If I use spray-json, should I just use parseJson instead?
    Niels Pedersen
    @nielspedersen
    Scratch that actually. parseJson doesn’t seem to work
    Niels Pedersen
    @nielspedersen
    Scratch that scratching… works with parseJson!
    Jose Martinez
    @callado4
    hi - is there a way to do a filter on if a json attribute is not null? in sql something like select json ->> 'someId' from jsonTable where (json ->> 'someId') is not null
    Jose Martinez
    @callado4
    I got what I needed, I did .filter(_.json.+>>("someId").asColumnOf[Option[String]].isDefined)
    Guy Jarvis
    @buddhabuddy
    Is it possible to toTsVector a jsonb column?
    Gavin Bisesi
    @Daenyth
    Hiya folks
    I implemented a bulk upsert action in my company's slick profile and I'm working on making a PR to send it back up to you
    Is it OK if I refactor some of the existing upsert unit tests? There's some existing duplication that I'm making worse as I'm adding stuff
    Also, I haven't been able to figure out how to write a reasonable fallback for when nativeUpsert capability is disabled. Right now I have it throw and suggest to DBIO.sequence(insertOrUpdate...)
    Samir ELSHARKAWY
    @sharkyze
    Hi everyone, I'm trying to use PgPlayJsonSupport and PlayJsonImplicits as shown in several examples but the traits are no longer available using import com.github.tminglei.slickpg._. I am using the version "com.github.tminglei" %% "slick-pg" % "0.16.0". Do any of you know if they have been removed ?
    David Hoepelman
    @dhoepelman
    If I would like to use a column[Array[String]], basically just using the raw JDBC type. Which implicit do I need to tell Slick that?
    The SimpleArrayJdbcType & co ways do not work because Array is not a subtype of Seq
    elyphas
    @elyphas

    Hi, I have this code:

    package postg
    import spatutorial.shared._
    import scala.concurrent.Future
    import javax.inject.Inject
    import play.api.db.slick.DatabaseConfigProvider
    import play.api.db.slick.HasDatabaseConfigProvider
    import scala.concurrent.ExecutionContext.Implicits.global
    
    import MySlickPg.MyPostgresProfile.api._
    
    class CPreciosPg {
    
      private class tabla(tag: Tag) extends Table[Precios](tag, "tblofic") {
    
        def    id_comparativo        = column[String]("id_comparativo")
        def rfc                                = column[String]("rfc")
        def cve_articulo            = column[String]("cve_articulo")
        def renglon                        = column[Int]("renglon")
        def precio                        = column[Double]("precio")
        def marca                = column[Option[String]]("marca")
        def anexo                = column[Option[String]]("anexo")
        def modelo            = column[Option[String]]("modelo")
        def descalificado        = column[Boolean]("descalificado")
        def gana            = column[Option[Boolean]]("gana")
    
        def * = (id_comparativo, rfc, cve_articulo, renglon, precio, marca, anexo, modelo, descalificado, gana) <> (Precios.tupled, Precios.unapply)
      }
      def ById() = {
        val query = TableQuery(new tabla(_))
        val v = for {
          q <- query
        } yield q
        v.map(println)
        "nada"
      }
    }

    But I only get this:

    [warn] M.MyPostgresProfile -  >>> DUPLICATED binding for tsrange - existed: com.github.tminglei.slickpg.Range, new: com.github.tminglei.slickpg.Range !!!  If it's expected, pls ignore it.
    [warn] M.MyPostgresProfile -  >>> DUPLICATED binding for daterange - existed: com.github.tminglei.slickpg.Range, new: com.github.tminglei.slickpg.Range !!!  If it's expected, pls ignore it.
    Rep(Ref @1094116140)

    Someone could tell me, Why happen this?

    When I call the " ById()" method
    elyphas
    @elyphas

    Now I have this code:

    package postg
    
    import spatutorial.shared._
    import scala.concurrent.Future
    import javax.inject.Inject
    import play.api.db.slick.DatabaseConfigProvider
    import play.api.db.slick.HasDatabaseConfigProvider
    import scala.concurrent.ExecutionContext.Implicits.global
    
    //import play.api.db.slick.Profile._
    //import profile.simple._
    
    import slick.jdbc.JdbcProfile
    
    import play.api.db.slick.DatabaseConfigProvider
    import play.api.db.slick.HasDatabaseConfigProvider
    import play.db.NamedDatabase
    import MySlickPg.MyPostgresProfile.api._
    
    class CPreciosPg @Inject()( @NamedDatabase("sicap")
                                protected val dbConfigProvider: DatabaseConfigProvider,
                                protected val provCotizan: CProvCotizan
                              ) extends HasDatabaseConfigProvider[JdbcProfile]{
    
      import profile.api._
    
      private class tabla(tag: Tag) extends Table[ProvCotizan](tag, "proveedores") {
    
        def    id_comparativo        = column[String]("id_comparativo")
        def rfc                                = column[String]("rfc")
        def plazo            = column[String]("plazo")
        def pago                        = column[String]("pago")
        def garantia                        = column[String]("garantia")
        def todo                        = column[Boolean]("todo")
        def descalificado                        = column[Boolean]("descalificado")
    
        def * = (id_comparativo, rfc, plazo, pago, garantia, todo, descalificado) <> (ProvCotizan.tupled, ProvCotizan.unapply)
      }
    
      def ById() = {
        val query = TableQuery(new tabla(_))
    
        val v = for {
          q <- query
        } yield {
    
    
        }
    
        v.map(println)
    
        "nada"
      }
    
    }

    but I have this result:

    ()
    elyphas
    @elyphas
    Hi, finally I connect slick-pg to postgresql, but I don't know how to use arrayAgg,Someone could tell me please?
    Naveen Kumar Parachur Cotha
    @naveencotha-zt
    Hi, I just came across this lib, I am wondering what is the lib compatible version for slick3 - is it 0.16?
    Matthew Daumen
    @mdaumen
    I'm trying to figure out how to query a jsonb column to find a value present within an array
    This would be a native query:
    select * from predicate_rules p join composite_rules cr on p.composite_rule_id = cr.id where p.predicate @> '{"userRoles":["writer"]}';
    Matthew Daumen
    @mdaumen
    Seems like there is a @> operator in the PgJsonExtensions class, but its usage is not described in the docs nor have I been able to find any examples.
    Any tips?
    nafg
    @nafg
    No, but does it resemble one of the postgres json operators?
    Also how is it defined
    Matthew Daumen
    @mdaumen
    Hey there is a @> operator in the tminglei/slick-pg source
    The definition is as follows:
    `def @>[P2,R](c2: Rep[P2])(implicit om: o#arg[JSONType, P2]#to[Boolean, R]) = {
        om.column(jsonLib.Contains, n, c2.toNode)
      }`
    I have this line in a query: .filter({ case (_, pr) => pr.predicate @> Json.parse(s"""{"userRole":["$userRole"]}""")})
    Seems like I'm moving in the right direction.
    Matthew Daumen
    @mdaumen
    My driver is configured with Play! Json so I think that is the right way to pass that arg. Not 100% though.
    Matthew Daumen
    @mdaumen
    In case it ends up mattering - the above worked!
    Jens Grassel
    @jan0sch

    Hi,
    I was wondering if something like this is possible using json helpers:

    dbConfig.db.run(myTable.filter(_.state.~>("finished") === true).result.headOption)

    Where state is a JSON field on the table having a finished attribute which is boolean.

    However the compiler is complaining:

    [error] ... Cannot perform option-mapped operation
    [error]       with type: (io.circe.Json, Boolean) => R
    [error]   for base type: (io.circe.Json, io.circe.Json) => Boolean
    [error]     dbConfig.db.run(myTable.filter(_.state.+>("finished") === true).result.headOption)
    [error]                                                           ^
    [error] ... ambiguous implicit values:
    [error]  both value BooleanCanBeQueryCondition in object CanBeQueryCondition of type => slick.lifted.CanBeQueryCondition[Boolean]
    [error]  and value BooleanColumnCanBeQueryCondition in object CanBeQueryCondition of type => slick.lifted.CanBeQueryCondition[slick.lifted.Rep[Boolean]]
    [error]  match expected type slick.lifted.CanBeQueryCondition[Nothing]
    [error]     dbConfig.db.run(myTable.filter(_.state.+>("finished") === true).result.headOption)
    [error]                             ^
    Any ideas which can guide me in the right direction?
    Gavin Bisesi
    @Daenyth
    maybe try ("finished").asColumnOf[Boolean]?
    Jens Grassel
    @jan0sch
    @Daenyth Awesome, thank you. It compiles fine, now it only has to work. ;-)
    Jens Grassel
    @jan0sch
    Ok, it fails at runtime with "could not convert type jsonb to boolean". :-|
    Jens Grassel
    @jan0sch
    I use +>> now and compare to the string value. Not the best thing but it works.
    Vladimir
    @invis87
    Hi guys, can you give me a hint - how to save Timestamp in UTC?
    I am using java.time.Instant and this converter:
    implicit private val instantColumn: JdbcType[java.time.Instant] = MappedColumnType.base[java.time.Instant, java.sql.Timestamp](
        instant => java.sql.Timestamp.from(instant),
        column => column.toInstant)
    but when I save date to Database it it saved with my local offset :(
    Gavin Bisesi
    @Daenyth
    Make sure your server, db server, and db connection are all set to utc
    Rakesh
    @rakeshkr00
    I have used codegen with slick pg. The generated code throws could not find implicit value for parameter tt: slick.ast.TypedType[Option[com.vividsolutions.jts.geom.Geometry]] . I have defined my postgres profile as given at https://github.com/tminglei/slick-pg. Am I missing something here?
    If I raplace com.vividsolutions.jts.geom.Geometry with String, the error goes away.
    Gavin Bisesi
    @Daenyth
    you need to tell slick how Geometry maps to a database type it knows about
    Rakesh
    @rakeshkr00
    I thought slick pg would help taking care of it. BTW, how to let slick know that required mapping?
    Gavin Bisesi
    @Daenyth
    hmm it actually looks like it should
    does your slick profile extend PostGISSupport?