Skip to content

Commit

Permalink
Merge pull request zio-archive#830 from sviezypan/core_refactor
Browse files Browse the repository at this point in the history
Refactoring of core module
  • Loading branch information
sviezypan authored Mar 1, 2023
2 parents a5ea95a + 21cd32c commit 1dc612e
Show file tree
Hide file tree
Showing 84 changed files with 3,415 additions and 3,282 deletions.
39 changes: 22 additions & 17 deletions core/jvm/src/main/scala/zio/sql/Sql.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package zio.sql

import zio.schema.Schema
import zio.sql.table._
import zio.sql.update._
import zio.sql.select._
import zio.sql.insert._
import zio.sql.delete._

trait Sql
extends SelectModule
with DeleteModule
with UpdateModule
with ExprModule
with TableModule
with AllColumnsModule
with InsertModule
with UtilsModule
with SelectUtilsModule
with InsertUtilsModule {
self =>
trait Sql {

/*
* (SELECT *, "foo", table.a + table.b AS sum... FROM table WHERE cond) UNION (SELECT ... FROM table)
Expand Down Expand Up @@ -48,13 +42,24 @@ trait Sql

def insertInto[Source, AllColumnIdentities](
table: Table.Source.Aux_[Source, AllColumnIdentities]
): InsertIntoBuilder[Source, AllColumnIdentities] = InsertIntoBuilder(table)
): InsertByCommaBuilder[Source, AllColumnIdentities] = InsertByCommaBuilder(table)

def renderDelete(delete: self.Delete[_]): String
def renderDelete(delete: Delete[_]): String

def renderRead(read: self.Read[_]): String
def renderRead(read: Read[_]): String

def renderUpdate(update: self.Update[_]): String
def renderUpdate(update: Update[_]): String

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

// 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]](
{
case Some(a) => Right(Some(a))
case None => Left("cannot encode Right")
},
someA => Right(someA)
)
implicit val none: Schema[None.type] = Schema.singleton(None)
}
945 changes: 0 additions & 945 deletions core/jvm/src/main/scala/zio/sql/allcolumns.scala

This file was deleted.

8 changes: 0 additions & 8 deletions core/jvm/src/main/scala/zio/sql/delete.scala

This file was deleted.

8 changes: 8 additions & 0 deletions core/jvm/src/main/scala/zio/sql/delete/Delete.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package zio.sql.delete

import zio.sql.table._
import zio.sql.expr.Expr

final case class Delete[A](table: Table.Aux[A], whereExpr: Expr[_, A, Boolean]) {
def where[F](expr: Expr[F, A, Boolean]): Delete[A] = Delete(table, expr)
}
Loading

0 comments on commit 1dc612e

Please sign in to comment.