Skip to content

Commit

Permalink
Merge branch 'master' into fix318
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii authored Mar 14, 2024
2 parents 55e34f2 + 6a0fa9e commit c69afa5
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
steps:
- uses: actions/[email protected]
- name: Setup Java and Scala
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: temurin
java-version: '17'
Expand All @@ -48,7 +48,7 @@ jobs:
steps:
- uses: actions/[email protected]
- name: Setup Java and Scala
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: temurin
java-version: '17'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
update_release_draft:
runs-on: ubuntu-20.04
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/scala-steward.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Scala Steward
steps:
- name: Scala Steward
uses: scala-steward-org/scala-steward-action@v2.61.0
uses: scala-steward-org/scala-steward-action@v2.65.0
with:
github-app-id: ${{ secrets.SCALA_STEWARD_GITHUB_APP_ID }}
github-app-installation-id: ${{ secrets.SCALA_STEWARD_GITHUB_APP_INSTALLATION_ID }}
Expand Down
22 changes: 10 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ lazy val `quill-sql` =
// errors will happen. Even if the pprint classes are actually there
"io.suzaku" %% "boopickle" % "1.4.0",
"com.lihaoyi" %% "pprint" % "0.8.1",
"ch.qos.logback" % "logback-classic" % "1.4.11" % Test,
"ch.qos.logback" % "logback-classic" % "1.5.3" % Test,
"io.getquill" %% "quill-engine" % zioQuillVersion,
"dev.zio" %% "zio" % "2.0.19",
("io.getquill" %% "quill-util" % zioQuillVersion)
Expand Down Expand Up @@ -170,16 +170,14 @@ lazy val `quill-caliban` =
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.ghostdogpr" %% "caliban" % "2.4.3",
"com.github.ghostdogpr" %% "caliban-zio-http" % "2.4.3",
"com.github.ghostdogpr" %% "caliban-quick" % "2.5.1",
// Adding this to main dependencies would force users to use logback-classic for SLF4j unless the specifically remove it
// seems to be safer to just exclude & add a commented about need for a SLF4j implementation in Docs.
"ch.qos.logback" % "logback-classic" % "1.4.11" % Test,
"ch.qos.logback" % "logback-classic" % "1.5.3" % Test,
// Don't want to make this dependant on zio-test for the testing code so importing this here separately
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalatest" %% "scalatest-mustmatchers" % scalatestVersion % Test,
"org.postgresql" % "postgresql" % "42.7.0" % Test,
"com.softwaremill.sttp.tapir" %% "tapir-json-zio" % "1.8.3" % Test
"org.postgresql" % "postgresql" % "42.7.2" % Test,
)
)
.dependsOn(`quill-jdbc-zio` % "compile->compile")
Expand All @@ -190,8 +188,8 @@ lazy val `quill-zio` =
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "2.0.19",
"dev.zio" %% "zio-streams" % "2.0.19"
"dev.zio" %% "zio" % "2.0.21",
"dev.zio" %% "zio-streams" % "2.0.21"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
Expand All @@ -203,7 +201,7 @@ lazy val `quill-jdbc-zio` =
.settings(
libraryDependencies ++= Seq(
// Needed for PGObject in JsonExtensions but not necessary if user is not using postgres
"org.postgresql" % "postgresql" % "42.7.0" % "provided",
"org.postgresql" % "postgresql" % "42.7.2" % "provided",
"dev.zio" %% "zio-json" % "0.6.2"
),
Test / runMain / fork := true,
Expand Down Expand Up @@ -241,8 +239,8 @@ lazy val `quill-cassandra-zio` =
Test / fork := true,
libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % "4.17.0",
"dev.zio" %% "zio" % "2.0.19",
"dev.zio" %% "zio-streams" % "2.0.19"
"dev.zio" %% "zio" % "2.0.21",
"dev.zio" %% "zio-streams" % "2.0.21"
)
)
.dependsOn(`quill-cassandra` % "compile->compile;test->test")
Expand Down Expand Up @@ -270,7 +268,7 @@ lazy val jdbcTestingLibraries = Seq(
"com.mysql" % "mysql-connector-j" % "8.2.0" % Test,
"com.h2database" % "h2" % "2.2.224" % Test,
// In 42.2.18 error happens: PSQLException: conversion to class java.time.OffsetTime from timetz not supported
"org.postgresql" % "postgresql" % "42.7.0" % Test,
"org.postgresql" % "postgresql" % "42.7.2" % Test,
"org.xerial" % "sqlite-jdbc" % "3.42.0.1" % Test,
// In 7.1.1-jre8-preview error happens: The conversion to class java.time.OffsetDateTime is unsupported.
"com.microsoft.sqlserver" % "mssql-jdbc" % "7.4.1.jre11" % Test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package io.getquill

import caliban.graphQL
import caliban.schema.Annotations.GQLDescription
import caliban.{RootResolver, ZHttpAdapter}
import caliban._
import caliban.quick._
import zio.http._
import zio.http.Server
import zio.{ExitCode, ZIO}
Expand All @@ -22,10 +23,8 @@ import io.getquill.CalibanIntegration._
import io.getquill.util.ContextLogger
import io.getquill
import io.getquill.FlatSchema._
import caliban.interop.tapir.HttpInterpreter
import caliban.schema.Schema.auto._
import caliban.schema.ArgBuilder.auto._
import sttp.tapir.json.zio.*
import zio.json.JsonEncoder
import zio.json.JsonDecoder
import caliban._
Expand Down Expand Up @@ -96,20 +95,19 @@ object CalibanExample extends zio.ZIOAppDefault {
})
)
)
).interpreter
)

