Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Scala 3 support #24

Merged
merged 1 commit into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- name: Validate Scaladoc
run: sbt doc
- name: Run tests
run: sbt test +IntegrationTest/test
run: sbt +test +IntegrationTest/test
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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", "[email protected]", url("https://gitlab.com/jsfwa")),
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions src/it/scala/zio/cassandra/session/SessionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
14 changes: 14 additions & 0 deletions src/it/scala/zio/cassandra/session/cql/CqlSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,27 @@ 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)]
for {
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]
Expand Down
18 changes: 18 additions & 0 deletions src/it/scala/zio/cassandra/session/cql/codec/ReadsSpec.scala
Original file line number Diff line number Diff line change
@@ -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._
Expand All @@ -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 =
Expand Down Expand Up @@ -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))
}
)

Expand Down
Loading