Skip to content

Commit 14eeb95

Browse files
committed
Merge branch 'master' of https://github.com/zio/zio-query into zio2
2 parents 07833ce + 93ffd40 commit 14eeb95

File tree

5 files changed

+121
-11
lines changed

5 files changed

+121
-11
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
timeout-minutes: 30
1919
steps:
2020
- name: Checkout current branch
21-
uses: actions/checkout@v2.3.4
21+
uses: actions/checkout@v2.4.0
2222
with:
2323
fetch-depth: 0
2424
- name: Setup Scala and Java
@@ -33,7 +33,7 @@ jobs:
3333
timeout-minutes: 60
3434
steps:
3535
- name: Checkout current branch
36-
uses: actions/checkout@v2.3.4
36+
uses: actions/checkout@v2.4.0
3737
- name: Setup Scala and Java
3838
uses: olafurpg/setup-scala@v13
3939
- name: Cache scala dependencies
@@ -51,7 +51,7 @@ jobs:
5151
scala: ['2.11.12', '2.12.14', '2.13.6', '3.1.0']
5252
steps:
5353
- name: Checkout current branch
54-
uses: actions/checkout@v2.3.4
54+
uses: actions/checkout@v2.4.0
5555
with:
5656
fetch-depth: 0
5757
- name: Setup Scala and Java
@@ -77,7 +77,7 @@ jobs:
7777
if: github.event_name != 'pull_request'
7878
steps:
7979
- name: Checkout current branch
80-
uses: actions/checkout@v2.3.4
80+
uses: actions/checkout@v2.4.0
8181
with:
8282
fetch-depth: 0
8383
- name: Setup Scala and Java

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.17.6
1+
16.13.1

project/BuildHelper.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ object BuildHelper {
192192
Seq("com.github.ghik" % s"silencer-lib_$Scala213" % "1.7.5" % Provided)
193193
else
194194
Seq(
195-
"com.github.ghik" % "silencer-lib" % "1.7.5" % Provided cross CrossVersion.full,
196-
compilerPlugin("com.github.ghik" % "silencer-plugin" % "1.7.5" cross CrossVersion.full),
195+
"com.github.ghik" % "silencer-lib" % "1.7.7" % Provided cross CrossVersion.full,
196+
compilerPlugin("com.github.ghik" % "silencer-plugin" % "1.7.7" cross CrossVersion.full),
197197
compilerPlugin(scalafixSemanticdb)
198198
)
199199
},

project/plugins.sbt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0")
1+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
22
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
33
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
44
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
55
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
6-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2")
6+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.2")
77
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.23")
8-
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.8")
8+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.11")
99
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
1010
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
1111
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16")
1212
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
13-
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.30")
13+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.31")
1414

1515
libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.3"

zio-query/shared/src/main/scala/zio/query/ZQuery.scala

+110
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,32 @@ final class ZQuery[-R, +E, +A] private (private val step: ZIO[R, Nothing, Result
545545
}
546546
)
547547

548+
/**
549+
* Extracts the optional value or succeeds with the given 'default' value.
550+
*/
551+
def someOrElse[B](default: => B)(implicit ev: A <:< Option[B], trace: ZTraceElement): ZQuery[R, E, B] =
552+
self.map(_.getOrElse(default))
553+
554+
/**
555+
* Extracts the optional value or executes the given 'default' query.
556+
*/
557+
@deprecated("use someOrElseZIO", "0.3.0")
558+
final def someOrElseM[B, R1 <: R, E1 >: E](
559+
default: ZQuery[R1, E1, B]
560+
)(implicit ev: A <:< Option[B], trace: ZTraceElement): ZQuery[R1, E1, B] =
561+
someOrElseZIO(default)
562+
563+
/**
564+
* Extracts the optional value or executes the given 'default' query.
565+
*/
566+
final def someOrElseZIO[B, R1 <: R, E1 >: E](
567+
default: ZQuery[R1, E1, B]
568+
)(implicit ev: A <:< Option[B], trace: ZTraceElement): ZQuery[R1, E1, B] =
569+
self.flatMap(ev(_) match {
570+
case Some(value) => ZQuery.succeed(value)
571+
case None => default
572+
})
573+
548574
/**
549575
* Extracts the optional value or fails with the given error `e`.
550576
*/
@@ -883,6 +909,40 @@ object ZQuery {
883909
): ZQuery[R, E, Collection[A]] =
884910
foreach(as)(identity)
885911

