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 return type for executeAction #2907

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package io.getquill

import com.datastax.oss.driver.api.core.{CqlSession, CqlSessionBuilder}
import com.datastax.oss.driver.api.core.CqlSession
import com.datastax.oss.driver.api.core.cql.AsyncResultSet
import com.typesafe.config.Config
import io.getquill.context.ExecutionInfo
import io.getquill.context.cassandra.util.FutureConversions._
import io.getquill.monad.ScalaFutureIOMonad
import io.getquill.util.{ContextLogger, LoadConfig}

import scala.jdk.CollectionConverters._
import scala.compat.java8.FutureConverters._

import scala.concurrent.{ExecutionContext, Future}
import scala.jdk.CollectionConverters._

class CassandraAsyncContext[+N <: NamingStrategy](
naming: N,
Expand All @@ -30,7 +29,7 @@ class CassandraAsyncContext[+N <: NamingStrategy](
override type Result[T] = Future[T]
override type RunQueryResult[T] = List[T]
override type RunQuerySingleResult[T] = T
override type RunActionResult = Unit
override type RunActionResult = AsyncResultSet
override type RunBatchActionResult = Unit
override type Runner = Unit

Expand Down Expand Up @@ -58,7 +57,7 @@ class CassandraAsyncContext[+N <: NamingStrategy](
executionContext: ExecutionContext
): Result[RunActionResult] = {
val statement = prepareAsyncAndGetStatement(cql, prepare, this, logger)
statement.flatMap(st => session.executeAsync(st).toCompletableFuture.toScala).map(_ => ())
statement.flatMap(st => session.executeAsync(st).toCompletableFuture.toScala)
}

def executeBatchAction(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.getquill.context.cassandra

import io.getquill._
import com.datastax.oss.driver.api.core.cql.AsyncResultSet
import io.getquill.{EntityQuery, Quoted, Update}
import io.getquill.base.Spec
import io.getquill.context.ExecutionInfo

Expand All @@ -14,10 +15,12 @@ class CassandraContextSpec extends Spec {
"async" in {
import testAsyncDB._
case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int)
val update = quote {
val update: Quoted[Update[TestEntity]] = quote {
query[TestEntity].filter(_.id == lift(1)).update(_.i -> lift(1))
}
await(testAsyncDB.run(update)) mustEqual (())
val result: AsyncResultSet = await(testAsyncDB.run(update))
assert(result != null)

}
"sync" in {
import testSyncDB._
Expand Down
Loading