Skip to content

Commit

Permalink
Merge branch 'master' into update/scala-library-2.12.19
Browse files Browse the repository at this point in the history
  • Loading branch information
jczuchnowski committed May 6, 2024
2 parents 32036b1 + a2a8690 commit 9da650a
Show file tree
Hide file tree
Showing 32 changed files with 221 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fail-fast: false
matrix:
java: ['openjdk@1.11.0', 'openjdk@1.17.0']
scala: ['2.12.19', '2.13.10']
scala: ['2.12.19', '2.13.13']
steps:
- name: Checkout current branch
uses: actions/checkout@v2.3.4
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.17"
version = "3.8.1"
maxColumn = 120
align.preset = most
continuationIndent.defnSite = 2
Expand Down
16 changes: 8 additions & 8 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.21"
val zioSchemaVersion = "0.4.17"
val zioVersion = "2.0.22"
val zioSchemaVersion = "1.1.1"
val testcontainersVersion = "1.18.3"
val testcontainersScalaVersion = "0.41.3"
val logbackVersion = "1.4.8"
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.7.2" % Test,
"org.postgresql" % "postgresql" % "42.7.3" % Test,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test
)
)
Expand All @@ -179,7 +179,7 @@ lazy val jdbc_hikaricp = project
"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.33" % 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" % "23.2.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.7.2" % 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
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
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
18 changes: 11 additions & 7 deletions mysql/src/test/scala/zio/sql/mysql/MysqlModuleSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,34 @@ object MysqlModuleSpec extends MysqlRunnableSpec {

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]

val (customerId, dob, fName, lName, verified) = customers.columns

case class Orders(id: UUID, customer_id: UUID, order_date: LocalDate, deleted_at: Option[LocalDateTime])

implicit val orderSchema = DeriveSchema.gen[Orders]
implicit val orderSchema: Schema.CaseClass4[UUID, UUID, LocalDate, Option[LocalDateTime], Orders] =
DeriveSchema.gen[Orders]

val orders = Table.defineTable[Orders]

val (orderId, fkCustomerId, orderDate, deletedAt) = orders.columns

case class ProductPrice(productId: UUID, effective: LocalDate, price: BigDecimal)
implicit val productPriceSchema = DeriveSchema.gen[ProductPrice]
implicit val productPriceSchema: Schema.CaseClass3[UUID, LocalDate, BigDecimal, ProductPrice] =
DeriveSchema.gen[ProductPrice]

val productPrices = Table.defineTableSmart[ProductPrice]

val (productPricesOrderId, effectiveDate, productPrice) = productPrices.columns

case class OrderDetails(orderId: UUID, productId: UUID, quantity: Int, unitPrice: BigDecimal)

implicit val orderDetailsSchema = DeriveSchema.gen[OrderDetails]
implicit val orderDetailsSchema: Schema.CaseClass4[UUID, UUID, Int, BigDecimal, OrderDetails] =
DeriveSchema.gen[OrderDetails]

val orderDetails = Table.defineTableSmart[OrderDetails]

Expand Down Expand Up @@ -136,7 +140,7 @@ object MysqlModuleSpec extends MysqlRunnableSpec {
UUID.fromString("636ae137-5b1a-4c8c-b11f-c47c624d9cdc"),
"Jose",
"Wiggins",
false,
verified = false,
LocalDate.parse("1987-03-23")
)
)
Expand Down Expand Up @@ -282,8 +286,8 @@ object MysqlModuleSpec extends MysqlRunnableSpec {
)

val rows = List(
CustomerRow(UUID.randomUUID(), LocalDate.ofYearDay(2001, 8), "Peter", "Parker", true),
CustomerRow(UUID.randomUUID(), LocalDate.ofYearDay(1980, 2), "Stephen", "Strange", false)
CustomerRow(UUID.randomUUID(), LocalDate.ofYearDay(2001, 8), "Peter", "Parker", verified = true),
CustomerRow(UUID.randomUUID(), LocalDate.ofYearDay(1980, 2), "Stephen", "Strange", verified = false)
)

val command = insertInto(customers)(
Expand Down
3 changes: 2 additions & 1 deletion mysql/src/test/scala/zio/sql/mysql/TransactionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ object TransactionSpec 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
8 changes: 4 additions & 4 deletions oracle/src/test/scala/zio/sql/oracle/DualSchema.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package zio.sql.oracle

import zio.schema.DeriveSchema
import zio.schema.{ DeriveSchema, Schema }
import zio.sql.table._

trait DualSchema {
object Dual {
case class Dual(dummy: String)

implicit val dummySchema = DeriveSchema.gen[Dual]
val dual = Table.defineTable[Dual]
val dummy = dual.columns
implicit val dummySchema: Schema.CaseClass1[String, Dual] = DeriveSchema.gen[Dual]
val dual = Table.defineTable[Dual]
val dummy = dual.columns
}
}
Loading

0 comments on commit 9da650a

Please sign in to comment.