Skip to content

Commit

Permalink
Merge pull request #1523 from jatcwang/merge_master_into_1.x
Browse files Browse the repository at this point in the history
Merge master into 1.x
  • Loading branch information
tpolecat authored Aug 30, 2021
2 parents f198363 + 980169f commit d9c2ed4
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 31 deletions.
49 changes: 24 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import sbt.dsl.LinterLevel.Ignore
// Library versions all in one place, for convenience and sanity.
lazy val catsVersion = "2.6.1"
lazy val catsEffectVersion = "3.1.1"
lazy val circeVersion = settingKey[String]("Circe version.")
lazy val circeVersion = "0.14.1"
lazy val fs2Version = "3.0.3"
lazy val h2Version = "1.4.200"
lazy val hikariVersion = "4.0.3" // N.B. Hikari v4 introduces a breaking change via slf4j v2
lazy val kindProjectorVersion = "0.11.2"
lazy val monixVersion = "3.4.0"
lazy val quillVersion = "3.7.1"
lazy val postGisVersion = "2.5.0"
lazy val postgresVersion = "42.2.20"
lazy val refinedVersion = "0.9.25"
lazy val quillVersion = settingKey[String]("Quill version.")
lazy val postGisVersion = "2.5.1"
lazy val postgresVersion = "42.2.23"
lazy val refinedVersion = "0.9.27"
lazy val scalaCheckVersion = "1.15.4"
lazy val scalatestVersion = "3.2.9"
lazy val munitVersion = "0.7.26"
lazy val munitVersion = "0.7.28"
lazy val shapelessVersion = "2.3.7"
lazy val silencerVersion = "1.7.1"
lazy val specs2Version = "4.11.0"
lazy val specs2Version = "4.12.3"
lazy val scala212Version = "2.12.12"
lazy val scala213Version = "2.13.5"
lazy val scala30Version = "3.0.0"
lazy val slf4jVersion = "1.7.30"
lazy val scala30Version = "3.0.1"
lazy val slf4jVersion = "1.7.32"

// These are releases to ignore during MiMa checks
lazy val botchedReleases = Set("0.8.0", "0.8.1")
Expand Down Expand Up @@ -81,7 +81,7 @@ lazy val commonSettings =
// MUnit
libraryDependencies ++= Seq(
"org.typelevel" %% "scalacheck-effect-munit" % "1.0.2" % Test,
"org.typelevel" %% "munit-cats-effect-3" % "1.0.3" % Test,
"org.typelevel" %% "munit-cats-effect-3" % "1.0.5" % Test,
),
testFrameworks += new TestFramework("munit.Framework"),

Expand Down Expand Up @@ -121,10 +121,10 @@ lazy val commonSettings =
old
},

circeVersion := {
quillVersion := {
scalaVersion.value match {
case `scala30Version` => "0.14.0-M7"
case _ => "0.13.0"
case `scala30Version` => "3.7.2.Beta.1.4"
case _ => "3.7.2"
}
}

Expand Down Expand Up @@ -282,8 +282,8 @@ lazy val postgres = project
name := "doobie-postgres",
description := "Postgres support for doobie.",
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-io" % fs2Version,
"org.postgresql" % "postgresql" % postgresVersion,
"co.fs2" %% "fs2-io" % fs2Version,
"org.postgresql" % "postgresql" % postgresVersion,
postgisDep % "provided"
),
scalacOptions -= "-Xfatal-warnings", // we need to do deprecated things
Expand Down Expand Up @@ -332,8 +332,8 @@ lazy val `postgres-circe` = project
name := "doobie-postgres-circe",
description := "Postgres circe support for doobie.",
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion.value,
"io.circe" %% "circe-parser" % circeVersion.value
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion
)
)

Expand Down Expand Up @@ -397,7 +397,6 @@ lazy val scalatest = project
"com.h2database" % "h2" % h2Version % "test"
)
)
.settings(noDottySettings)

lazy val munit = project
.in(file("modules/munit"))
Expand All @@ -410,8 +409,8 @@ lazy val munit = project
description := "MUnit support for doobie.",
testFrameworks += new TestFramework("munit.Framework"),
libraryDependencies ++= Seq(
"org.scalameta" %% "munit" % munitVersion,
"com.h2database" % "h2" % h2Version % "test"
"org.scalameta" %% "munit" % munitVersion,
"com.h2database" % "h2" % h2Version % "test"
)
)

Expand All @@ -436,9 +435,9 @@ lazy val docs = project
scalacOptions := Nil,

libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion.value,
"io.circe" %% "circe-generic" % circeVersion.value,
"io.circe" %% "circe-parser" % circeVersion.value,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"io.monix" %% "monix-eval" % monixVersion,
),
fork in Test := true,
Expand All @@ -463,7 +462,7 @@ lazy val docs = project
"shapelessVersion" -> shapelessVersion,
"h2Version" -> h2Version,
"postgresVersion" -> postgresVersion,
"quillVersion" -> quillVersion,
"quillVersion" -> quillVersion.value,
"scalaVersion" -> scalaVersion.value,
),

