From aa00f120476c67ae36855edd6d15e763917eb923 Mon Sep 17 00:00:00 2001 From: Andrzej Jozwik Date: Fri, 6 Sep 2019 09:03:44 +0200 Subject: [PATCH] extract context --- .../quillmacro/async/AsyncJdbcRepository.scala | 14 ++++++++++---- .../async/CassandraAsyncRepository.scala | 7 +++++-- .../cassandra/sync/CassandraRepository.scala | 5 +++-- .../monix/CassandraMonixRepository.scala | 9 +++++---- .../quillmacro/sync/JdbcRepository.scala | 13 +++++++++---- .../monix/jdbc/MonixJdbcRepository.scala | 15 ++++++++++----- version.sbt | 2 +- 7 files changed, 43 insertions(+), 22 deletions(-) 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 5389013..1781abd 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 @@ -16,14 +16,16 @@ object AsyncJdbcRepository { trait AsyncJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] extends AsyncRepositoryWithGeneratedId[K, T] - with WithUpdate[Long] { - protected val context: AsyncJdbcContextDateQuotes[D, N, C] + with WithUpdate[Long] + with WithAsyncJdbcContext[D, N, C] { protected def dynamicSchema: context.DynamicEntityQuery[T] } -trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] extends AsyncRepository[K, T] with WithUpdate[Long] { - protected val context: AsyncJdbcContextDateQuotes[D, N, C] +trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] + extends AsyncRepository[K, T] + with WithUpdate[Long] + with WithAsyncJdbcContext[D, N, C] { protected def dynamicSchema: context.DynamicEntityQuery[T] @@ -31,3 +33,7 @@ trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, trait AsyncJdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] extends AsyncJdbcRepository[K, T, D, N, C] + +trait WithAsyncJdbcContext[D <: SqlIdiom, N <: NamingStrategy, C <: Connection] { + protected val context: AsyncJdbcContextDateQuotes[D, N, C] +} diff --git a/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/async/CassandraAsyncRepository.scala b/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/async/CassandraAsyncRepository.scala index d2ad089..9914644 100644 --- a/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/async/CassandraAsyncRepository.scala +++ b/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/async/CassandraAsyncRepository.scala @@ -11,11 +11,14 @@ object CassandraAsyncRepository { type CassandraAsyncContextDateQuotes[N <: NamingStrategy] = CassandraAsyncContext[N] with AsyncCrudWithContextDateQuotesUnit } -trait CassandraAsyncRepository[K, T <: WithId[K], N <: NamingStrategy] extends AsyncRepository[K, T] with WithUpdate[Unit] { - protected val context: CassandraAsyncContextDateQuotes[N] +trait CassandraAsyncRepository[K, T <: WithId[K], N <: NamingStrategy] extends AsyncRepository[K, T] with WithUpdate[Unit] with WithCassandraAsyncContext[N] { protected def dynamicSchema: context.DynamicEntityQuery[T] } trait CassandraAsyncRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraAsyncRepository[K, T, N] + +trait WithCassandraAsyncContext[N <: NamingStrategy] { + protected val context: CassandraAsyncContextDateQuotes[N] +} diff --git a/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/sync/CassandraRepository.scala b/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/sync/CassandraRepository.scala index b64dded..c910ff1 100644 --- a/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/sync/CassandraRepository.scala +++ b/quill-cassandra-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/sync/CassandraRepository.scala @@ -10,11 +10,12 @@ object CassandraRepository { type CassandraContextDateQuotes[N <: NamingStrategy] = CassandraSyncContext[N] with CrudWithContextDateQuotesUnit } -trait CassandraRepository[K, T <: WithId[K], N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Unit] { - protected val context: CassandraContextDateQuotes[N] +trait CassandraRepository[K, T <: WithId[K], N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Unit] with WithCassandraContext[N] { protected def dynamicSchema: context.DynamicEntityQuery[T] } trait CassandraRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraRepository[K, T, N] + +trait WithCassandraContext[N <: NamingStrategy] { protected val context: CassandraContextDateQuotes[N] } diff --git a/quill-cassandra-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/monix/CassandraMonixRepository.scala b/quill-cassandra-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/monix/CassandraMonixRepository.scala index d9bd43b..8af2566 100644 --- a/quill-cassandra-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/monix/CassandraMonixRepository.scala +++ b/quill-cassandra-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/cassandra/monix/CassandraMonixRepository.scala @@ -10,11 +10,12 @@ object CassandraMonixRepository { type CassandraMonixContextDateQuotes[N <: NamingStrategy] = CassandraMonixContext[N] with MonixWithContextDateQuotesUnit } -trait CassandraMonixRepository[K, T <: WithId[K], N <: NamingStrategy] extends MonixRepository[K, T] with WithUpdate[Unit] { - protected val context: CassandraMonixContextDateQuotes[N] - +trait CassandraMonixRepository[K, T <: WithId[K], N <: NamingStrategy] extends MonixRepository[K, T] with WithUpdate[Unit] with WithCassandraMonixContext[N] { protected def dynamicSchema: context.DynamicEntityQuery[T] - } trait CassandraMonixRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraMonixRepository[K, T, N] + +trait WithCassandraMonixContext[N <: NamingStrategy] { + protected val context: CassandraMonixContextDateQuotes[N] +} diff --git a/quill-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/sync/JdbcRepository.scala b/quill-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/sync/JdbcRepository.scala index c0c6627..8f3053c 100644 --- a/quill-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/sync/JdbcRepository.scala +++ b/quill-jdbc-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/sync/JdbcRepository.scala @@ -13,8 +13,10 @@ object JdbcRepository { type JdbcContextDateQuotes[D <: SqlIdiom, N <: NamingStrategy] = JdbcContext[D, N] with ContextDateQuotes[D, N] } -trait JdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends SyncRepositoryWithGeneratedId[K, T] with WithUpdate[Long] { - protected val context: JdbcContextDateQuotes[D, N] +trait JdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] + extends SyncRepositoryWithGeneratedId[K, T] + with WithUpdate[Long] + with WithJdbcContext[D, N] { protected def dynamicSchema: context.DynamicEntityQuery[T] @@ -22,8 +24,7 @@ trait JdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: Namin context.transaction(task) } -trait JdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Long] { - protected val context: JdbcContextDateQuotes[D, N] +trait JdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Long] with WithJdbcContext[D, N] { protected def dynamicSchema: context.DynamicEntityQuery[T] @@ -33,3 +34,7 @@ trait JdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] exte } trait JdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends JdbcRepository[K, T, D, N] + +trait WithJdbcContext[D <: SqlIdiom, N <: NamingStrategy] { + protected val context: JdbcContextDateQuotes[D, N] +} diff --git a/quill-jdbc-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/monix/jdbc/MonixJdbcRepository.scala b/quill-jdbc-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/monix/jdbc/MonixJdbcRepository.scala index c95664b..7c10ed6 100644 --- a/quill-jdbc-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/monix/jdbc/MonixJdbcRepository.scala +++ b/quill-jdbc-monix-macro/src/main/scala/pl/jozwik/quillgeneric/quillmacro/monix/jdbc/MonixJdbcRepository.scala @@ -13,8 +13,10 @@ object MonixJdbcRepository { type MonixJdbcContextDateQuotes[D <: SqlIdiom, N <: NamingStrategy] = MonixJdbcContext[D, N] with MonixWithContextDateQuotesLong } -trait MonixJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends MonixRepository[K, T] with WithUpdate[Long] { - protected val context: MonixJdbcContextDateQuotes[D, N] +trait MonixJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] + extends MonixRepository[K, T] + with WithUpdate[Long] + with WithMonixJdbcContext[D, N] { protected def dynamicSchema: context.DynamicEntityQuery[T] @@ -25,9 +27,8 @@ trait MonixJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] trait MonixJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends MonixRepositoryWithGeneratedId[K, T] - with WithUpdate[Long] { - - protected val context: MonixJdbcContextDateQuotes[D, N] + with WithUpdate[Long] + with WithMonixJdbcContext[D, N] { protected def dynamicSchema: context.DynamicEntityQuery[T] @@ -35,4 +36,8 @@ trait MonixJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: context.transaction(task) } +trait WithMonixJdbcContext[D <: SqlIdiom, N <: NamingStrategy] { + protected val context: MonixJdbcContextDateQuotes[D, N] +} + trait MonixJdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends MonixJdbcRepository[K, T, D, N] diff --git a/version.sbt b/version.sbt index 6fbb590..217b7d2 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.8.5" +ThisBuild / version := "0.8.6"