Skip to content

Commit

Permalink
Merge branch 'master' into update/scala3-library-3.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jczuchnowski authored May 6, 2024
2 parents a9e4912 + 341ee89 commit 6277ce9
Show file tree
Hide file tree
Showing 36 changed files with 239 additions and 139 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v14
- name: Cache scala dependencies
uses: coursier/cache-action@v5
- name: Lint code
Expand All @@ -34,15 +34,15 @@ jobs:
strategy:
fail-fast: false
matrix:
java: ['adopt@1.8', 'adopt@1.11']
scala: ['2.12.18', '2.13.10']
java: ['openjdk@1.11.0', 'openjdk@1.17.0']
scala: ['2.12.19', '2.13.13']
steps:
- name: Checkout current branch
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v14
with:
java-version: ${{ matrix.java }}
- name: Cache scala dependencies
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Checkout current branch
uses: actions/[email protected]
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v13
uses: olafurpg/setup-scala@v14
- name: Cache scala dependencies
uses: coursier/cache-action@v6
- name: Check Document Generation
Expand All @@ -73,7 +73,7 @@ jobs:
with:
fetch-depth: 0
- name: Setup Scala and Java
uses: olafurpg/setup-scala@v10
uses: olafurpg/setup-scala@v14
- name: Cache scala dependencies
uses: coursier/cache-action@v5
- name: Release artifacts
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.11"
version = "3.8.1"
maxColumn = 120
align.preset = most
continuationIndent.defnSite = 2
Expand Down
20 changes: 10 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ addCommandAlias("fmtOnce", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("fmt", "fmtOnce;fmtOnce")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")

val zioVersion = "2.0.15"
val zioSchemaVersion = "0.4.13"
val zioVersion = "2.0.22"
val zioSchemaVersion = "1.1.1"
val testcontainersVersion = "1.18.3"
val testcontainersScalaVersion = "0.40.17"
val logbackVersion = "1.3.8"
val testcontainersScalaVersion = "0.41.3"
val logbackVersion = "1.5.6"

lazy val root = project
.in(file("."))
Expand Down Expand Up @@ -155,7 +155,7 @@ lazy val jdbc = project
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"org.postgresql" % "postgresql" % "42.6.0" % Test,
"org.postgresql" % "postgresql" % "42.7.3" % Test,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test
)
)
Expand All @@ -175,11 +175,11 @@ lazy val jdbc_hikaricp = project
.settings(buildInfoSettings("zio.sql.jdbc-hickaricp"))
.settings(
libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "4.0.3", // 5.x doesn't support Java 1.8
"com.zaxxer" % "HikariCP" % "5.1.0", // 5.x doesn't support Java 1.8
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"org.testcontainers" % "mysql" % testcontainersVersion % Test,
"mysql" % "mysql-connector-java" % "8.0.29" % Test,
"com.mysql" % "mysql-connector-j" % "8.3.0" % Test,
"com.dimafeng" %% "testcontainers-scala-mysql" % testcontainersScalaVersion % Test
)
)
Expand All @@ -198,7 +198,7 @@ lazy val mysql = project
"org.testcontainers" % "database-commons" % testcontainersVersion % Test,
"org.testcontainers" % "jdbc" % testcontainersVersion % Test,
"org.testcontainers" % "mysql" % testcontainersVersion % Test,
"mysql" % "mysql-connector-java" % "8.0.32" % Test,
"com.mysql" % "mysql-connector-j" % "8.3.0" % Test,
"com.dimafeng" %% "testcontainers-scala-mysql" % testcontainersScalaVersion % Test,
"ch.qos.logback" % "logback-classic" % logbackVersion % Test
)
Expand All @@ -217,7 +217,7 @@ lazy val oracle = project
"org.testcontainers" % "database-commons" % testcontainersVersion % Test,
"org.testcontainers" % "oracle-xe" % testcontainersVersion % Test,
"org.testcontainers" % "jdbc" % testcontainersVersion % Test,
"com.oracle.database.jdbc" % "ojdbc8" % "21.10.0.0" % Test,
"com.oracle.database.jdbc" % "ojdbc8" % "23.3.0.23.09" % Test,
"com.dimafeng" %% "testcontainers-scala-oracle-xe" % testcontainersScalaVersion % Test,
"ch.qos.logback" % "logback-classic" % logbackVersion % Test
)
Expand All @@ -236,7 +236,7 @@ lazy val postgres = project
"org.testcontainers" % "database-commons" % testcontainersVersion % Test,
"org.testcontainers" % "postgresql" % testcontainersVersion % Test,
"org.testcontainers" % "jdbc" % testcontainersVersion % Test,
"org.postgresql" % "postgresql" % "42.6.0" % Compile,
"org.postgresql" % "postgresql" % "42.7.3" % Compile,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test,
"ch.qos.logback" % "logback-classic" % logbackVersion % Test
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package zio.sql.expr

import zio.sql.typetag.TypeTag
import zio.sql.Features
import com.github.ghik.silencer.silent

