Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Matthew de Detrich
    @mdedetrich
    @milessabin Pull request for the readme is here milessabin/shapeless#619
    Miles Sabin
    @milessabin
    Err ... that should be a PR against the README for Slickless!
    It's a general problem (so the issue is for shapeless and not Slick or Slickless) with a specific manifestation (in Slickless, so that's where the FAQ needs to go).
    Oh, OK, misleading link above :-D
    PR is here: underscoreio/slickless#9
    LGTM ... I'll leave it to one of the primary maintainers to merge.
    Richard Dallaway
    @d6y
    Done! Thank you @mdedetrich and @milessabin
    Dave Gurnell
    @davegurnell
    I know I'm ridiculously (about a month?) late to the party here, but we should totally add an alternative to <> to slickless to make case class mappings a one liner:
    (id :: email :: HNil) <_\o/_> Generic[User] or similar
    (id :: email :: HNil).shape[User]
    etc
    Marius B. Kotsbak
    @mkotsbak
    Hehe, was that the easiest operator you found? :)
    Dave Gurnell
    @davegurnell
    Aye :) It's actually incorrect, looking at it... it has letters next to symbols.
    But the second form seems more appropriate than the first anyway.
    Marius B. Kotsbak
    @mkotsbak
    Yes, that would be nice
    Dave Gurnell
    @davegurnell

    PR here:
    https://github.com/underscoreio/slickless/pull/10/files

    Note in the discussion that I'm not totally happy with the syntax. Let me know if anyone can suggest a workaround for the problem described there.

    Philippe Derome
    @phderome
    @davegurnell does this address issue of slow compiles on errors as per that discussion milessabin/shapeless#619 ? Meaning, compile time to handle mapping with large case classes is now pretty good?
    Dave Gurnell
    @davegurnell
    @phderome The PR won't change the performance, but the compile times for Slickless shouldn't be tooooo bad because we're not using Generic or LabelledGeneric recursively.
    If you see otherwise, please let me know. It'd be useful to know what the pain points are.
    Philippe Derome
    @phderome
    Thanks! I might give it a try within next week or two (on a new job where Slick is used) and should get back.
    Alexander Ioffe
    @deusaquilus
    Hi. I'm trying to create a HListCaseClassShape which will work exactly the same way CaseClassShape works only by converting to a slickless/scalaz HList instead. Is it possible to build this HListCaseClassShape based on the hconsShape? Any idea how I can get this right?
    class HListCaseClassShape[P <: Product, LiftedList, LiftedCaseClass <: P, PlainList, PlainCaseClass <: P](
           mapLifted: LiftedList => LiftedCaseClass, mapPlain: PlainList => PlainCaseClass)(
           implicit columnShapes: Shape[FlatShapeLevel, LiftedList, PlainList, LiftedList], classTag: ClassTag[PlainCaseClass])
      extends MappedScalaProductShape[FlatShapeLevel, P, LiftedCaseClass, PlainCaseClass, LiftedCaseClass] {
      val shapes = columnShapes.asInstanceOf[ ??? ].shapes
      override def toMapped(v: Any) = {
        val folded = v.asInstanceOf[Product].productIterator.foldRight(HNil: HList)(_ :: _)
        folded.asInstanceOf[PlainList]
      }
      def buildValue(elems: IndexedSeq[Any]) = {
        val list = elems.foldRight(HNil: HList)(_ :: _)
        mapLifted(list.asInstanceOf[LiftedList])
      }
      def copy(s: Seq[Shape[_ <: ShapeLevel, _, _, _]]) = ???
    }
    Dave Gurnell
    @davegurnell
    Hi @deusaquilus. IIUC that's supported out of the box in the latest version of Slickless. Have you seen the mappedWith method? https://github.com/underscoreio/slickless#synopsis
    Alexander Ioffe
    @deusaquilus
    Hi @davegurnell, I'm a bit confused. Does slickless have an implicit shape for case classes? Don't you have to have a table object plus * projection for it to work? How do you do it via just a lifted/non-lifted case class?

    Here is what I am trying to do:

    case class LiftedB(data1: Rep[String], data2: Rep[String], data3: Rep[String], data4: Rep[String], data5: Rep[String], data6: Rep[String], data7: Rep[String], data8: Rep[String], data9: Rep[String], data10: Rep[String], data11: Rep[String], data12: Rep[String], data13: Rep[String], data14: Rep[String], data15: Rep[String], data16: Rep[String], data17: Rep[String], data18: Rep[String], data19: Rep[String], data20: Rep[String], data21: Rep[String], data22: Rep[String], data23: Rep[String], data24: Rep[String], data25: Rep[String])
    case class B(data1: String, data2: String, data3: String, data4: String, data5: String, data6: String, data7: String, data8: String, data9: String, data10: String, data11: String, data12: String, data13: String, data14: String, data15: String, data16: String, data17: String, data18: String, data19: String, data20: String, data21: String, data22: String, data23: String, data24: String, data25: String )
    
    type DirectConsList = HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HCons[String, HNil]]]]]]]]]]]]]]]]]]]]]]]]]
    type LiftedConsList = HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HCons[Rep[String], HNil]]]]]]]]]]]]]]]]]]]]]]]]]
    
    implicit object BShape extends HListCaseClassShape[
      Product,
      LiftedConsList,
      LiftedB,
      DirectConsList,
      B](toLifted, toDirect)
    
    def toLifted(list: LiftedConsList) = {
      list match {
        case data1 :: data2 :: data3 :: data4 :: data5 :: data6 :: data7 :: data8 :: data9 :: data10 :: data11 :: data12 :: data13 :: data14 :: data15 :: data16 :: data17 :: data18 :: data19 :: data20 :: data21 :: data22 :: data23 :: data24 :: data25 :: HNil => {
          LiftedB(data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11, data12, data13, data14, data15, data16, data17, data18, data19, data20, data21, data22, data23, data24, data25 )
        }
        case _ => throw new Exception("malformed HList")
      }
    }
    
    def toDirect(list:DirectConsList) = {
      list match {
        case data1 :: data2 :: data3 :: data4 :: data5 :: data6 :: data7 :: data8 :: data9 :: data10 :: data11 :: data12 :: data13 :: data14 :: data15 :: data16 :: data17 :: data18 :: data19 :: data20 :: data21 :: data22 :: data23 :: data24 :: data25 :: HNil => {
          B(data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11, data12, data13, data14, data15, data16, data17, data18, data19, data20, data21, data22, data23, data24, data25 )
        }
        case _ => throw new Exception("malformed HList")
      }
    }

    Unfortunately this did not work...

    Richard Dallaway
    @d6y
    Hey @deusaquilus - I’m a bit confused too. WIth slickless we do define a Table and a *. I guess you’re looking to work the “monomorphic case clases” style at http://slick.lightbend.com/doc/3.1.1/userdefined.html#monomorphic-case-classes - it’s not something I use or understand. You still need a Table as I understand it. I’m not sure what the appeal is. I suppose what I’m saying is… I don’t know what you’re trying to do :-) Do you have an code example where you’d use this style? maybe that’d make it clearer. Sorry I can’t be of more help at the moment.
    Alexander Ioffe
    @deusaquilus
    Yes, I was trying to create a monomorphic case class that is independent of a table that could be used in an arbitrary projection. However, it turns out that the above approach works, there was only a slight typo where I forgot mapPlain(folded.asInstanceOf[PlainList]) in the toMapped. Full gist available here: HListCaseClassShape.
    Dave Gurnell
    @davegurnell
    Hi @deusaquilus. Apologies for coming to this discussion super late. I've been bad at monitoring Gitter lately. Did you get things sorted out?
    @tksfz
    @tksfz
    hi i'm sure you get this question all the time so i apologize. Can slickless be made to work with slick 2.1? i've copied the code into a project with slick 2.1 and it seems to at least compile
    @tksfz
    @tksfz
    hi @davegurnell i'm sure you get this question all the time - Can slickless be made to work with slick 2.1? i've copied the code into a project with slick 2.1 and it seems to at least compile
    Richard Dallaway
    @d6y
    @tksfz I don't think anyone else has asked for a Slick 2.1 version. Looks like you're leading the way. Can you let us know if it works for you?
    @tksfz
    @tksfz
    oh cool. well it does compile unmodified.
    would it make any sense for me to try to push a PR that adds cross-building and publishing for slick 2.1?
    or is that not useful?
    @tksfz
    @tksfz
    now that i look at it i don't see an obvious way to do that. since it's a fairly small lib, maybe copying the code is the best route.
    Guang
    @pangwa
    hello,
    Lucky
    @lucky0604
    does anybody's here?
    Lucky
    @lucky0604

    when I use slickless with a model, more than 22 params, and the code is

    def * = (a1 :: a2 ::  ... :: a30 :: HNil).mappedWith(Generic[Model])

    it returns an error that

    No matching Shape found.
    Slick does not know how to map the given types.
    Possible causes: T in Table[T] does not match your * projection,
     you use an unsupported type in a Query (e.g. scala List),
     or you forgot to import a driver api into scope.
      Required level: L
         Source type: slick.lifted.Rep[Option[Long]] :: slick.lifted.Rep[Option[Long]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[Int]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[Int]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[Int]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[Int]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[Int]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[String]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[Int]] :: slick.lifted.Rep[Option[java.sql.Date]] :: slick.lifted.Rep[Option[...]] :: slick.lifted.Rep[...] :: ... :: ...
       Unpacked type: this.Repr
         Packed type: P

    what's wrong with this? thanks for ur help

    Daniel
    @ErunamoJAZZ
    @lucky0604 hi, the error looks like your case class Model just does not feet to the shape of the HList correctly
    If by example, your db model use a type Option[Int] but your case class use just Int, the error will throw
    Or the order could be incorrect
    Daniel
    @ErunamoJAZZ
    You must review it careful in order to find where this is wrong, good luck!
    Richard Dallaway
    @d6y
    What Daniel said… and if you have domain types in there (e.g., user, or a date library) they have mappings. But otherwise, should work. The simple example we give is: https://github.com/underscoreio/slickless/blob/master/src/test/scala/userapp/LargeSpec.scala
    Happy to stare at code if you have git repository somewhere.
    Lucky
    @lucky0604
    @ErunamoJAZZ yeah, you're right man. ma mistake. :)
    @ErunamoJAZZ thx bro.
    @d6y thx bro. it's already fixed.
    Daniel
    @ErunamoJAZZ
    cool, :)
    Răzvan Rotaru
    @roti
    can slickless be used to map to classes which are not flat (i.e. some fields are mapped to a subobject) ?

    for example the class is

    case class Employee(id: Int, name: String, department: Department)

    and the employee table is denormalized, it contains the department fields as well

    Richard Dallaway
    @d6y