given JsonEncoder[GraphQLRequest] = GraphQLRequest.zioJsonEncoder

given JsonDecoder[GraphQLRequest] = GraphQLRequest.zioJsonDecoder

val myApp = for {
_ <- Dao.resetDatabase()
interpreter <- endpoints
_ <- Server.serve(Http.collectHttp[Request] { case _ -> Root / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
}
).provide(Server.defaultWithPort(8088))
.forever
- <- endpoints.runServer(
port = 8088,
apiPath = "/api/graphql",
graphiqlPath = Some("/graphiql")
)
} yield ()

override def run =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package io.getquill

import caliban.graphQL
import caliban.schema.Annotations.GQLDescription
import caliban.{RootResolver, ZHttpAdapter}
import zio.http.*
import zio.http.Server
import caliban.RootResolver
import zio.{ExitCode, ZIO}
import io.getquill.*
import io.getquill.context.qzio.ImplicitSyntax.*
Expand All @@ -23,12 +21,10 @@ import io.getquill.util.ContextLogger
import io.getquill.NestedSchema.*
import caliban.schema.Schema.auto.*
import caliban.schema.ArgBuilder.auto.*
import zio.http.Server
import caliban.interop.tapir.HttpInterpreter
import sttp.tapir.json.zio.*
import zio.json.JsonEncoder
import zio.json.JsonDecoder
import caliban._
import caliban.quick._


object DaoNested {
Expand Down Expand Up @@ -99,17 +95,15 @@ object CalibanExampleNested extends zio.ZIOAppDefault {
})
)
)
).interpreter
)

val myApp = for {
_ <- DaoNested.resetDatabase()
interpreter <- endpoints
_ <- Server.serve(
Http.collectHttp[Request] { case _ -> Root / "api" / "graphql" =>
ZHttpAdapter.makeHttpService(HttpInterpreter(interpreter))
}
).provide(Server.defaultWithPort(8088))
.forever
_ <- endpoints.runServer(
port = 8088,
apiPath = "/api/graphql",
graphiqlPath = Some("/graphiql")
)
} yield ()

override def run =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class OnConflictJdbcSpec extends OnConflictSpec {
ctx.run(testQuery2) mustEqual res2
ctx.run(testQuery3) mustEqual res3
}
"BATCH INSERT IGNORE" in {
import `onConflictIgnore`._
ctx.run(batchInsert)
ctx.run(testQuery3) mustEqual res3
}

"ON DUPLICATE KEY UPDATE i=i " in {
import `onConflictIgnore(_.i)`._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class OnConflictJdbcSpec extends OnConflictSpec {
ctx.run(testQuery3) mustEqual res3
}

"BATCH ON CONFLICT DO NOTHING" in {
import `onConflictIgnore`._
ctx.run(batchInsert)
ctx.run(testQuery3) mustEqual res3
}

"ON CONFLICT (i) DO NOTHING" in {
import `onConflictIgnore(_.i)`._
ctx.run(testQuery1) mustEqual res1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class OnConflictJdbcSpec extends OnConflictSpec {
ctx.run(testQuery3) mustEqual res3
}

"BATCH ON CONFLICT DO NOTHING" in {
import `onConflictIgnore`._
ctx.run(batchInsert)
ctx.run(testQuery3) mustEqual res3
}

"ON CONFLICT (i) DO NOTHING" in {
import `onConflictIgnore(_.i)`._
ctx.run(testQuery1) mustEqual res1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ private[getquill] enum BatchActionType {
* Otherwise SQLServer will not let you insert the row because `IDENTITY_INSERT` will be off.
*/
object PossiblyInfixAction {
private def isTailAction(actionAst: Ast) =
actionAst.isInstanceOf[ast.Insert] || actionAst.isInstanceOf[ast.Update] || actionAst.isInstanceOf[ast.Delete]
private def isTailAction(actionAst: Ast) = {
actionAst.isInstanceOf[ast.Insert] || actionAst.isInstanceOf[ast.Update] || actionAst.isInstanceOf[ast.Delete] ||
actionAst.isInstanceOf[ast.OnConflict]
}

private def hasOneAction(params: List[Ast]) =
params.filter(isTailAction(_)).length == 1
def unapply(actionAst: ast.Ast): Option[Ast] =
Expand All @@ -104,6 +107,7 @@ private[getquill] object ActionEntity {
case PossiblyInfixAction(ast.Insert(entity, _)) => Some(BatchActionType.Insert)
case PossiblyInfixAction(ast.Update(entity, assignments)) => Some(BatchActionType.Update)
case PossiblyInfixAction(ast.Delete(entity)) => Some(BatchActionType.Delete)
case PossiblyInfixAction(ast.OnConflict(_,_,_)) => Some(BatchActionType.Insert)
case _ => None
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ trait OnConflictSpec extends Spec {
qr1.filter(_.i == 1)
}
val res3 = List(TestEntity("", 1, 0, None, true))

inline def batchInsert = quote {
liftQuery(List(
TestEntity("", 1, 0, None, true),
TestEntity("", 1, 0, None, true),
TestEntity("", 1, 0, None, true),
)).foreach( v => qr1.insertValue(v).onConflictIgnore)
}
}

object `onConflictIgnore(_.i)` {
Expand Down

0 comments on commit c69afa5

Please sign in to comment.