sealed trait Set[F, -A] {
type Value
Expand All @@ -17,7 +16,6 @@ sealed trait Set[F, -A] {
object Set {
type Aux[F, -A, Value0] = Set[F, A] { type Value = Value0 }

@silent
def apply[F: Features.IsSource, A, Value0: TypeTag](
lhs0: Expr[F, A, Value0],
rhs0: Expr[_, A, Value0]
Expand Down
34 changes: 34 additions & 0 deletions core/jvm/src/main/scala-2.13/zio/sql/expr/Set.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package zio.sql.expr

import zio.sql.typetag.TypeTag
import zio.sql.Features

import scala.annotation.nowarn

sealed trait Set[F, -A] {
type Value

def lhs: Expr[F, A, Value]
def rhs: Expr[_, A, Value]

def typeTag: TypeTag[Value]

}

object Set {
type Aux[F, -A, Value0] = Set[F, A] { type Value = Value0 }

@nowarn
def apply[F: Features.IsSource, A, Value0: TypeTag](
lhs0: Expr[F, A, Value0],
rhs0: Expr[_, A, Value0]
): Set.Aux[F, A, Value0] =
new Set[F, A] {
type Value = Value0

def lhs = lhs0
def rhs = rhs0

def typeTag = implicitly[TypeTag[Value]]
}
}
4 changes: 2 additions & 2 deletions core/jvm/src/main/scala/zio/sql/select/Read.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ sealed trait Read[+Out] { self =>
}

def union[Out1 >: Out](that: Read.Aux[ResultType, Out1]): Read.Aux[ResultType, Out1] =
Read.Union[ResultType, Out1](self, that, true)
Read.Union[ResultType, Out1](self, that, distinct = true)

def unionAll[Out1 >: Out](that: Read.Aux[ResultType, Out1]): Read.Aux[ResultType, Out1] =
Read.Union[ResultType, Out1](self, that, false)
Read.Union[ResultType, Out1](self, that, distinct = false)
}

object Read {
Expand Down
5 changes: 3 additions & 2 deletions core/jvm/src/test/scala/zio/sql/ProductSchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ object ProductSchema {
deleted: Boolean
)

implicit val localDateSchema =
implicit val localDateSchema: Schema[LocalDate] =
Schema.primitive[LocalDate](StandardType.LocalDateType)

implicit val productsSchema = DeriveSchema.gen[Product]
implicit val productsSchema: Schema.CaseClass6[String, LocalDate, String, Int, Int, Boolean, Product] =
DeriveSchema.gen[Product]

val productTable = Table.defineTable[Product]

Expand Down
6 changes: 3 additions & 3 deletions core/jvm/src/test/scala/zio/sql/TestBasicSelectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio.test._
import zio.test.Assertion._
import zio.schema._
import zio.test.ZIOSpecDefault
import zio.schema.DeriveSchema
import zio.schema.{ DeriveSchema, Schema }
import java.time.LocalDate
import zio.sql.table._
import zio.sql.select._
Expand All @@ -21,9 +21,9 @@ object TestBasicSelect {

case class Users(user_id: String, dob: LocalDate, first_name: String, last_name: String)

implicit val localDateSchema =
implicit val localDateSchema: Schema[LocalDate] =
Schema.primitive[LocalDate](StandardType.LocalDateType)
implicit val userSchema = DeriveSchema.gen[Users]
implicit val userSchema: Schema.CaseClass4[String, LocalDate, String, String, Users] = DeriveSchema.gen[Users]

val userTable = Table.defineTable[Users]

Expand Down
11 changes: 6 additions & 5 deletions examples/src/main/scala/zio/sql/Examples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package zio.sql
import java.util.UUID
import java.time._
import zio.sql.postgresql.PostgresJdbcModule
import zio.schema.DeriveSchema
import zio.schema.{ DeriveSchema, Schema }
import zio.sql.expr.AggregationDef._
import zio.sql.expr.FunctionDef._
import zio.sql.table._
Expand Down Expand Up @@ -142,7 +142,7 @@ object Examples extends App with PostgresJdbcModule {
firstName: String,
lastName: String
)
implicit val userSchema = DeriveSchema.gen[User]
implicit val userSchema: Schema.CaseClass5[UUID, Int, LocalDate, String, String, User] = DeriveSchema.gen[User]

val dataSchema: User = User(UUID.randomUUID(), 22, LocalDate.ofYearDay(1990, 1), "Ronald", "Russel")

Expand Down Expand Up @@ -173,7 +173,7 @@ object Examples extends App with PostgresJdbcModule {

case class Users(id: UUID, age: Int, dob: LocalDate, firstName: String, lastName: String)

implicit val userSchema = DeriveSchema.gen[Users]
implicit val userSchema: Schema.CaseClass5[UUID, Int, LocalDate, String, String, Users] = DeriveSchema.gen[Users]

val users = Table.defineTable[Users]

Expand All @@ -184,7 +184,7 @@ object Examples extends App with PostgresJdbcModule {

case class Orders(id: java.util.UUID, userId: java.util.UUID, orderDate: LocalDate)

implicit val orderSchema = DeriveSchema.gen[Orders]
implicit val orderSchema: Schema.CaseClass3[UUID, UUID, LocalDate, Orders] = DeriveSchema.gen[Orders]

val orders = Table.defineTable[Orders]

Expand All @@ -194,7 +194,8 @@ object Examples extends App with PostgresJdbcModule {
object OrderDetails {
case class OrderDetail(orderId: java.util.UUID, productId: Int, quantity: Double, unitPrice: Double)

implicit val orderDetailSchema = DeriveSchema.gen[OrderDetail]
implicit val orderDetailSchema: Schema.CaseClass4[java.util.UUID, Int, Double, Double, OrderDetail] =
DeriveSchema.gen[OrderDetail]

val orderDetails = Table.defineTable[OrderDetail]

Expand Down
4 changes: 2 additions & 2 deletions examples/src/main/scala/zio/sql/GroupByExamples.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.sql

import zio.schema.DeriveSchema
import zio.schema.{ DeriveSchema, Schema }
import zio.sql.postgresql.PostgresJdbcModule
import zio.sql.expr.AggregationDef._
import zio.sql.table._
Expand All @@ -9,7 +9,7 @@ object GroupByExamples extends App with PostgresJdbcModule {

case class Product(id: Int, name: String, amount: Int, price: Double)

implicit val productSchema = DeriveSchema.gen[Product]
implicit val productSchema: Schema.CaseClass4[Int, String, Int, Double, Product] = DeriveSchema.gen[Product]

val productTable = Table.defineTable[Product]

Expand Down
5 changes: 3 additions & 2 deletions examples/src/main/scala/zio/sql/LiveExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.time.LocalDate
import java.util.Properties

import zio._
import zio.schema.DeriveSchema
import zio.schema.{ DeriveSchema, Schema }
import zio.sql.{ ConnectionPool, ConnectionPoolConfig }
import zio.sql.postgresql.PostgresJdbcModule
import zio.sql.table._
Expand Down Expand Up @@ -71,7 +71,8 @@ object LiveExample extends ZIOAppDefault with PostgresJdbcModule {

case class Customer(id: UUID, age: Int, dob: LocalDate, firstName: String, lastName: String)

implicit val customerSchema = DeriveSchema.gen[Customer]
implicit val customerSchema: Schema.CaseClass5[UUID, Int, LocalDate, String, String, Customer] =
DeriveSchema.gen[Customer]

val customers = Table.defineTable[Customer]("customers")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import zio._
final case class MySqlConfig(username: String, password: String, url: String)
object MySqlTestContainer {

def mysql(imageName: String = "mysql"): ZIO[Scope, Throwable, MySQLContainer] =
def mysql(imageName: String = "mysql:8.2.0"): ZIO[Scope, Throwable, MySQLContainer] =
ZIO.acquireRelease {
ZIO.attemptBlocking {
val c = new MySQLContainer(
Expand Down
2 changes: 1 addition & 1 deletion jdbc/src/main/scala/zio/sql/JdbcInternalModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ trait JdbcInternalModule { self: Jdbc =>
case TDialectSpecific(t) => t.decode(columnIndex, resultSet)
case t @ Nullable() =>
val _ = nonNull
extractColumn(columnIndex, resultSet, t.typeTag, false).map(Option(_))
extractColumn(columnIndex, resultSet, t.typeTag, nonNull = false).map(Option(_))
case TNone => Right(None)
}
}
Expand Down
2 changes: 1 addition & 1 deletion mysql/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.3
sbt.version=1.9.9
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ object CommonFunctionDefSpec extends MysqlRunnableSpec with Jdbc {

case class Customers(id: UUID, dob: LocalDate, first_name: String, last_name: String, verified: Boolean)

implicit val customerSchema = DeriveSchema.gen[Customers]
implicit val customerSchema: Schema.CaseClass5[UUID, LocalDate, String, String, Boolean, Customers] =
DeriveSchema.gen[Customers]

val customers = Table.defineTable[Customers]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ object CustomFunctionDefSpec extends MysqlRunnableSpec with Jdbc {

case class Customers(id: UUID, dob: LocalDate, first_name: String, last_name: String, verified: Boolean)

implicit val customerSchema = DeriveSchema.gen[Customers]
implicit val customerSchema: Schema.CaseClass5[UUID, LocalDate, String, String, Boolean, Customers] =
DeriveSchema.gen[Customers]

val customers = Table.defineTable[Customers]

Expand Down
5 changes: 3 additions & 2 deletions mysql/src/test/scala/zio/sql/mysql/DeleteSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import zio.test._

import java.util.UUID
import java.time.LocalDate
import zio.schema.DeriveSchema
import zio.schema.{ DeriveSchema, Schema }
import zio.test.TestAspect.sequential
import zio.sql.table._

object DeleteSpec extends MysqlRunnableSpec {

case class Customers(id: UUID, dob: LocalDate, first_name: String, lastName: String, verified: Boolean)

implicit val customerSchema = DeriveSchema.gen[Customers]
implicit val customerSchema: Schema.CaseClass5[UUID, LocalDate, String, String, Boolean, Customers] =
DeriveSchema.gen[Customers]

val customers = Table.defineTable[Customers]

Expand Down
Loading

0 comments on commit 6277ce9

Please sign in to comment.