From 05a8e8886f97eeca08a3010ab2295485e5a3a98f Mon Sep 17 00:00:00 2001 From: "andrzej.jozwik@gmail.com" Date: Mon, 13 Jul 2020 21:19:09 +0200 Subject: [PATCH 1/5] change to jasync --- build.sbt | 14 +++++----- .../async/AsyncJdbcRepository.scala | 16 ++++++------ .../ConfigurationAsyncRepository.scala | 6 +++-- .../repository/PersonAsyncRepository.scala | 26 +++++++++---------- version.sbt | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build.sbt b/build.sbt index 3e84ea0..6526d63 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ import com.sksamuel.scapegoat.sbt.ScapegoatSbtPlugin.autoImport._ val `scalaVersion_2.13` = "2.13.3" -val `scalaVersion_2.12` = "2.12.11" +val `scalaVersion_2.12` = "2.12.12" val `only2_12` = Seq(`scalaVersion_2.12`) @@ -62,9 +62,9 @@ val `ch.qos.logback_logback-classic` = "ch.qos.logback" % "logback-classic" % "1 val `io.getquill_quill-core` = "io.getquill" %% "quill-core" % quillVersion -val `io.getquill_quill-async` = "io.getquill" %% "quill-async" % quillVersion +val `io.getquill_quill-jasync` = "io.getquill" %% "quill-jasync" % quillVersion -val `io.getquill_quill-async-mysql` = "io.getquill" %% "quill-async-mysql" % quillVersion +val `io.getquill_quill-jasync-mysql` = "io.getquill" %% "quill-jasync-mysql" % quillVersion val `io.getquill_quill-cassandra-monix` = "io.getquill" %% "quill-cassandra-monix" % quillVersion @@ -147,8 +147,8 @@ lazy val `quill-jdbc-macro` = projectWithName("quill-jdbc-macro", file("quill-jd .settings(libraryDependencies ++= Seq(`io.getquill_quill-jdbc`)) .dependsOn(`macro-quill`, `macro-quill` % "test->test") -lazy val `quill-async-jdbc-macro` = projectWithNameOnly12("quill-async-jdbc-macro", file("quill-async-jdbc-macro")) - .settings(libraryDependencies ++= Seq(`io.getquill_quill-async`, `io.getquill_quill-async-mysql` % Test)) +lazy val `quill-async-jdbc-macro` = projectWithName("quill-async-jdbc-macro", file("quill-async-jdbc-macro")) + .settings(libraryDependencies ++= Seq(`io.getquill_quill-jasync`, `io.getquill_quill-jasync-mysql` % Test)) .dependsOn(`macro-quill`, `macro-quill` % "test->test") lazy val baseModules = @@ -164,10 +164,10 @@ lazy val cassandraModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](`quill-cassandra-macro`, `quill-cassandra-monix-macro`) lazy val scala213Modules = - baseModules ++ dbModules + baseModules ++ dbModules ++ asyncDbModules lazy val allModules = - scala213Modules ++ asyncDbModules ++ cassandraModules + scala213Modules ++ cassandraModules def projectWithNameOnly12(name: String, file: File): Project = projectWithName(name, file).settings( diff --git a/quill-async-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/async/AsyncJdbcRepository.scala b/quill-async-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/async/AsyncJdbcRepository.scala index 3556677..49ef4f1 100644 --- a/quill-async-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/async/AsyncJdbcRepository.scala +++ b/quill-async-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/async/AsyncJdbcRepository.scala @@ -1,20 +1,20 @@ package pl.jozwik.quillgeneric.quillmacro.async -import com.github.mauricio.async.db.Connection +import com.github.jasync.sql.db.ConcreteConnection import io.getquill.NamingStrategy import io.getquill.context.Context -import io.getquill.context.async.AsyncContext +import io.getquill.context.jasync.JAsyncContext import io.getquill.context.sql.idiom.SqlIdiom import io.getquill.idiom.Idiom import pl.jozwik.quillgeneric.quillmacro.async.AsyncJdbcRepository.AsyncJdbcContextDateQuotes import pl.jozwik.quillgeneric.quillmacro.{ CompositeKey, WithId, WithUpdate } object AsyncJdbcRepository { - type ContextDateQuotes[D <: Idiom, N <: NamingStrategy] = Context[D, N] with AsyncCrudWithContext[Long] - type AsyncJdbcContextDateQuotes[D <: SqlIdiom, N <: NamingStrategy, C <: Connection] = AsyncContext[D, N, C] with ContextDateQuotes[D, N] + type ContextDateQuotes[D <: Idiom, N <: NamingStrategy] = Context[D, N] with AsyncCrudWithContext[Long] + type AsyncJdbcContextDateQuotes[D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection] = JAsyncContext[D, N, C] with ContextDateQuotes[D, N] } -trait AsyncJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] +trait AsyncJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection] extends AsyncRepositoryWithGeneratedId[K, T] with WithUpdate[Long] with WithAsyncJdbcContext[D, N, C] { @@ -22,7 +22,7 @@ trait AsyncJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: protected def dynamicSchema: context.DynamicEntityQuery[T] } -trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] +trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection] extends AsyncRepository[K, T] with WithUpdate[Long] with WithAsyncJdbcContext[D, N, C] { @@ -31,9 +31,9 @@ trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, } -trait AsyncJdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] +trait AsyncJdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection] extends AsyncJdbcRepository[K, T, D, N, C] -trait WithAsyncJdbcContext[D <: SqlIdiom, N <: NamingStrategy, C <: Connection] { +trait WithAsyncJdbcContext[D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection] { protected val context: AsyncJdbcContextDateQuotes[D, N, C] } diff --git a/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/ConfigurationAsyncRepository.scala b/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/ConfigurationAsyncRepository.scala index 83f84a7..60c4a6f 100644 --- a/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/ConfigurationAsyncRepository.scala +++ b/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/ConfigurationAsyncRepository.scala @@ -1,6 +1,6 @@ package pl.jozwik.quillgeneric.async.jdbc.repository -import com.github.mauricio.async.db.Connection +import com.github.jasync.sql.db.ConcreteConnection import io.getquill.NamingStrategy import io.getquill.context.sql.idiom.SqlIdiom import pl.jozwik.quillgeneric.model.{ Configuration, ConfigurationId } @@ -9,13 +9,15 @@ import pl.jozwik.quillgeneric.quillmacro.async.AsyncJdbcRepository.AsyncJdbcCont import scala.concurrent.{ ExecutionContext, Future } -class ConfigurationAsyncRepository[D <: SqlIdiom, N <: NamingStrategy, C <: Connection]( +class ConfigurationAsyncRepository[D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection]( protected val context: AsyncJdbcContextDateQuotes[D, N, C], tableName: String ) extends AsyncJdbcRepository[ConfigurationId, Configuration, D, N, C] { protected def dynamicSchema: context.DynamicEntityQuery[Configuration] = dSchema + import context.toFuture + private implicit val dSchema: context.DynamicEntityQuery[Configuration] = context.dynamicQuerySchema[Configuration](tableName) diff --git a/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/PersonAsyncRepository.scala b/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/PersonAsyncRepository.scala index fd78c57..0ec258d 100644 --- a/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/PersonAsyncRepository.scala +++ b/quill-async-jdbc-macro/src/test/scala/pl/jozwik/quillgeneric/async/jdbc/repository/PersonAsyncRepository.scala @@ -1,6 +1,6 @@ package pl.jozwik.quillgeneric.async.jdbc.repository -import com.github.mauricio.async.db.Connection +import com.github.jasync.sql.db.ConcreteConnection import io.getquill.NamingStrategy import io.getquill.context.sql.idiom.SqlIdiom import pl.jozwik.quillgeneric.model.{ Person, PersonId } @@ -9,11 +9,13 @@ import pl.jozwik.quillgeneric.quillmacro.async.AsyncJdbcRepositoryWithGeneratedI import scala.concurrent.{ ExecutionContext, Future } -class PersonAsyncRepository[D <: SqlIdiom, N <: NamingStrategy, C <: Connection]( +class PersonAsyncRepository[D <: SqlIdiom, N <: NamingStrategy, C <: ConcreteConnection]( protected val context: AsyncJdbcContextDateQuotes[D, N, C], tableName: String ) extends AsyncJdbcRepositoryWithGeneratedId[PersonId, Person, D, N, C] { + import context.toFuture + protected def dynamicSchema: context.DynamicEntityQuery[Person] = dSchema private implicit val dSchema: context.DynamicEntityQuery[Person] = @@ -24,38 +26,34 @@ class PersonAsyncRepository[D <: SqlIdiom, N <: NamingStrategy, C <: Connection] override def create(entity: Person, generatedId: Boolean)(implicit ex: ExecutionContext): Future[PersonId] = context.transaction { implicit f => - if (generatedId) { + if (generatedId) context.createAndGenerateId[PersonId, Person](entity)(dSchema, f) - } else { + else context.create[PersonId, Person](entity)(dSchema, f) - } } override def createAndRead(entity: Person, generatedId: Boolean)(implicit ex: ExecutionContext): Future[Person] = context.transaction { implicit f => - if (generatedId) { + if (generatedId) context.createWithGenerateIdAndRead[PersonId, Person](entity)(dSchema, f) - } else { + else context.createAndRead[PersonId, Person](entity)(dSchema, f) - } } override def createOrUpdate(entity: Person, generatedId: Boolean)(implicit ex: ExecutionContext): Future[PersonId] = context.transaction { implicit f => - if (generatedId) { + if (generatedId) context.createAndGenerateIdOrUpdate[PersonId, Person](entity)(dSchema, f) - } else { + else context.createOrUpdate[PersonId, Person](entity)(dSchema, f) - } } override def createOrUpdateAndRead(entity: Person, generatedId: Boolean = true)(implicit ex: ExecutionContext): Future[Person] = context.transaction { implicit f => - if (generatedId) { + if (generatedId) context.createWithGenerateIdOrUpdateAndRead[PersonId, Person](entity)(dSchema, f) - } else { + else context.createOrUpdateAndRead[PersonId, Person](entity)(dSchema, f) - } } override def read(id: PersonId)(implicit ex: ExecutionContext): Future[Option[Person]] = diff --git a/version.sbt b/version.sbt index 2aa1f08..31f84d3 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.8.9" +ThisBuild / version := "0.9.0-SNAPSHOT" From bc5b530f7b482c88f68daeab98d9ae78d3b44b5a Mon Sep 17 00:00:00 2001 From: Andrzej Jozwik Date: Tue, 14 Jul 2020 16:56:15 +0200 Subject: [PATCH 2/5] Update to jasync --- build.sbt | 37 +++++++------------------------------ version.sbt | 2 +- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/build.sbt b/build.sbt index 6526d63..f145320 100644 --- a/build.sbt +++ b/build.sbt @@ -4,6 +4,8 @@ val `scalaVersion_2.13` = "2.13.3" val `scalaVersion_2.12` = "2.12.12" +ThisBuild / scalaVersion := `scalaVersion_2.13` + val `only2_12` = Seq(`scalaVersion_2.12`) val targetJdk = "1.8" @@ -21,16 +23,7 @@ ThisBuild / scapegoatVersion := { resolvers += Resolver.sonatypeRepo("releases") -lazy val scalaVersionFromProps = sys.props.getOrElse("macro.scala.version", `scalaVersion_2.12`) - -ThisBuild / scalaVersion := { - if (is213Version(scalaVersionFromProps)) - `scalaVersion_2.13` - else - `scalaVersion_2.12` -} - -ThisBuild / crossScalaVersions := Set(scalaVersion.value, `scalaVersion_2.12`).toSeq +ThisBuild / crossScalaVersions := Seq(`scalaVersion_2.13`, `scalaVersion_2.12`) ThisBuild / organization := "com.github.ajozwik" @@ -84,21 +77,11 @@ val `org.scalatestplus_scalacheck-1-14` = "org.scalatestplus" %% "scalacheck-1-1 val `org.cassandraunit_cassandra-unit` = "org.cassandraunit" % "cassandra-unit" % "3.11.2.0" -val `com.datastax.cassandra_cassandra-driver-extras` = "com.datastax.cassandra" % "cassandra-driver-extras" % "3.8.0" +val `com.datastax.cassandra_cassandra-driver-extras` = "com.datastax.cassandra" % "cassandra-driver-extras" % "3.9.0" def is213Version(version: String): Boolean = version.startsWith("2.13") -def modulesFromProps: Seq[ClasspathDep[ProjectReference]] = - if (is213Version(scalaVersionFromProps)) - scala213Modules - else - allModules - -lazy val `quill-macro-parent` = - (project in file(".")) - .settings(skip in publish := true) - .aggregate(modulesFromProps.map(_.project): _*) - .dependsOn(modulesFromProps: _*) +skip in publish := true lazy val `macro-quill` = projectWithName("macro-quill", file("macro-quill")).settings( libraryDependencies ++= Seq( @@ -119,7 +102,7 @@ lazy val `quill-monix-macro` = projectWithName("quill-monix-macro", file("quill- .settings(libraryDependencies ++= Seq(`io.getquill_quill-monix`)) .dependsOn(`macro-quill`, `macro-quill` % "test->test") -lazy val `quill-cassandra-monix-macro` = projectWithNameOnly12("quill-cassandra-monix-macro", file("quill-cassandra-monix-macro")) +lazy val `quill-cassandra-monix-macro` = projectWithName("quill-cassandra-monix-macro", file("quill-cassandra-monix-macro")) .settings( libraryDependencies ++= Seq( `io.getquill_quill-cassandra-monix`, @@ -131,7 +114,7 @@ lazy val `quill-cassandra-monix-macro` = projectWithNameOnly12("quill-cassandra- .dependsOn(`quill-monix-macro`) .dependsOn(Seq(`macro-quill`, `quill-monix-macro`, `quill-cassandra-macro`).map(_ % "test->test"): _*) -lazy val `quill-cassandra-macro` = projectWithNameOnly12("quill-cassandra-macro", file("quill-cassandra-macro")) +lazy val `quill-cassandra-macro` = projectWithName("quill-cassandra-macro", file("quill-cassandra-macro")) .settings( libraryDependencies ++= Seq( `io.getquill_quill-cassandra`, @@ -169,12 +152,6 @@ lazy val scala213Modules = lazy val allModules = scala213Modules ++ cassandraModules -def projectWithNameOnly12(name: String, file: File): Project = - projectWithName(name, file).settings( - crossScalaVersions := `only2_12`, - skip in publish := is213Version(scalaVersion.value) - ) - def projectWithName(name: String, file: File): Project = Project(name, file).settings( libraryDependencies ++= Seq( diff --git a/version.sbt b/version.sbt index 31f84d3..552b1ca 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.9.0-SNAPSHOT" +ThisBuild / version := "0.9.0" From 88f298082a3a4cfae552de1b96b46db98b3f4d53 Mon Sep 17 00:00:00 2001 From: Andrzej Jozwik Date: Tue, 14 Jul 2020 17:04:07 +0200 Subject: [PATCH 3/5] Solved #17 --- .travis.yml | 2 +- publish.sh | 2 +- publish213.sh | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 publish213.sh diff --git a/.travis.yml b/.travis.yml index c4b867d..fbe60a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ cache: language: scala scala: - - 2.12.11 + - 2.12.12 - 2.13.3 jdk: diff --git a/publish.sh b/publish.sh index 660a0cb..6134e42 100644 --- a/publish.sh +++ b/publish.sh @@ -1,3 +1,3 @@ #!/bin/bash -PATH=$HOME/bin:$PATH sbt -Dquill.macro.log=false clean test publishLocal publishSigned sonatypeRelease +PATH=$HOME/bin:$PATH sbt -Dquill.macro.log=false clean +test +publishLocal publishSigned sonatypeRelease diff --git a/publish213.sh b/publish213.sh deleted file mode 100644 index d40bdde..0000000 --- a/publish213.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -PATH=$HOME/bin:$PATH sbt -Dquill.macro.log=false -Dmacro.scala.version=2.13 clean test publishLocal publishSigned sonatypeRelease From df1ed55d802c352af4827265012e68f2eb2a6e82 Mon Sep 17 00:00:00 2001 From: Andrzej Jozwik Date: Tue, 14 Jul 2020 17:23:06 +0200 Subject: [PATCH 4/5] cleaning code --- .scalafmt.conf | 2 +- build.sbt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index a8a2d89..d140d0d 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -6,4 +6,4 @@ newlines.alwaysBeforeTopLevelStatements = true continuationIndent.extendSite = 2 spaces.inImportCurlyBraces = true unindentTopLevelOperators = true -rewrite.rules = [AsciiSortImports, RedundantBraces, RedundantParens] \ No newline at end of file +rewrite.rules = [AsciiSortImports, RedundantBraces] \ No newline at end of file diff --git a/build.sbt b/build.sbt index f145320..84a2957 100644 --- a/build.sbt +++ b/build.sbt @@ -6,8 +6,6 @@ val `scalaVersion_2.12` = "2.12.12" ThisBuild / scalaVersion := `scalaVersion_2.13` -val `only2_12` = Seq(`scalaVersion_2.12`) - val targetJdk = "1.8" ThisBuild / scalacOptions ++= Seq("-Dquill.macro.log=false") From 102850bc4c22a563db39b04063ab929b7ee4b894 Mon Sep 17 00:00:00 2001 From: Andrzej Jozwik Date: Wed, 15 Jul 2020 11:37:01 +0200 Subject: [PATCH 5/5] SNAPSHOT --- publishSnapshot.sh | 2 +- version.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/publishSnapshot.sh b/publishSnapshot.sh index 6e861a5..f464066 100644 --- a/publishSnapshot.sh +++ b/publishSnapshot.sh @@ -1,3 +1,3 @@ #!/bin/bash -PATH=$HOME/bin:$PATH sbt clean test publishSigned +PATH=$HOME/bin:$PATH sbt -Dquill.macro.log=false clean +test +publishSigned diff --git a/version.sbt b/version.sbt index 552b1ca..31f84d3 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.9.0" +ThisBuild / version := "0.9.0-SNAPSHOT"