912+
/**
913+
* Collects a collection of queries into a query returning a collection of
914+
* their results. Requests will be executed sequentially and will be
915+
* pipelined.
916+
*/
917+
def collectAll[R, E, A](as: Set[ZQuery[R, E, A]])(implicit trace: ZTraceElement): ZQuery[R, E, Set[A]] =
918+
foreach(as)(identity)
919+
920+
/**
921+
* Collects a collection of queries into a query returning a collection of
922+
* their results. Requests will be executed sequentially and will be
923+
* pipelined.
924+
*/
925+
def collectAll[R, E, A: ClassTag](as: Array[ZQuery[R, E, A]])(implicit trace: ZTraceElement): ZQuery[R, E, Array[A]] =
926+
foreach(as)(identity)
927+
928+
/**
929+
* Collects a collection of queries into a query returning a collection of
930+
* their results. Requests will be executed sequentially and will be
931+
* pipelined.
932+
*/
933+
def collectAll[R, E, A](as: Option[ZQuery[R, E, A]])(implicit trace: ZTraceElement): ZQuery[R, E, Option[A]] =
934+
foreach(as)(identity)
935+
936+
/**
937+
* Collects a collection of queries into a query returning a collection of
938+
* their results. Requests will be executed sequentially and will be
939+
* pipelined.
940+
*/
941+
def collectAll[R, E, A](as: NonEmptyChunk[ZQuery[R, E, A]])(implicit
942+
trace: ZTraceElement
943+
): ZQuery[R, E, NonEmptyChunk[A]] =
944+
foreach(as)(identity)
945+
886946
/**
887947
* Collects a collection of queries into a query returning a collection of
888948
* their results, batching requests to data sources.
@@ -895,6 +955,31 @@ object ZQuery {
895955
): ZQuery[R, E, Collection[A]] =
896956
foreachBatched(as)(identity)
897957

958+
/**
959+
* Collects a collection of queries into a query returning a collection of
960+
* their results, batching requests to data sources.
961+
*/
962+
def collectAllBatched[R, E, A](as: Set[ZQuery[R, E, A]])(implicit trace: ZTraceElement): ZQuery[R, E, Set[A]] =
963+
foreachBatched(as)(identity)
964+
965+
/**
966+
* Collects a collection of queries into a query returning a collection of
967+
* their results, batching requests to data sources.
968+
*/
969+
def collectAllBatched[R, E, A: ClassTag](as: Array[ZQuery[R, E, A]])(implicit
970+
trace: ZTraceElement
971+
): ZQuery[R, E, Array[A]] =
972+
foreachBatched(as)(identity)
973+
974+
/**
975+
* Collects a collection of queries into a query returning a collection of
976+
* their results, batching requests to data sources.
977+
*/
978+
def collectAllBatched[R, E, A](as: NonEmptyChunk[ZQuery[R, E, A]])(implicit
979+
trace: ZTraceElement
980+
): ZQuery[R, E, NonEmptyChunk[A]] =
981+
foreachBatched(as)(identity)
982+
898983
/**
899984
* Collects a collection of queries into a query returning a collection of
900985
* their results. Requests will be executed in parallel and will be batched.
@@ -907,6 +992,31 @@ object ZQuery {
907992
): ZQuery[R, E, Collection[A]] =
908993
foreachPar(as)(identity)
909994

995+
/**
996+
* Collects a collection of queries into a query returning a collection of
997+
* their results. Requests will be executed in parallel and will be batched.
998+
*/
999+
def collectAllPar[R, E, A](as: Set[ZQuery[R, E, A]])(implicit trace: ZTraceElement): ZQuery[R, E, Set[A]] =
1000+
foreachPar(as)(identity)
1001+
1002+
/**
1003+
* Collects a collection of queries into a query returning a collection of
1004+
* their results. Requests will be executed in parallel and will be batched.
1005+
*/
1006+
def collectAllPar[R, E, A: ClassTag](as: Array[ZQuery[R, E, A]])(implicit
1007+
trace: ZTraceElement
1008+
): ZQuery[R, E, Array[A]] =
1009+
foreachPar(as)(identity)
1010+
1011+
/**
1012+
* Collects a collection of queries into a query returning a collection of
1013+
* their results. Requests will be executed in parallel and will be batched.
1014+
*/
1015+
def collectAllPar[R, E, A](as: NonEmptyChunk[ZQuery[R, E, A]])(implicit
1016+
trace: ZTraceElement
1017+
): ZQuery[R, E, NonEmptyChunk[A]] =
1018+
foreachPar(as)(identity)
1019+
9101020
/**
9111021
* Constructs a query that dies with the specified error.
9121022
*/

0 commit comments

Comments
 (0)