Skip to content

Commit

Permalink
formatting and 2.12 compilation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sviezypan committed Feb 16, 2023
1 parent 1ef0d8c commit fb55409
Show file tree
Hide file tree
Showing 31 changed files with 59 additions and 66 deletions.
4 changes: 2 additions & 2 deletions core/jvm/src/main/scala/zio/sql/Sql.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ trait Sql {

def renderInsert[A: Schema](insert: Insert[_, A]): String

//TODO don't know where to put it now
// TODO don't know where to put it now
implicit def convertOptionToSome[A](implicit op: Schema[Option[A]]): Schema[Some[A]] =
op.transformOrFail[Some[A]](
{
Expand All @@ -61,5 +61,5 @@ trait Sql {
},
someA => Right(someA)
)
implicit val none: Schema[None.type] = Schema.singleton(None)
implicit val none: Schema[None.type] = Schema.singleton(None)
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/expr/ComparableTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ object ComparableTypes extends ComparableTypesLowPriority {

sealed trait ComparableTypesLowPriority {
implicit final def comparableSubtype2[A, B <: A]: ComparableTypes[A, B] = new ComparableTypes[A, B] {}
}
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/expr/FunctionName.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package zio.sql.expr

final case class FunctionName(name: String)
final case class FunctionName(name: String)
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/expr/Set.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ object Set {

def typeTag = implicitly[TypeTag[Value]]
}
}
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/insert/Insert.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import zio.sql.select._

final case class Insert[A, Z](table: Table.Source.Aux[A], sources: SelectionSet[A], values: Seq[Z])(implicit
schemaN: Schema[Z]
)
)
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/insert/InsertBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ final case class InsertBuilder[F, Source, AllColumnIdentities, B <: SelectionSet
schemaCC: Schema[Z],
schemaValidity: InsertLike[F, ColsRepr, AllColumnIdentities, Z]
): Insert[Source, Z] = Insert(table, sources.value, Seq(value))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package zio.sql.insert
import zio.sql.table._
import zio.sql.expr.Expr
import zio.sql.select._
import zio.sql.insert.InsertBuilder

// format: off
final case class InsertByCommaBuilder[Source, AllColumnIdentities](
Expand Down
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/ops/Operator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Operator {

override val symbol: String = "/"
}
case object AndBool extends BinaryOp[Boolean] {
case object AndBool extends BinaryOp[Boolean] {
override val symbol: String = "and"
}

Expand Down
3 changes: 1 addition & 2 deletions core/jvm/src/main/scala/zio/sql/select/ColumnSelection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ sealed trait ColumnSelection[-Source, +ColumnType] {
val toColumn: Column[ColumnType]
}


object ColumnSelection {
final case class Constant[ColumnType: TypeTag](value: ColumnType, name: Option[String])
extends ColumnSelection[Any, ColumnType] {
Expand All @@ -33,4 +32,4 @@ object ColumnSelection {
case None => Column.Indexed()
}
}
}
}
4 changes: 2 additions & 2 deletions core/jvm/src/main/scala/zio/sql/select/DecodingError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object DecodingError {
final case class MissingColumn(column: Int) extends DecodingError {
def message = s"The column with index ${column} does not exist"
}
case object Closed extends DecodingError {
case object Closed extends DecodingError {
def message = s"The ResultSet has been closed, so decoding is impossible"
}
}
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/select/Ordering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ object Ordering {

implicit def exprToOrdering[F, A, B](expr: Expr[F, A, B]): Ordering[Expr[F, A, B]] =
Asc(expr)
}
}
10 changes: 6 additions & 4 deletions core/jvm/src/main/scala/zio/sql/select/SelectAll.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio.sql.table._

final case class SelectAll() {

//TODO check if helper's types can be moved to table or rewrite to macro
// TODO check if helper's types can be moved to table or rewrite to macro
def from[A](table: Table.Source.Aux[A])(implicit helper: SelectAllHelper[table.ColumnsOut, A]): Read.Select[
helper.F,
helper.ResultTypeRepr,
Expand All @@ -18,10 +18,12 @@ final case class SelectAll() {
helper.ColumnHead,
helper.SelectionTail
]
val b: B0 = ??? //table.all.selection.value.asInstanceOf[B0]
val b: B0 = ??? // table.all.selection.value.asInstanceOf[B0]

Read.Subselect[helper.F, helper.ResultTypeRepr, A, A, helper.ColumnHead, helper.SelectionTail](
Selection[helper.F, A, B0](b), Some(table), true
Selection[helper.F, A, B0](b),
Some(table),
true
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ final case class SubselectBuilder[F, Source, B <: SelectionSet[Source], ParentTa

Read.Subselect(Selection[F, Source with ParentTable, B0](b), Some(table), true).normalize
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.sql.table

import zio.sql._
import zio.sql._
import zio.schema._
import zio.sql.typetag._

Expand All @@ -26,4 +26,4 @@ class ExprAccessorBuilder(name: String) extends AccessorBuilder {

def makeTraversal[S, A](collection: Schema.Collection[S, A], element: Schema[A]): Traversal[S, A] = ()

}
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/typetag/Decodable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import zio.sql.select.DecodingError

trait Decodable[+A] {
def decode(column: Int, resultSet: ResultSet): Either[DecodingError, A]
}
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/typetag/IsIntegral.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ object IsIntegral {
implicit case object TShortIsIntegral extends AbstractIsIntegral[Short]
implicit case object TIntIsIntegral extends AbstractIsIntegral[Int]
implicit case object TLongIsIntegral extends AbstractIsIntegral[Long]
}
}
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/typetag/IsNumeric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ object IsNumeric {
implicit case object TDoubleIsNumeric extends AbstractIsNumeric[Double]
// TODO IS BigDecimal numeric? can I work in sql with -, + on `money` type?
implicit case object TBigDecimalIsNumeric extends AbstractIsNumeric[java.math.BigDecimal]
}
}
10 changes: 2 additions & 8 deletions core/jvm/src/main/scala/zio/sql/typetag/TypeTag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import java.time._
import java.util.UUID
import zio.Chunk
import zio.schema._
import zio.sql.typetag.Decodable

trait Tag[+A] {
private[zio] def cast(a: Any): A = a.asInstanceOf[A]
Expand All @@ -13,7 +12,7 @@ trait Tag[+A] {
sealed trait TypeTag[+A] extends Tag[A]

object TypeTag {

trait TypeTagExtension[+A] extends Tag[A] with Decodable[A]

sealed trait NotNull[+A] extends TypeTag[A]
Expand Down Expand Up @@ -42,7 +41,7 @@ object TypeTag {
final case class Nullable[A: NotNull]() extends TypeTag[Option[A]] {
def typeTag: TypeTag[A] = implicitly[TypeTag[A]]
}
implicit case object TNone extends TypeTag[None.type]
implicit case object TNone extends TypeTag[None.type]

implicit def option[A: NotNull]: TypeTag[Option[A]] = Nullable[A]()

Expand Down Expand Up @@ -110,8 +109,3 @@ object TypeTag {
case _ => None
}
}





2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/update/Update.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio.sql.table._
import zio.sql.typetag._
import zio.sql.Features

import zio.sql.expr.{Expr, Set}
import zio.sql.expr.{ Expr, Set }

// UPDATE table
// SET foo = bar
Expand Down
2 changes: 1 addition & 1 deletion core/jvm/src/main/scala/zio/sql/update/UpdateBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ import zio.sql.expr._
final case class UpdateBuilder[A](table: Table.Aux[A]) {
def set[F: Features.IsSource, Value: TypeTag](lhs: Expr[F, A, Value], rhs: Expr[_, A, Value]): Update[A] =
Update(table, Set(lhs, rhs) :: Nil, true)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package zio.sql.utils

sealed trait TrailingUnitNormalizer[In] {
type Out

sealed trait TrailingUnitNormalizer[In] {
type Out
def apply(in: In): Out
}

def apply(in: In): Out
object TrailingUnitNormalizer {
type WithOut[In0, Out0] = TrailingUnitNormalizer[In0] {
type Out = Out0
}

object TrailingUnitNormalizer {
type WithOut[In0, Out0] = TrailingUnitNormalizer[In0] {
type Out = Out0
}
// format: off
implicit def arity1[In, A]: TrailingUnitNormalizer.WithOut[(A, Unit), A] = new TrailingUnitNormalizer[(A, Unit)] {
override type Out = A
Expand Down Expand Up @@ -165,4 +164,4 @@ package zio.sql.utils
(in._1, in._2._1, in._2._2._1, in._2._2._2._1, in._2._2._2._2._1, in._2._2._2._2._2._1, in._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1, in._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._2._1)
}
// format: on
}
}
2 changes: 1 addition & 1 deletion core/jvm/src/test/scala/zio/sql/ProductSchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import zio.sql.table._
import zio.sql.insert._
import zio.sql.select._
import zio.sql.update._
import zio.sql.delete._
import zio.sql.delete._

object ProductSchema {
val sql = new Sql { self =>
Expand Down
2 changes: 1 addition & 1 deletion core/jvm/src/test/scala/zio/sql/TestBasicSelectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import zio.sql.table._
import zio.sql.select._
import zio.sql.insert._
import zio.sql.update._
import zio.sql.delete._
import zio.sql.delete._

object TestBasicSelect {
val userSql = new Sql { self =>
Expand Down
8 changes: 4 additions & 4 deletions mysql/src/main/scala/zio/sql/mysql/MysqlRenderModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ trait MysqlRenderModule extends MysqlSqlModule { self =>
table match {
case Table.DialectSpecificTable(_) => ???
// The outer reference in this type test cannot be checked at run time?!
case sourceTable: Table.Source =>
case sourceTable: Table.Source =>
render(sourceTable.name)
case Table.DerivedTable(read, name) =>
render(" ( ")
Expand Down Expand Up @@ -288,7 +288,7 @@ trait MysqlRenderModule extends MysqlSqlModule { self =>
case Expr.Source(table, column) =>
(table, column.name) match {
case (tableName: String, Some(columnName)) => render(tableName, ".", columnName)
case _ => ()
case _ => ()
}
case Expr.Unary(base, op) =>
render(" ", op.symbol)
Expand Down Expand Up @@ -415,9 +415,9 @@ trait MysqlRenderModule extends MysqlSqlModule { self =>
lit.typeTag match {
case TDialectSpecific(tt) =>
tt match {
case tt @ TYear =>
case tt @ TYear =>
render(tt.cast(lit.value))
case _ => ???
case _ => ???
}
case TByteArray =>
render(
Expand Down
4 changes: 2 additions & 2 deletions mysql/src/main/scala/zio/sql/mysql/MysqlSqlModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import java.time._
import java.sql.ResultSet
import java.util.UUID
import zio.sql.Sql
import zio.sql.select._
import zio.sql.expr._
import zio.sql.select._
import zio.sql.expr._
import zio.sql.typetag._

trait MysqlSqlModule extends Sql { self =>
Expand Down
4 changes: 2 additions & 2 deletions oracle/src/main/scala/zio/sql/oracle/OracleRenderModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ trait OracleRenderModule extends OracleSqlModule { self =>
(table, column.name) match {
case (tableName: String, Some(columnName)) =>
val _ = builder.append(tableName).append(".").append(columnName)
case _ => ()
case _ => ()
}
case Expr.Unary(base, op) =>
val _ = builder.append(" ").append(op.symbol)
Expand Down Expand Up @@ -656,7 +656,7 @@ trait OracleRenderModule extends OracleSqlModule { self =>
table match {
case Table.DialectSpecificTable(_) => ???
// The outer reference in this type test cannot be checked at run time?!
case sourceTable: Table.Source =>
case sourceTable: Table.Source =>
val _ = builder.append(sourceTable.name)
case Table.DerivedTable(read, name) =>
builder.append(" ( ")
Expand Down
4 changes: 2 additions & 2 deletions oracle/src/main/scala/zio/sql/oracle/OracleSqlModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import java.time.YearMonth
import java.sql.ResultSet
import scala.util.Try
import java.time.Duration
import zio.sql.select._
import zio.sql.expr._
import zio.sql.select._
import zio.sql.expr._
import zio.sql.typetag._

trait OracleSqlModule extends Sql { self =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ trait PostgresRenderModule extends PostgresSqlModule { self =>
case TString => render("'", value, "'")
case TDialectSpecific(typeTagExtension) =>
typeTagExtension match {
case tt @ TInterval => render(tt.cast(value))
case tt @ TTimestampz => render(tt.cast(value))
case _ => ???
case tt @ TInterval => render(tt.cast(value))
case tt @ TTimestampz => render(tt.cast(value))
case _ => ???
}
case TByteArray =>
render(
Expand Down Expand Up @@ -265,7 +265,7 @@ trait PostgresRenderModule extends PostgresSqlModule { self =>
(table, column.name) match {
case (tableName: String, Some(columnName)) =>
render(quoted(tableName), ".", quoted(columnName))
case _ => ()
case _ => ()
}
e.typeTag match {
case TypeTag.TBigDecimal => render("::numeric")
Expand Down Expand Up @@ -530,10 +530,10 @@ trait PostgresRenderModule extends PostgresSqlModule { self =>
render(" ,lateral ")

renderTable(derivedTable)
case _ => ???
case _ => ???
}
// The outer reference in this type test cannot be checked at run time?!
case sourceTable: Table.Source => render(quoted(sourceTable.name))
case sourceTable: Table.Source => render(quoted(sourceTable.name))
case Table.DerivedTable(read, name) =>
render(" ( ")
render(renderRead(read.asInstanceOf[Read[_]]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ trait PostgresSqlModule extends Sql { self =>
}
}

//could not find implicit value for evidence parameter of type
// could not find implicit value for evidence parameter of type
// zio.sql.typetag.TypeTag[zio.sql.postgresql.CustomFunctionDefSpec.PostgresSpecific.Interval]

trait PostgresTypeTag[+A] extends TypeTagExtension[A]
Expand All @@ -60,7 +60,7 @@ trait PostgresSqlModule extends Sql { self =>
_ => Right(())
)
}
implicit case object TInterval extends TypeTagExtension[Interval] {
implicit case object TInterval extends TypeTagExtension[Interval] {
override def decode(
column: Int,
resultSet: ResultSet
Expand Down
Loading

0 comments on commit fb55409

Please sign in to comment.