Expand Down Expand Up @@ -501,7 +500,7 @@ lazy val quill = project
name := "doobie-quill",
description := "Quill support for doobie.",
libraryDependencies ++= Seq(
"io.getquill" %% "quill-jdbc" % quillVersion,
"io.getquill" %% "quill-jdbc" % quillVersion.value,
"org.slf4j" % "slf4j-simple" % slf4jVersion % "test"
),
)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/main/scala/doobie/util/read.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class Read[A](
new Read(gets, (rs, n) => f(unsafeGet(rs, n)))

def ap[B](ff: Read[A => B]): Read[B] =
new Read(gets ++ ff.gets, (rs, n) => ff.unsafeGet(rs, n)(unsafeGet(rs, n + ff.length)))
new Read(ff.gets ++ gets, (rs, n) => ff.unsafeGet(rs, n)(unsafeGet(rs, n + ff.length)))

def get(n: Int): ResultSetIO[A] =
FRS.raw(unsafeGet(_, n))
Expand Down
22 changes: 22 additions & 0 deletions modules/core/src/test/scala/doobie/util/ReadSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
assertEquals(util.Read[LenStr2].length, 1)
}

test(".product should product the correct ordering of gets") {
import cats.syntax.all._

val readInt = util.Read[Int]
val readString = util.Read[String]

val p = readInt.product(readString)

assertEquals(p.gets, (readInt.gets ++ readString.gets))
}

test("Read should select correct columns when combined with `ap`") {
import cats.syntax.all._
import doobie.implicits._
Expand All @@ -73,4 +84,15 @@ class ReadSuite extends munit.FunSuite with ReadSuitePlatform {
assertEquals(o, List((1, 2, 3, 4, 5)))
}

test("Read should select correct columns when combined with `product`") {
import cats.syntax.all._
import doobie.implicits._
val r = util.Read[Int].product(util.Read[Int].product(util.Read[Int]))

val q = sql"SELECT 1, 2, 3".query(r).to[List]
val o = q.transact(xa).unsafeRunSync()

assertEquals(o, List((1, (2, 3))))
}

}
2 changes: 2 additions & 0 deletions modules/docs/src/main/mdoc/docs/12-Custom-Mappings.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Instances are provided for the following Scala types:
- `Instant`, `LocalDate`, `LocalTime`, `LocalDateTime`, `OffsetTime`, `OffsetDateTime` and `ZonedDateTime` from the `java.time` package; and
- single-element case classes wrapping one of the above types.

The `java.time` instances may require a separate import , dependent on your Database Driver . See the [doobie-faq](https://tpolecat.github.io/doobie/docs/18-FAQ.html#how-do-i-use-java-time-types-with-doobie-) for details

The above cases are defined by the JDBC specification. See later chapters on vendor-specific additions, which provide mappings for some non-standard types such as `UUID`s and network addresses.

#### Deriving Get and Put from Existing Instances
Expand Down
1 change: 1 addition & 0 deletions modules/docs/src/main/mdoc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Don't see yours? [You can add it in a PR!](https://github.com/tpolecat/doobie/ed
- [Doomoolmori](https://doomoolmori.com)
- [eBay Inc.](https://www.ebay.com)
- [Evolution](https://www.evolution.com/)
- [FinDynamic](https://www.findynamic.com/en)
- [HIFI](https://hi.fi)
- [ITV](https://www.itv.com/)
- [lences.io](https://lenses.io)
Expand Down
24 changes: 24 additions & 0 deletions modules/munit/src/test/scala/doobie/munit/CheckerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package doobie.munit

import cats.effect.IO
import doobie.syntax.string._
import doobie.util.Read
import doobie.util.transactor.Transactor
import munit._
import scala.concurrent.ExecutionContext
Expand All @@ -29,6 +30,29 @@ trait CheckerChecks[M[_]] extends FunSuite with Checker[M] {

test ("trivial case-class"){ check(sql"select 1".query[Foo[cats.Id]]) }

test("Read should select correct columns when combined with `product`") {
import cats.syntax.all._
import doobie.implicits._

val ri = Read[Int]
val rs = Read[String]

// tupled use product under the hood
val combined: Read[(Int, String)] = (ri, rs).tupled

check(sql"SELECT 1, '2'".query(combined))
}

test("Read should select correct columns for checking when combined with `ap`") {
val readInt = Read[(Int, Int)]
val readIntToInt: Read[Tuple2[Int, Int] => String] =
Read[(String, String)].map(i => k => s"$i,$k")

val combined: Read[String] = readInt.ap(readIntToInt)

check(sql"SELECT '1', '2', 3, 4".query(combined))
}

}

class IOCheckerCheck extends CheckerChecks[IO] with IOChecker {
Expand Down
2 changes: 1 addition & 1 deletion project/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Required for the freegen definition for postgres in ../build.sbt
val postgresVersion = "42.2.20"
val postgresVersion = "42.2.23"
libraryDependencies += "org.postgresql" % "postgresql" % postgresVersion
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.9.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.2")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.18")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.22")
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.5")

0 comments on commit d9c2ed4

Please sign in to comment.