karimagnusson / kuzminki-zio

Kuzminki is feature-rich query builder and access library for PostgreSQL written in Scala.
https://kuzminki.info
Apache License 2.0
27 stars 1 forks source link

Any thoughts about ZIO 2 and scala 2.13? #2

Open shevv920 opened 2 years ago

shevv920 commented 2 years ago

I tried to upgrade to scala 2.13 and to migrate to ZIO 2 https://github.com/shevv920/kuzminki-zio/pull/1/files Worked fine for me, but only thing i've tested is simple INSERT and SELECT operations

  class Fruit extends Model("fruit") {
    val id   = column[Int]("id")
    val name = column[String]("name")
    def all  = (id, name)
  }

  val fruit = Model.get[Fruit]

  val job = for {
    _      <- sql.insert(fruit).cols1(t => t.name).run("Banana")
    fruits <- sql.select(fruit).cols2(_.all).all.run
  } yield fruits

Worked fine for me

karimagnusson commented 2 years ago

Thank you for this. I was planing to make a version for ZIO 2. I will take your version and test it and then publish. In the code there is RIO[Kuzminki with Any, R] Is “with Any” nessasery?

shevv920 commented 2 years ago

Thank you for this. I was planing to make a version for ZIO 2. I will take your version and test it and then publish. In the code there is RIO[Kuzminki with Any, R] Is “with Any” nessasery?

Looks like with Any is not necessary, removed it. It came from scalafix rule changes from zio2 migrate guide I've updated my code to test and it's fine Only manual changes are

  -def get = ZIO.environment[Kuzminki](_.get) //from scalafix
  +def get = ZIO.service[Kuzminki]
karimagnusson commented 2 years ago

I tested your changes and it works like a charm. I created a new repo for this version: https://github.com/karimagnusson/kuzminki-zio-2 Do you know how to package and publish to Maven a project for multiple Scala versions? I'm thinking of 2.12 and 2.13.

shevv920 commented 2 years ago

I tested your changes and it works like a charm. I created a new repo for this version: https://github.com/karimagnusson/kuzminki-zio-2 Do you know how to package and publish to Maven a project for multiple Scala versions? I'm thinking of 2.12 and 2.13.

Cool, thank you! Unfortunately I have no experience in publishing. But I can try to do it for my fork and get back to you :)

shevv920 commented 2 years ago

Actually I tried to setup crossbuild: https://github.com/shevv920/kuzminki-zio-2/pull/1/files

sbt +publishLocal locally works fine, i have 2.12 and 2.13 published versions

Next part can be better, I think:


libraryDependencies ++= {
    CrossVersion.partialVersion(scalaVersion.value) match {
      case Some((2, 12)) => Seq("org.scala-lang" % "scala-reflect" % scala212)
      case Some((2, 13)) => Seq("org.scala-lang" % "scala-reflect" % scala213)
      case _ => Nil
    }
  }