diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml
index 17f5715..2beb23b 100644
--- a/.github/workflows/CI.yaml
+++ b/.github/workflows/CI.yaml
@@ -22,4 +22,4 @@ jobs:
- name: Validate Scaladoc
run: sbt doc
- name: Run tests
- run: sbt test +IntegrationTest/test
+ run: sbt +test +IntegrationTest/test
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 7473e11..42d68b2 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -14,7 +14,7 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- - run: sbt ci-release
+ - run: sbt +ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
diff --git a/build.sbt b/build.sbt
index 38fb027..b364ed2 100644
--- a/build.sbt
+++ b/build.sbt
@@ -7,6 +7,7 @@ inThisBuild(
List(
organization := "st.alzo",
scalaVersion := V.scala2,
+ crossScalaVersions := V.allScala,
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer("jsfwa", "jsfwa", "zubrilinandrey@gmail.com", url("https://gitlab.com/jsfwa")),
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index 0d5fd59..867d0e1 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -4,7 +4,7 @@ object Dependencies {
object V {
val scala2 = "2.13.8"
- val scala3 = "3.1.3"
+ val scala3 = "3.2.1"
val allScala = Seq(scala2, scala3)
val cassandraDriverVersion = "4.14.1"
diff --git a/src/it/scala/zio/cassandra/session/SessionSpec.scala b/src/it/scala/zio/cassandra/session/SessionSpec.scala
index 50071ad..5510b36 100644
--- a/src/it/scala/zio/cassandra/session/SessionSpec.scala
+++ b/src/it/scala/zio/cassandra/session/SessionSpec.scala
@@ -103,9 +103,8 @@ object SessionSpec extends ZIOCassandraSpec with ZIOCassandraSpecUtils {
},
test("selectFirst should return Some(null) for null") {
for {
- result <- Session
- .selectFirst(s"select data FROM $keyspace.test_data WHERE id = 0")
- .map(_.map(_.getString(0)))
+ session <- ZIO.service[Session]
+ result <- session.selectFirst(s"select data FROM $keyspace.test_data WHERE id = 0").map(_.map(_.getString(0)))
} yield assertTrue(result.contains(null))
},
test("selectFirst interpolated query (cqlConst) should return Some") {
diff --git a/src/it/scala/zio/cassandra/session/cql/CqlSpec.scala b/src/it/scala/zio/cassandra/session/cql/CqlSpec.scala
index 709bc3c..3af8b9f 100644
--- a/src/it/scala/zio/cassandra/session/cql/CqlSpec.scala
+++ b/src/it/scala/zio/cassandra/session/cql/CqlSpec.scala
@@ -64,6 +64,12 @@ object CqlSpec extends ZIOCassandraSpec {
results <- getDataByIds(List(1, 2, 3)).select.runCollect
} yield assertTrue(results == Chunk("one", "two", "three"))
},
+ test("interpolated select should return small tuples from migration") {
+ def getAllByIds(ids: List[Long]) = cql"select id FROM tests.test_data WHERE id in $ids".as[Tuple1[Long]]
+ for {
+ results <- getAllByIds(List(1, 2, 3)).config(_.setQueryTimestamp(0L)).select.runCollect
+ } yield assertTrue(results == Chunk(Tuple1(1L), Tuple1(2L), Tuple1(3L)))
+ },
test("interpolated select should return tuples from migration") {
def getAllByIds(ids: List[Long]) =
cql"select id, data FROM tests.test_data WHERE id in $ids".as[(Long, String)]
@@ -71,6 +77,14 @@ object CqlSpec extends ZIOCassandraSpec {
results <- getAllByIds(List(1, 2, 3)).config(_.setQueryTimestamp(0L)).select.runCollect
} yield assertTrue(results == Chunk((1L, "one"), (2L, "two"), (3L, "three")))
},
+ test("interpolated select should return large tuple from migration") {
+ def getAllByIds(ids: List[Long]) =
+ cql"select id, data, count, dataset, id, data, count, dataset FROM tests.test_data WHERE id in $ids"
+ .as[(Long, String, Int, Set[Int], Long, String, Int, Set[Int])]
+ for {
+ result <- getAllByIds(List(2)).config(_.setQueryTimestamp(0L)).selectFirst
+ } yield assertTrue(result.contains((2L, "two", 20, Set(201), 2L, "two", 20, Set(201))))
+ },
test("interpolated select should return tuples from migration with multiple binding") {
def getAllByIds(id1: Long, id2: Int) =
cql"select data FROM tests.test_data_multiple_keys WHERE id1 = $id1 and id2 = $id2".as[String]
diff --git a/src/it/scala/zio/cassandra/session/cql/codec/ReadsSpec.scala b/src/it/scala/zio/cassandra/session/cql/codec/ReadsSpec.scala
index 93ca3ef..d7b2b86 100644
--- a/src/it/scala/zio/cassandra/session/cql/codec/ReadsSpec.scala
+++ b/src/it/scala/zio/cassandra/session/cql/codec/ReadsSpec.scala
@@ -1,5 +1,6 @@
package zio.cassandra.session.cql.codec
+import com.datastax.oss.driver.api.core.cql.Row
import zio.cassandra.session.{ Session, ZIOCassandraSpec, ZIOCassandraSpecUtils }
import zio.test.Assertion.hasSameElements
import zio.test._
@@ -21,10 +22,14 @@ object ReadsSpec extends ZIOCassandraSpec with ZIOCassandraSpecUtils {
final case class NameTestData(id: BigInt, ALLUPPER: String, alllower: String, someName: String, someLongName: String)
+ final case class ReadsCacheTestData(id: BigInt)
+
final case class NullableCollectionsTestData(id: Int, regularList: Seq[Int], frozenList: Seq[Int])
private val nameTestData = NameTestData(0, "ALL-UPPER", "all-lower", "some-name", "some-long-name")
+ private val readsCacheTestData = ReadsCacheTestData(0)
+
val spec: Spec[Session, Throwable] = suite("Reads")(
test("should read simple data types") {
val expected =
@@ -115,6 +120,19 @@ object ReadsSpec extends ZIOCassandraSpec with ZIOCassandraSpecUtils {
.mapZIO(read[NullableCollectionsTestData](_))
.runCollect
} yield assertTrue(result.forall(d => d.regularList.isEmpty && d.frozenList.isEmpty))
+ },
+ test("should read row using row reads") {
+ for {
+ session <- ZIO.service[Session]
+ _ <- session.selectFirst(s"select id FROM $keyspace.reads_type_test").flatMap(readOpt[Row](_))
+ } yield assertCompletes
+ },
+ test("should read row using cached reader (which can be marked as implicit)") {
+ implicit val reads: Reads[ReadsCacheTestData] = Reads.derive
+ for {
+ session <- ZIO.service[Session]
+ result <- session.selectFirst(s"select id FROM $keyspace.reads_type_test where id = 0")
+ } yield assertTrue(result.map(reads.read).contains(readsCacheTestData))
}
)
diff --git a/src/main/scala-2.13/zio/cassandra/session/cql/codec/ReadsInstances.scala b/src/main/scala-2.13/zio/cassandra/session/cql/codec/ReadsInstances.scala
new file mode 100644
index 0000000..0af34fb
--- /dev/null
+++ b/src/main/scala-2.13/zio/cassandra/session/cql/codec/ReadsInstances.scala
@@ -0,0 +1,711 @@
+package zio.cassandra.session.cql.codec
+
+import com.datastax.oss.driver.api.core.cql.Row
+import shapeless.{ ::, HList, HNil, LabelledGeneric, Witness }
+import shapeless.labelled.{ field, FieldType }
+import zio.cassandra.session.cql.codec.Reads.instance
+
+trait ReadsInstances0 extends ReadsInstances1 {
+
+ /** Useful when you want to "cache" [[zio.cassandra.session.cql.codec.Reads]] instance (e.g. to decrease compilation
+ * time or make sure it captures the correct [[zio.cassandra.session.cql.codec.Configuration]])
+ *
+ * Example:
+ * {{{
+ * final case class Foo(a: Int, b: String)
+ *
+ * // somewhere else
+ * implicit val configuration: Configuration = {
+ * val renameFields: String => String = {
+ * case "a" => "some_other_name"
+ * case other => Configuration.snakeCaseTransformation(other)
+ * }
+ * Configuration(renameFields)
+ * }
+ *
+ * implicit val reads: Reads[Foo] = Reads.derive
+ * }}}
+ */
+ def derive[T, Repr](implicit
+ configuration: Configuration,
+ gen: LabelledGeneric.Aux[T, Repr],
+ reads: Reads[Repr]
+ ): Reads[T] = genericReads
+
+}
+
+trait ReadsInstances1 extends ReadsInstances2 {
+
+ implicit val rowReads: Reads[Row] = instance(identity)
+
+ implicit def tuple1Reads[
+ T1: CellReads
+ ]: Reads[Tuple1[T1]] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ Tuple1(t1)
+ }
+
+ implicit def tuple2Reads[
+ T1: CellReads,
+ T2: CellReads
+ ]: Reads[(T1, T2)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ (t1, t2)
+ }
+
+ implicit def tuple3Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads
+ ]: Reads[(T1, T2, T3)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ (t1, t2, t3)
+ }
+
+ implicit def tuple4Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads
+ ]: Reads[(T1, T2, T3, T4)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ (t1, t2, t3, t4)
+ }
+
+ implicit def tuple5Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ (t1, t2, t3, t4, t5)
+ }
+
+ implicit def tuple6Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ (t1, t2, t3, t4, t5, t6)
+ }
+
+ implicit def tuple7Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ (t1, t2, t3, t4, t5, t6, t7)
+ }
+
+ implicit def tuple8Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ (t1, t2, t3, t4, t5, t6, t7, t8)
+ }
+
+ implicit def tuple9Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9)
+ }
+
+ implicit def tuple10Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)
+ }
+
+ implicit def tuple11Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
+ }
+
+ implicit def tuple12Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12)
+ }
+
+ implicit def tuple13Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13)
+ }
+
+ implicit def tuple14Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14)
+ }
+
+ implicit def tuple15Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15)
+ }
+
+ implicit def tuple16Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16)
+ }
+
+ implicit def tuple17Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads,
+ T17: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ val t17 = readByIndex[T17](row, 16)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17)
+ }
+
+ implicit def tuple18Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads,
+ T17: CellReads,
+ T18: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ val t17 = readByIndex[T17](row, 16)
+ val t18 = readByIndex[T18](row, 17)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18)
+ }
+
+ implicit def tuple19Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads,
+ T17: CellReads,
+ T18: CellReads,
+ T19: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ val t17 = readByIndex[T17](row, 16)
+ val t18 = readByIndex[T18](row, 17)
+ val t19 = readByIndex[T19](row, 18)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19)
+ }
+
+ implicit def tuple20Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads,
+ T17: CellReads,
+ T18: CellReads,
+ T19: CellReads,
+ T20: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ val t17 = readByIndex[T17](row, 16)
+ val t18 = readByIndex[T18](row, 17)
+ val t19 = readByIndex[T19](row, 18)
+ val t20 = readByIndex[T20](row, 19)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20)
+ }
+
+ implicit def tuple21Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads,
+ T17: CellReads,
+ T18: CellReads,
+ T19: CellReads,
+ T20: CellReads,
+ T21: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ val t17 = readByIndex[T17](row, 16)
+ val t18 = readByIndex[T18](row, 17)
+ val t19 = readByIndex[T19](row, 18)
+ val t20 = readByIndex[T20](row, 19)
+ val t21 = readByIndex[T21](row, 20)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21)
+ }
+
+ implicit def tuple22Reads[
+ T1: CellReads,
+ T2: CellReads,
+ T3: CellReads,
+ T4: CellReads,
+ T5: CellReads,
+ T6: CellReads,
+ T7: CellReads,
+ T8: CellReads,
+ T9: CellReads,
+ T10: CellReads,
+ T11: CellReads,
+ T12: CellReads,
+ T13: CellReads,
+ T14: CellReads,
+ T15: CellReads,
+ T16: CellReads,
+ T17: CellReads,
+ T18: CellReads,
+ T19: CellReads,
+ T20: CellReads,
+ T21: CellReads,
+ T22: CellReads
+ ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22)] =
+ instance { row =>
+ val t1 = readByIndex[T1](row, 0)
+ val t2 = readByIndex[T2](row, 1)
+ val t3 = readByIndex[T3](row, 2)
+ val t4 = readByIndex[T4](row, 3)
+ val t5 = readByIndex[T5](row, 4)
+ val t6 = readByIndex[T6](row, 5)
+ val t7 = readByIndex[T7](row, 6)
+ val t8 = readByIndex[T8](row, 7)
+ val t9 = readByIndex[T9](row, 8)
+ val t10 = readByIndex[T10](row, 9)
+ val t11 = readByIndex[T11](row, 10)
+ val t12 = readByIndex[T12](row, 11)
+ val t13 = readByIndex[T13](row, 12)
+ val t14 = readByIndex[T14](row, 13)
+ val t15 = readByIndex[T15](row, 14)
+ val t16 = readByIndex[T16](row, 15)
+ val t17 = readByIndex[T17](row, 16)
+ val t18 = readByIndex[T18](row, 17)
+ val t19 = readByIndex[T19](row, 18)
+ val t20 = readByIndex[T20](row, 19)
+ val t21 = readByIndex[T21](row, 20)
+ val t22 = readByIndex[T22](row, 21)
+ (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22)
+ }
+
+}
+
+trait ReadsInstances2 extends ReadsInstances3 {
+
+ implicit val hNilReads: Reads[HNil] = instance(_ => HNil)
+
+ implicit def hConsReads[K <: Symbol, H, T <: HList](implicit
+ configuration: Configuration,
+ hReads: CellReads[H],
+ tReads: Reads[T],
+ fieldNameW: Witness.Aux[K]
+ ): Reads[FieldType[K, H] :: T] =
+ instance { row =>
+ val fieldName = configuration.transformFieldNames(fieldNameW.value.name)
+ val bytes = row.getBytesUnsafe(fieldName)
+ val fieldType = row.getType(fieldName)
+ val head = withRefinedError(hReads.read(bytes, row.protocolVersion(), fieldType))(row, fieldName)
+ val tail = tReads.read(row)
+ field[K](head) :: tail
+ }
+
+ implicit def genericReads[T, Repr](implicit
+ configuration: Configuration,
+ gen: LabelledGeneric.Aux[T, Repr],
+ reads: Reads[Repr]
+ ): Reads[T] =
+ instance(row => gen.from(reads.read(row)))
+
+ private def withRefinedError[T](expr: => T)(row: Row, fieldName: String): T =
+ try expr
+ catch refineError(row, row.getColumnDefinitions.get(fieldName))
+
+}
diff --git a/src/main/scala-2.13/zio/cassandra/session/cql/codec/UdtReadsInstances1.scala b/src/main/scala-2.13/zio/cassandra/session/cql/codec/UdtReadsInstances1.scala
new file mode 100644
index 0000000..abc994d
--- /dev/null
+++ b/src/main/scala-2.13/zio/cassandra/session/cql/codec/UdtReadsInstances1.scala
@@ -0,0 +1,42 @@
+package zio.cassandra.session.cql.codec
+
+import com.datastax.oss.driver.api.core.data.UdtValue
+import shapeless.{ ::, HList, HNil, LabelledGeneric, Lazy, Witness }
+import shapeless.labelled.{ field, FieldType }
+import zio.cassandra.session.cql.codec.UdtReads.instance
+
+trait UdtReadsInstances1 {
+
+ implicit val hNilUdtReads: UdtReads[HNil] = instance(_ => HNil)
+
+ implicit def hConsUdtReads[K <: Symbol, H, T <: HList](implicit
+ configuration: Configuration,
+ hReads: Lazy[CellReads[H]],
+ tReads: UdtReads[T],
+ fieldNameW: Witness.Aux[K]
+ ): UdtReads[FieldType[K, H] :: T] =
+ instance { udtValue =>
+ val fieldName = configuration.transformFieldNames(fieldNameW.value.name)
+ val bytes = udtValue.getBytesUnsafe(fieldName)
+ val types = udtValue.getType(fieldName)
+
+ val head = withRefinedError(hReads.value.read(bytes, udtValue.protocolVersion(), types))(udtValue, fieldName)
+ val tail = tReads.read(udtValue)
+
+ field[K](head) :: tail
+ }
+
+ implicit def genericUdtReads[T, Repr](implicit
+ configuration: Configuration,
+ gen: LabelledGeneric.Aux[T, Repr],
+ reads: Lazy[UdtReads[Repr]]
+ ): UdtReads[T] =
+ instance(udtValue => gen.from(reads.value.read(udtValue)))
+
+ private def withRefinedError[T](expr: => T)(udtValue: UdtValue, fieldName: String): T =
+ try expr
+ catch {
+ case UnexpectedNullValue.NullValueInColumn => throw UnexpectedNullValue.NullValueInUdt(udtValue, fieldName)
+ }
+
+}
diff --git a/src/main/scala-2.13/zio/cassandra/session/cql/codec/UdtWritesInstances1.scala b/src/main/scala-2.13/zio/cassandra/session/cql/codec/UdtWritesInstances1.scala
new file mode 100644
index 0000000..0ec165a
--- /dev/null
+++ b/src/main/scala-2.13/zio/cassandra/session/cql/codec/UdtWritesInstances1.scala
@@ -0,0 +1,32 @@
+package zio.cassandra.session.cql.codec
+
+import shapeless.{ ::, HList, HNil, LabelledGeneric, Lazy, Witness }
+import shapeless.labelled.FieldType
+import zio.cassandra.session.cql.codec.UdtWrites.instance
+
+trait UdtWritesInstances1 {
+
+ implicit val hNilUdtWrites: UdtWrites[HNil] = instance((_, udtValue) => udtValue)
+
+ implicit def hConsUdtWrites[K <: Symbol, H, T <: HList](implicit
+ configuration: Configuration,
+ hWrites: Lazy[CellWrites[H]],
+ tWrites: UdtWrites[T],
+ fieldNameW: Witness.Aux[K]
+ ): UdtWrites[FieldType[K, H] :: T] =
+ instance { (t, udtValue) =>
+ val fieldName = configuration.transformFieldNames(fieldNameW.value.name)
+ val hType = udtValue.getType(fieldName)
+ val hBytes = hWrites.value.write(t.head, udtValue.protocolVersion(), hType)
+ val valueWithH = udtValue.setBytesUnsafe(fieldName, hBytes)
+ tWrites.write(t.tail, valueWithH)
+ }
+
+ implicit def genericUdtWrites[T, Repr](implicit
+ configuration: Configuration,
+ gen: LabelledGeneric.Aux[T, Repr],
+ writes: Lazy[UdtWrites[Repr]]
+ ): UdtWrites[T] =
+ instance((t, udtValue) => writes.value.write(gen.to(t), udtValue))
+
+}
diff --git a/src/main/scala-3/zio/cassandra/session/cql/codec/ReadsInstances.scala b/src/main/scala-3/zio/cassandra/session/cql/codec/ReadsInstances.scala
new file mode 100644
index 0000000..33daae5
--- /dev/null
+++ b/src/main/scala-3/zio/cassandra/session/cql/codec/ReadsInstances.scala
@@ -0,0 +1,84 @@
+package zio.cassandra.session.cql.codec
+
+import com.datastax.oss.driver.api.core.cql.Row
+import zio.cassandra.session.cql.codec.Reads.instance
+
+import scala.compiletime.{constValue, erasedValue, summonInline}
+import scala.deriving.Mirror
+
+trait ReadsInstances0 extends ReadsInstances1 {
+
+ /** Useful when you want to "cache" [[zio.cassandra.session.cql.codec.Reads]] instance (e.g. to decrease compilation
+ * time or make sure it captures the correct [[zio.cassandra.session.cql.codec.Configuration]])
+ *
+ * Example:
+ * {{{
+ * final case class Foo(a: Int, b: String)
+ *
+ * // somewhere else
+ * implicit val configuration: Configuration = {
+ * val renameFields: String => String = {
+ * case "a" => "some_other_name"
+ * case other => Configuration.snakeCaseTransformation(other)
+ * }
+ * Configuration(renameFields)
+ * }
+ *
+ * implicit val reads: Reads[Foo] = Reads.derive
+ * }}}
+ */
+ inline def derive[T <: Product: Mirror.ProductOf](using configuration: Configuration): Reads[T] = derived[T]
+
+}
+
+trait ReadsInstances1 extends ReadsInstances2 {
+
+ given Reads[Row] = instance(identity)
+
+ inline given tupleNReads[T <: Tuple]: Reads[T] =
+ instance(recurse[T](_)(0).asInstanceOf[T])
+
+ // return type should be `Types`, but Scala doesn't seem to understand it
+ private inline def recurse[Types <: Tuple](row: Row)(index: Int): Tuple =
+ inline erasedValue[Types] match {
+ case _: (tpe *: types) =>
+ val head = readByIndex[tpe](row, index)(using summonInline[CellReads[tpe]])
+ val tail = recurse[types](row)(index + 1)
+
+ head *: tail
+ case _ =>
+ EmptyTuple
+ }
+
+}
+
+trait ReadsInstances2 extends ReadsInstances3 {
+
+ inline given derived[T <: Product: Mirror.ProductOf](using configuration: Configuration): Reads[T] =
+ inline summonInline[Mirror.ProductOf[T]] match {
+ case proMir =>
+ instance { row =>
+ val fields = recurse[proMir.MirroredElemLabels, proMir.MirroredElemTypes](row)(configuration)
+ proMir.fromProduct(fields)
+ }
+ }
+
+ private inline def recurse[Names <: Tuple, Types <: Tuple](row: Row)(configuration: Configuration): Tuple =
+ inline erasedValue[(Names, Types)] match {
+ case (_: (name *: names), _: (tpe *: types)) =>
+ val fieldName = configuration.transformFieldNames(constValue[name].toString)
+ val bytes = row.getBytesUnsafe(fieldName)
+ val fieldType = row.getType(fieldName)
+ val head = withRefinedError(summonInline[CellReads[tpe]].read(bytes, row.protocolVersion(), fieldType))(row, fieldName)
+ val tail = recurse[names, types](row)(configuration)
+
+ head *: tail
+ case _ =>
+ EmptyTuple
+ }
+
+ private def withRefinedError[T](expr: => T)(row: Row, fieldName: String): T =
+ try expr
+ catch refineError(row, row.getColumnDefinitions.get(fieldName))
+
+}
diff --git a/src/main/scala-3/zio/cassandra/session/cql/codec/UdtReadsInstances1.scala b/src/main/scala-3/zio/cassandra/session/cql/codec/UdtReadsInstances1.scala
new file mode 100644
index 0000000..bbc151f
--- /dev/null
+++ b/src/main/scala-3/zio/cassandra/session/cql/codec/UdtReadsInstances1.scala
@@ -0,0 +1,40 @@
+package zio.cassandra.session.cql.codec
+
+import com.datastax.oss.driver.api.core.data.UdtValue
+import zio.cassandra.session.cql.codec.UdtReads.instance
+
+import scala.compiletime.{constValue, erasedValue, summonInline}
+import scala.deriving.Mirror
+
+trait UdtReadsInstances1 {
+
+ inline given derived[T <: Product: Mirror.ProductOf](using configuration: Configuration): UdtReads[T] =
+ inline summonInline[Mirror.ProductOf[T]] match {
+ case proMir =>
+ instance { udtValue =>
+ val fields = recurse[proMir.MirroredElemLabels, proMir.MirroredElemTypes](udtValue)(configuration)
+ proMir.fromProduct(fields)
+ }
+ }
+
+ private inline def recurse[Names <: Tuple, Types <: Tuple](udtValue: UdtValue)(configuration: Configuration): Tuple =
+ inline erasedValue[(Names, Types)] match {
+ case (_: (name *: names), _: (tpe *: types)) =>
+ val fieldName = configuration.transformFieldNames(constValue[name].toString)
+ val bytes = udtValue.getBytesUnsafe(fieldName)
+ val fieldType = udtValue.getType(fieldName)
+ val head = withRefinedError(summonInline[CellReads[tpe]].read(bytes, udtValue.protocolVersion(), fieldType))(udtValue, fieldName)
+ val tail = recurse[names, types](udtValue)(configuration)
+
+ head *: tail
+ case _ =>
+ EmptyTuple
+ }
+
+ private def withRefinedError[T](expr: => T)(udtValue: UdtValue, fieldName: String): T =
+ try expr
+ catch {
+ case UnexpectedNullValue.NullValueInColumn => throw UnexpectedNullValue.NullValueInUdt(udtValue, fieldName)
+ }
+
+}
diff --git a/src/main/scala-3/zio/cassandra/session/cql/codec/UdtWritesInstances1.scala b/src/main/scala-3/zio/cassandra/session/cql/codec/UdtWritesInstances1.scala
new file mode 100644
index 0000000..a38ec2e
--- /dev/null
+++ b/src/main/scala-3/zio/cassandra/session/cql/codec/UdtWritesInstances1.scala
@@ -0,0 +1,32 @@
+package zio.cassandra.session.cql.codec
+
+import com.datastax.oss.driver.api.core.data.UdtValue
+import zio.cassandra.session.cql.codec.UdtWrites.instance
+
+import scala.compiletime.{constValue, erasedValue, summonInline}
+import scala.deriving.Mirror
+
+trait UdtWritesInstances1 {
+
+ inline given derived[T <: Product: Mirror.ProductOf](using configuration: Configuration): UdtWrites[T] =
+ inline summonInline[Mirror.ProductOf[T]] match {
+ case proMir =>
+ instance { (t, udtValue) =>
+ recurse[proMir.MirroredElemLabels, proMir.MirroredElemTypes](t, udtValue)(0)(configuration)
+ }
+ }
+
+ private inline def recurse[Names <: Tuple, Types <: Tuple](element: Product, udtValue: UdtValue)(index: Int)(configuration: Configuration): UdtValue =
+ inline erasedValue[(Names, Types)] match {
+ case (_: (name *: names), _: (tpe *: types)) =>
+ val fieldName = configuration.transformFieldNames(constValue[name].toString)
+ val fieldValue = element.productElement(index).asInstanceOf[tpe]
+ val fieldType = udtValue.getType(fieldName)
+ val bytes = summonInline[CellWrites[tpe]].write(fieldValue, udtValue.protocolVersion(), fieldType)
+ val valueWithBytes = udtValue.setBytesUnsafe(fieldName, bytes)
+ recurse[names, types](element, valueWithBytes)(index + 1)(configuration)
+ case _ =>
+ udtValue
+ }
+
+}
diff --git a/src/main/scala/zio/cassandra/session/Session.scala b/src/main/scala/zio/cassandra/session/Session.scala
index b58e0ab..6466ea9 100644
--- a/src/main/scala/zio/cassandra/session/Session.scala
+++ b/src/main/scala/zio/cassandra/session/Session.scala
@@ -7,14 +7,12 @@ import com.datastax.oss.driver.api.core.metrics.Metrics
import com.datastax.oss.driver.api.core.{ CqlIdentifier, CqlSession, CqlSessionBuilder }
import zio._
import zio.cassandra.session.cql.query.{ PreparedQuery, QueryTemplate }
-import zio.macros.accessible
import zio.stream.ZStream.Pull
import zio.stream.{ Stream, ZStream }
import scala.jdk.CollectionConverters.IterableHasAsScala
import scala.jdk.OptionConverters.RichOptional
-@accessible
trait Session {
def prepare(stmt: String): Task[PreparedStatement]
@@ -121,7 +119,7 @@ object Session {
.acquireRelease(ZIO.fromCompletionStage(builder.buildAsync())) { session =>
ZIO.fromCompletionStage(session.closeAsync()).orDie
}
- .map(Live)
+ .map(Live(_))
def existing(session: CqlSession): Session =
Live(session)
diff --git a/src/main/scala/zio/cassandra/session/cql/codec/Reads.scala b/src/main/scala/zio/cassandra/session/cql/codec/Reads.scala
index bcf2dd8..1c02491 100644
--- a/src/main/scala/zio/cassandra/session/cql/codec/Reads.scala
+++ b/src/main/scala/zio/cassandra/session/cql/codec/Reads.scala
@@ -1,8 +1,6 @@
package zio.cassandra.session.cql.codec
import com.datastax.oss.driver.api.core.cql.{ ColumnDefinition, Row }
-import shapeless._
-import shapeless.labelled.{ field, FieldType }
import zio.cassandra.session.cql.codec.Reads.instance
/** The main typeclass for decoding Cassandra values, the only one that matters.
@@ -16,7 +14,7 @@ trait Reads[T] {
}
-object Reads extends ReadsInstances1 {
+object Reads extends ReadsInstances0 {
def apply[T](implicit reads: Reads[T]): Reads[T] = reads
@@ -28,707 +26,6 @@ object Reads extends ReadsInstances1 {
}
- /** Useful when you want to "cache" [[zio.cassandra.session.cql.codec.Reads]] instance (e.g. to decrease compilation
- * time or make sure it captures the correct [[zio.cassandra.session.cql.codec.Configuration]])
- *
- * Example:
- * {{{
- * final case class Foo(a: Int, b: String)
- *
- * // somewhere else
- * implicit val configuration: Configuration = {
- * val renameFields: String => String = {
- * case "a" => "some_other_name"
- * case other => Configuration.snakeCaseTransformation(other)
- * }
- * Configuration(renameFields)
- * }
- *
- * implicit val reads: Reads[Foo] = Reads.derive
- * }}}
- */
- def derive[T, Repr](implicit
- configuration: Configuration,
- gen: LabelledGeneric.Aux[T, Repr],
- reads: Reads[Repr]
- ): Reads[T] = genericReads
-
-}
-
-trait ReadsInstances1 extends ReadsInstances2 {
-
- implicit val rowReads: Reads[Row] = instance(identity)
-
- implicit def tuple1Reads[
- T1: CellReads
- ]: Reads[Tuple1[T1]] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- Tuple1(t1)
- }
-
- implicit def tuple2Reads[
- T1: CellReads,
- T2: CellReads
- ]: Reads[(T1, T2)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- (t1, t2)
- }
-
- implicit def tuple3Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads
- ]: Reads[(T1, T2, T3)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- (t1, t2, t3)
- }
-
- implicit def tuple4Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads
- ]: Reads[(T1, T2, T3, T4)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- (t1, t2, t3, t4)
- }
-
- implicit def tuple5Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads
- ]: Reads[(T1, T2, T3, T4, T5)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- (t1, t2, t3, t4, t5)
- }
-
- implicit def tuple6Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- (t1, t2, t3, t4, t5, t6)
- }
-
- implicit def tuple7Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- (t1, t2, t3, t4, t5, t6, t7)
- }
-
- implicit def tuple8Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- (t1, t2, t3, t4, t5, t6, t7, t8)
- }
-
- implicit def tuple9Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9)
- }
-
- implicit def tuple10Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)
- }
-
- implicit def tuple11Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
- }
-
- implicit def tuple12Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12)
- }
-
- implicit def tuple13Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13)
- }
-
- implicit def tuple14Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14)
- }
-
- implicit def tuple15Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15)
- }
-
- implicit def tuple16Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16)
- }
-
- implicit def tuple17Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads,
- T17: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- val t17 = readByIndex[T17](row, 16)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17)
- }
-
- implicit def tuple18Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads,
- T17: CellReads,
- T18: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- val t17 = readByIndex[T17](row, 16)
- val t18 = readByIndex[T18](row, 17)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18)
- }
-
- implicit def tuple19Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads,
- T17: CellReads,
- T18: CellReads,
- T19: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- val t17 = readByIndex[T17](row, 16)
- val t18 = readByIndex[T18](row, 17)
- val t19 = readByIndex[T19](row, 18)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19)
- }
-
- implicit def tuple20Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads,
- T17: CellReads,
- T18: CellReads,
- T19: CellReads,
- T20: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- val t17 = readByIndex[T17](row, 16)
- val t18 = readByIndex[T18](row, 17)
- val t19 = readByIndex[T19](row, 18)
- val t20 = readByIndex[T20](row, 19)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20)
- }
-
- implicit def tuple21Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads,
- T17: CellReads,
- T18: CellReads,
- T19: CellReads,
- T20: CellReads,
- T21: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- val t17 = readByIndex[T17](row, 16)
- val t18 = readByIndex[T18](row, 17)
- val t19 = readByIndex[T19](row, 18)
- val t20 = readByIndex[T20](row, 19)
- val t21 = readByIndex[T21](row, 20)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21)
- }
-
- implicit def tuple22Reads[
- T1: CellReads,
- T2: CellReads,
- T3: CellReads,
- T4: CellReads,
- T5: CellReads,
- T6: CellReads,
- T7: CellReads,
- T8: CellReads,
- T9: CellReads,
- T10: CellReads,
- T11: CellReads,
- T12: CellReads,
- T13: CellReads,
- T14: CellReads,
- T15: CellReads,
- T16: CellReads,
- T17: CellReads,
- T18: CellReads,
- T19: CellReads,
- T20: CellReads,
- T21: CellReads,
- T22: CellReads
- ]: Reads[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22)] =
- instance { row =>
- val t1 = readByIndex[T1](row, 0)
- val t2 = readByIndex[T2](row, 1)
- val t3 = readByIndex[T3](row, 2)
- val t4 = readByIndex[T4](row, 3)
- val t5 = readByIndex[T5](row, 4)
- val t6 = readByIndex[T6](row, 5)
- val t7 = readByIndex[T7](row, 6)
- val t8 = readByIndex[T8](row, 7)
- val t9 = readByIndex[T9](row, 8)
- val t10 = readByIndex[T10](row, 9)
- val t11 = readByIndex[T11](row, 10)
- val t12 = readByIndex[T12](row, 11)
- val t13 = readByIndex[T13](row, 12)
- val t14 = readByIndex[T14](row, 13)
- val t15 = readByIndex[T15](row, 14)
- val t16 = readByIndex[T16](row, 15)
- val t17 = readByIndex[T17](row, 16)
- val t18 = readByIndex[T18](row, 17)
- val t19 = readByIndex[T19](row, 18)
- val t20 = readByIndex[T20](row, 19)
- val t21 = readByIndex[T21](row, 20)
- val t22 = readByIndex[T22](row, 21)
- (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22)
- }
-
-}
-
-trait ReadsInstances2 extends ReadsInstances3 {
-
- implicit val hNilReads: Reads[HNil] = instance(_ => HNil)
-
- implicit def hConsReads[K <: Symbol, H, T <: HList](implicit
- configuration: Configuration,
- hReads: CellReads[H],
- tReads: Reads[T],
- fieldNameW: Witness.Aux[K]
- ): Reads[FieldType[K, H] :: T] =
- instance { row =>
- val fieldName = configuration.transformFieldNames(fieldNameW.value.name)
- val bytes = row.getBytesUnsafe(fieldName)
- val fieldType = row.getType(fieldName)
- val head = withRefinedError(hReads.read(bytes, row.protocolVersion(), fieldType))(row, fieldName)
- val tail = tReads.read(row)
- field[K](head) :: tail
- }
-
- implicit def genericReads[T, Repr](implicit
- configuration: Configuration,
- gen: LabelledGeneric.Aux[T, Repr],
- reads: Reads[Repr]
- ): Reads[T] =
- instance(row => gen.from(reads.read(row)))
-
- private def withRefinedError[T](expr: => T)(row: Row, fieldName: String): T =
- try expr
- catch refineError(row, row.getColumnDefinitions.get(fieldName))
-
}
trait ReadsInstances3 {
diff --git a/src/main/scala/zio/cassandra/session/cql/codec/UdtReads.scala b/src/main/scala/zio/cassandra/session/cql/codec/UdtReads.scala
index aa81f5e..446348f 100644
--- a/src/main/scala/zio/cassandra/session/cql/codec/UdtReads.scala
+++ b/src/main/scala/zio/cassandra/session/cql/codec/UdtReads.scala
@@ -1,9 +1,6 @@
package zio.cassandra.session.cql.codec
import com.datastax.oss.driver.api.core.data.UdtValue
-import shapeless._
-import shapeless.labelled.{ field, FieldType }
-import zio.cassandra.session.cql.codec.UdtReads._
/** Deserializer created specifically for UDT values.
Note that unlike [[zio.cassandra.session.cql.codec.Reads]],
* this reader can be (is) recursive, so each instance of [[zio.cassandra.session.cql.codec.UdtReads]] can be seen as
@@ -29,39 +26,3 @@ object UdtReads extends UdtReadsInstances1 {
}
}
-
-trait UdtReadsInstances1 {
-
- implicit val hNilUdtReads: UdtReads[HNil] = instance(_ => HNil)
-
- implicit def hConsUdtReads[K <: Symbol, H, T <: HList](implicit
- configuration: Configuration,
- hReads: Lazy[CellReads[H]],
- tReads: UdtReads[T],
- fieldNameW: Witness.Aux[K]
- ): UdtReads[FieldType[K, H] :: T] =
- instance { udtValue =>
- val fieldName = configuration.transformFieldNames(fieldNameW.value.name)
- val bytes = udtValue.getBytesUnsafe(fieldName)
- val types = udtValue.getType(fieldName)
-
- val head = withRefinedError(hReads.value.read(bytes, udtValue.protocolVersion(), types))(udtValue, fieldName)
- val tail = tReads.read(udtValue)
-
- field[K](head) :: tail
- }
-
- implicit def genericUdtReads[T, Repr](implicit
- configuration: Configuration,
- gen: LabelledGeneric.Aux[T, Repr],
- reads: Lazy[UdtReads[Repr]]
- ): UdtReads[T] =
- instance(udtValue => gen.from(reads.value.read(udtValue)))
-
- private def withRefinedError[T](expr: => T)(udtValue: UdtValue, fieldName: String): T =
- try expr
- catch {
- case UnexpectedNullValue.NullValueInColumn => throw UnexpectedNullValue.NullValueInUdt(udtValue, fieldName)
- }
-
-}
diff --git a/src/main/scala/zio/cassandra/session/cql/codec/UdtWrites.scala b/src/main/scala/zio/cassandra/session/cql/codec/UdtWrites.scala
index bc8c1a7..37ea25a 100644
--- a/src/main/scala/zio/cassandra/session/cql/codec/UdtWrites.scala
+++ b/src/main/scala/zio/cassandra/session/cql/codec/UdtWrites.scala
@@ -1,9 +1,6 @@
package zio.cassandra.session.cql.codec
import com.datastax.oss.driver.api.core.data.UdtValue
-import shapeless._
-import shapeless.labelled.FieldType
-import zio.cassandra.session.cql.codec.UdtWrites._
/** Serializer created specifically for UDT values.
Note that this reader can be (is) recursive, so each instance of
* [[zio.cassandra.session.cql.codec.UdtWrites]] can be seen as an instance of
@@ -34,30 +31,3 @@ object UdtWrites extends UdtWritesInstances1 {
}
}
-
-trait UdtWritesInstances1 {
-
- implicit val hNilUdtWrites: UdtWrites[HNil] = instance((_, udtValue) => udtValue)
-
- implicit def hConsUdtWrites[K <: Symbol, H, T <: HList](implicit
- configuration: Configuration,
- hWrites: Lazy[CellWrites[H]],
- tWrites: UdtWrites[T],
- fieldNameW: Witness.Aux[K]
- ): UdtWrites[FieldType[K, H] :: T] =
- instance { (t, udtValue) =>
- val fieldName = configuration.transformFieldNames(fieldNameW.value.name)
- val hType = udtValue.getType(fieldName)
- val hBytes = hWrites.value.write(t.head, udtValue.protocolVersion(), hType)
- val valueWithH = udtValue.setBytesUnsafe(fieldName, hBytes)
- tWrites.write(t.tail, valueWithH)
- }
-
- implicit def genericUdtWrites[T, Repr](implicit
- configuration: Configuration,
- gen: LabelledGeneric.Aux[T, Repr],
- writes: Lazy[UdtWrites[Repr]]
- ): UdtWrites[T] =
- instance((t, udtValue) => writes.value.write(gen.to(t), udtValue))
-
-}