diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..ad60c8cd0 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Scala Steward: Reformat with scalafmt 3.7.10 +9bcedec20a4fc7adedce8aea4921c05b0c7acfa4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6db45b2ab..cc3d8dd8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,8 @@ name: CI env: - JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags -XX:+UseG1GC -Xmx4g -Xms4g - JVM_OPTS: -XX:+PrintCommandLineFlags -XX:+UseG1GC -Xmx4g -Xms4g + JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags -XX:+UseG1GC -Xmx4g -Xms4g -Xss4m + JVM_OPTS: -XX:+PrintCommandLineFlags -XX:+UseG1GC -Xmx4g -Xms4g -Xss4m on: pull_request: diff --git a/.scalafmt.conf b/.scalafmt.conf index 1e658cd37..6c4a46c56 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.5.9" +version = "3.7.10" maxColumn = 120 align.preset = most continuationIndent.defnSite = 2 diff --git a/README.md b/README.md index 4704b7654..39e8e3497 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ZIO SQL lets you write type-safe, type-inferred, and composable SQL queries in ordinary Scala, helping you prevent persistence bugs before they happen, and leverage your IDE to make writing SQL productive, safe, and fun. -[![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-sql/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-sql_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-sql_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-sql_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-sql_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-sql-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-sql-docs_2.13) [![ZIO SQL](https://img.shields.io/github/stars/zio/zio-sql?style=social)](https://github.com/zio/zio-sql) +[![Development](https://img.shields.io/badge/Project%20Stage-Development-green.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-sql/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-sql_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-sql_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-sql_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-sql_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-sql-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-sql-docs_2.13) [![ZIO SQL](https://img.shields.io/github/stars/zio/zio-sql?style=social)](https://github.com/zio/zio-sql) ## Introduction diff --git a/build.sbt b/build.sbt index 181702c5b..8f2d2afc9 100644 --- a/build.sbt +++ b/build.sbt @@ -26,7 +26,7 @@ addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck" val zioVersion = "2.0.6" val zioSchemaVersion = "0.4.2" val testcontainersVersion = "1.17.6" -val testcontainersScalaVersion = "0.40.11" +val testcontainersScalaVersion = "0.40.17" val logbackVersion = "1.2.11" lazy val root = project @@ -98,7 +98,7 @@ lazy val docs = project crossScalaVersions := Seq(Scala213, Scala212, ScalaDotty), projectName := "ZIO SQL", mainModuleName := (coreJVM / moduleName).value, - projectStage := ProjectStage.ProductionReady, + projectStage := ProjectStage.Development, ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(), docsPublishBranch := "master", readmeContribution := readmeContribution.value + @@ -131,6 +131,7 @@ lazy val examples = project lazy val driver = project .in(file("driver")) + .dependsOn(coreJVM) .settings(stdSettings("zio-sql-driver")) .settings(buildInfoSettings("zio.sql.driver")) .settings( diff --git a/core/jvm/src/main/scala/zio/sql/Sql.scala b/core/jvm/src/main/scala/zio/sql/Sql.scala index a55e4649a..7e1b9cd67 100644 --- a/core/jvm/src/main/scala/zio/sql/Sql.scala +++ b/core/jvm/src/main/scala/zio/sql/Sql.scala @@ -1,12 +1,16 @@ package zio.sql -import zio.schema.Schema +import zio.schema.{ Schema, StandardType } import zio.sql.table._ import zio.sql.update._ import zio.sql.select._ import zio.sql.insert._ import zio.sql.delete._ +case class SqlRow(params: List[SqlParameter]) +case class SqlParameter(_type: StandardType[_], value: Any) +case class SqlStatement(query: String, rows: List[SqlRow]) + trait Sql { /* @@ -34,15 +38,13 @@ trait Sql { def select[F, A, B <: SelectionSet[A]](selection: Selection[F, A, B]): SelectBuilder[F, A, B] = SelectBuilder[F, A, B](selection) - def subselect[ParentTable]: SubselectPartiallyApplied[ParentTable] = new SubselectPartiallyApplied[ParentTable] + def subselect[ParentTable]: SubselectByCommaBuilder[ParentTable] = new SubselectByCommaBuilder[ParentTable] def deleteFrom[T <: Table](table: T): Delete[table.TableType] = Delete(table, true) def update[A](table: Table.Aux[A]): UpdateBuilder[A] = UpdateBuilder(table) - def insertInto[Source, AllColumnIdentities]( - table: Table.Source.Aux_[Source, AllColumnIdentities] - ): InsertByCommaBuilder[Source, AllColumnIdentities] = InsertByCommaBuilder(table) + val insertInto: InsertByCommaBuilder = InsertByCommaBuilder() def renderDelete(delete: Delete[_]): String @@ -50,7 +52,7 @@ trait Sql { def renderUpdate(update: Update[_]): String - def renderInsert[A: Schema](insert: Insert[_, A]): String + def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement // TODO don't know where to put it now implicit def convertOptionToSome[A](implicit op: Schema[Option[A]]): Schema[Some[A]] = diff --git a/core/jvm/src/main/scala/zio/sql/expr/Expr.scala b/core/jvm/src/main/scala/zio/sql/expr/Expr.scala index 2b49d570b..178e58b20 100644 --- a/core/jvm/src/main/scala/zio/sql/expr/Expr.scala +++ b/core/jvm/src/main/scala/zio/sql/expr/Expr.scala @@ -123,8 +123,6 @@ sealed trait Expr[-F, -A, +B] { self => object Expr { - implicit val subqueryToExpr = Read.Subselect.subselectToExpr _ - sealed trait InvariantExpr[F, -A, B] extends Expr[F, A, B] { def typeTag: TypeTag[B] } @@ -134,7 +132,7 @@ object Expr { implicit def literal[A: TypeTag](a: A): Expr[Features.Literal, Any, A] = Expr.Literal(a) implicit def some[A: TypeTag.NotNull](someA: Some[A]): Expr[Features.Literal, Any, Option[A]] = { - implicit val typeTagA = TypeTag.Nullable[A]() + implicit val typeTagA: TypeTag.Nullable[A] = TypeTag.Nullable[A]() Expr.Literal[Option[A]](someA) } diff --git a/core/jvm/src/main/scala/zio/sql/insert/InsertBuilder.scala b/core/jvm/src/main/scala/zio/sql/insert/InsertBuilder.scala index bba6015a9..b429385ec 100644 --- a/core/jvm/src/main/scala/zio/sql/insert/InsertBuilder.scala +++ b/core/jvm/src/main/scala/zio/sql/insert/InsertBuilder.scala @@ -5,18 +5,18 @@ import zio.sql.macros._ import zio.sql.table._ import zio.sql.select._ -final case class InsertBuilder[F, Source, AllColumnIdentities, B <: SelectionSet[Source], ColsRepr]( +final case class InsertBuilder[F, Source, AllColumnIdentities, B <: SelectionSet[Source]]( table: Table.Source.Aux_[Source, AllColumnIdentities], - sources: Selection.Aux[F, Source, B, ColsRepr] + sources: Selection[F, Source, B] ) { def values[Z](values: Seq[Z])(implicit schemaCC: Schema[Z], - schemaValidity: InsertLike[F, ColsRepr, AllColumnIdentities, Z] + schemaValidity: InsertLike[F, sources.ColsRepr, AllColumnIdentities, Z] ): Insert[Source, Z] = Insert(table, sources.value, values) def values[Z](value: Z)(implicit schemaCC: Schema[Z], - schemaValidity: InsertLike[F, ColsRepr, AllColumnIdentities, Z] + schemaValidity: InsertLike[F, sources.ColsRepr, AllColumnIdentities, Z] ): Insert[Source, Z] = Insert(table, sources.value, Seq(value)) } diff --git a/core/jvm/src/main/scala/zio/sql/insert/InsertByCommaBuilder.scala b/core/jvm/src/main/scala/zio/sql/insert/InsertByCommaBuilder.scala index cd3ffbaa3..f576f6968 100644 --- a/core/jvm/src/main/scala/zio/sql/insert/InsertByCommaBuilder.scala +++ b/core/jvm/src/main/scala/zio/sql/insert/InsertByCommaBuilder.scala @@ -1,210 +1,12 @@ package zio.sql.insert import zio.sql.table._ -import zio.sql.expr.Expr import zio.sql.select._ +import scala.language.experimental.macros -// format: off -final case class InsertByCommaBuilder[Source, AllColumnIdentities]( - table: Table.Source.Aux_[Source, AllColumnIdentities] -) { - - def apply[F, B <: SelectionSet[Source]](sources: Selection[F, Source, B]) = - InsertBuilder[F, Source, AllColumnIdentities, B, sources.ColsRepr](table, sources) - - def apply[F1, B1](expr1: Expr[F1, Source, B1]) = { - val selection: Selection[F1, Source, SelectionSet.Cons[Source, B1, SelectionSet.Empty]] = expr1 - - InsertBuilder[F1, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Empty], selection.ColsRepr](table, selection) - } - - def apply[F1, F2, B1, B2](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2]) = { - val selection = expr1 ++ expr2 - - InsertBuilder[F1 with F2, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Empty]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, B1, B2, B3](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3]) = { - val selection = expr1 ++ expr2 ++ expr3 - - InsertBuilder[F1 with F2 with F3, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Empty]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, B1, B2, B3, B4](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 - - InsertBuilder[F1 with F2 with F3 with F4, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Empty]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, B1, B2, B3, B4, B5](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 - - InsertBuilder[F1 with F2 with F3 with F4 with F5, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Empty]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, B1, B2, B3, B4, B5, B6](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Empty]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, B1, B2, B3, B4, B5, B6, B7](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Empty]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, B1, B2, B3, B4, B5, B6, B7, B8](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Empty]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, B1, B2, B3, B4, B5, B6, B7, B8, B9](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Empty]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Empty]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Empty]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Empty]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Empty]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Empty]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Empty]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Empty]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Empty]]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Empty]]]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Empty]]]]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20], expr21: Expr[F21, Source, B21]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 ++ expr21 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Cons[Source, B21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21, B22](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20], expr21: Expr[F21, Source, B21], expr22: Expr[F22, Source, B22]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 ++ expr21 ++ expr22 - - InsertBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 with F22, Source, AllColumnIdentities, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Cons[Source, B21, SelectionSet.Cons[Source, B22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]]], selection.ColsRepr]( - table, - selection - ) - } +final case class InsertByCommaBuilder() { + def apply[F, Source, Set <: SelectionSet[Source], AllColumnIdentities]( + table: Table.Source.Aux_[Source, AllColumnIdentities] + )(selections: Selection[F, Source, _ <: SelectionSet[Source]]*): InsertBuilder[F, Source, AllColumnIdentities, Set] = + macro SelectionMacro.insertApplyMacro[F, Source, AllColumnIdentities] } -// format: on diff --git a/core/jvm/src/main/scala/zio/sql/select/Read.scala b/core/jvm/src/main/scala/zio/sql/select/Read.scala index 0d8664d74..b889d9d96 100644 --- a/core/jvm/src/main/scala/zio/sql/select/Read.scala +++ b/core/jvm/src/main/scala/zio/sql/select/Read.scala @@ -180,43 +180,162 @@ object Read { override type GroupByF = self.GroupByF } - //format: off - def groupBy[F1](expr1: Expr[F1, Source, Any])(implicit verify: GroupByLike[F, F1]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr, self.groupByExprs ++ expr1, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 - } - - def groupBy[F1, F2](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any])(implicit verify: GroupByLike[F, F1 with F2]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr, self.groupByExprs ++ expr1 ++ expr2, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 with F2 + def groupBy[F1](expr1: Expr[F1, Source, Any])(implicit + verify: GroupByLike[F, F1] + ): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 } - def groupBy[F1, F2, F3](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any], expr3: Expr[F3, Source, Any])(implicit verify: GroupByLike[F, F1 with F2 with F3]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr,self.groupByExprs ++ expr1 ++ expr2 ++ expr3, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 with F2 with F3 + def groupBy[F1, F2](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any])(implicit + verify: GroupByLike[F, F1 with F2] + ): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1 ++ expr2, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 with F2 + } + + def groupBy[F1, F2, F3](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any], expr3: Expr[F3, Source, Any])( + implicit verify: GroupByLike[F, F1 with F2 with F3] + ): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1 ++ expr2 ++ expr3, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 with F2 with F3 } - def groupBy[F1, F2, F3, F4](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any], expr3: Expr[F3, Source, Any], expr4: Expr[F4, Source, Any])(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3 with F4] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr, self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 + def groupBy[F1, F2, F3, F4]( + expr1: Expr[F1, Source, Any], + expr2: Expr[F2, Source, Any], + expr3: Expr[F3, Source, Any], + expr4: Expr[F4, Source, Any] + )(implicit + verify: GroupByLike[F, F1 with F2 with F3 with F4] + ): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3 with F4] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 } - - def groupBy[F1, F2, F3, F4, F5](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any], expr3: Expr[F3, Source, Any], expr4: Expr[F4, Source, Any], expr5: Expr[F5, Source, Any])(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4 with F5]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3 with F4 with F5] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr, self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 with F5 + + def groupBy[F1, F2, F3, F4, F5]( + expr1: Expr[F1, Source, Any], + expr2: Expr[F2, Source, Any], + expr3: Expr[F3, Source, Any], + expr4: Expr[F4, Source, Any], + expr5: Expr[F5, Source, Any] + )(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4 with F5]): Subselect.WithGroupByF[ + F, + Repr, + Source, + Subsource, + Head, + Tail, + self.GroupByF with F1 with F2 with F3 with F4 with F5 + ] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 with F5 } - - def groupBy[F1, F2, F3, F4, F5, F6](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any], expr3: Expr[F3, Source, Any], expr4: Expr[F4, Source, Any], expr5: Expr[F5, Source, Any], expr6: Expr[F6, Source, Any])(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4 with F5 with F6]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr, self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 + + def groupBy[F1, F2, F3, F4, F5, F6]( + expr1: Expr[F1, Source, Any], + expr2: Expr[F2, Source, Any], + expr3: Expr[F3, Source, Any], + expr4: Expr[F4, Source, Any], + expr5: Expr[F5, Source, Any], + expr6: Expr[F6, Source, Any] + )(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4 with F5 with F6]): Subselect.WithGroupByF[ + F, + Repr, + Source, + Subsource, + Head, + Tail, + self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 + ] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 } - //TODO add arities up to 22 if needed - def groupBy[F1, F2, F3, F4, F5, F6, F7](expr1: Expr[F1, Source, Any], expr2: Expr[F2, Source, Any], expr3: Expr[F3, Source, Any], expr4: Expr[F4, Source, Any], expr5: Expr[F5, Source, Any], expr6: Expr[F6, Source, Any], expr7: Expr[F7, Source, Any])(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4 with F5 with F6 with F7]): Subselect.WithGroupByF[F, Repr, Source, Subsource, Head, Tail, self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 with F7] = - new Subselect[F, Repr, Source, Subsource, Head, Tail](selection, table, whereExpr, self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7, havingExpr, orderByExprs, offset, limit) { - override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 with F7 + // TODO add arities up to 22 if needed + def groupBy[F1, F2, F3, F4, F5, F6, F7]( + expr1: Expr[F1, Source, Any], + expr2: Expr[F2, Source, Any], + expr3: Expr[F3, Source, Any], + expr4: Expr[F4, Source, Any], + expr5: Expr[F5, Source, Any], + expr6: Expr[F6, Source, Any], + expr7: Expr[F7, Source, Any] + )(implicit verify: GroupByLike[F, F1 with F2 with F3 with F4 with F5 with F6 with F7]): Subselect.WithGroupByF[ + F, + Repr, + Source, + Subsource, + Head, + Tail, + self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 with F7 + ] = + new Subselect[F, Repr, Source, Subsource, Head, Tail]( + selection, + table, + whereExpr, + self.groupByExprs ++ expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7, + havingExpr, + orderByExprs, + offset, + limit + ) { + override type GroupByF = self.GroupByF with F1 with F2 with F3 with F4 with F5 with F6 with F7 } - //format: on def normalize(implicit instance: Normalizer[ResultType] diff --git a/core/jvm/src/main/scala/zio/sql/select/SelectAll.scala b/core/jvm/src/main/scala/zio/sql/select/SelectAll.scala index 8a9d9e3e5..184a58229 100644 --- a/core/jvm/src/main/scala/zio/sql/select/SelectAll.scala +++ b/core/jvm/src/main/scala/zio/sql/select/SelectAll.scala @@ -1,29 +1,28 @@ package zio.sql.select import zio.sql.table._ +import zio.sql.expr._ +import scala.language.experimental.macros +import scala.language.implicitConversions final case class SelectAll() { + def from[AllColumnsIdentities, TableType, ColumnsOut, F, Repr, Head, Tail <: SelectionSet[TableType]]( + wrapper: SelectAllWrapper[AllColumnsIdentities, TableType, ColumnsOut] + ): Read.Subselect[F, Repr, TableType, TableType, Head, Tail] = + macro SelectionMacro.buildSelectAll[AllColumnsIdentities, ColumnsOut, TableType] +} - // 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, - A, - helper.ColumnHead, - helper.SelectionTail - ] = { - type B0 = SelectionSet.ConsAux[ - helper.ResultTypeRepr, - A, - helper.ColumnHead, - helper.SelectionTail - ] - val b: B0 = table.all.selection.value.asInstanceOf[B0] +case class SelectAllWrapper[AllColumnsIdentities, TableType, ColumnsOut]( + table: Table.Source.WithTableDetails[AllColumnsIdentities, TableType, ColumnsOut], + exprs: List[zio.sql.expr.Expr[_, TableType, _]] +) - Read.Subselect[helper.F, helper.ResultTypeRepr, A, A, helper.ColumnHead, helper.SelectionTail]( - Selection[helper.F, A, B0](b), - Some(table), - true +object SelectAllWrapper { + implicit def tableToExprs[AllColumnsIdentities, TableType, ColumnsOut]( + table: Table.Source.WithTableDetails[AllColumnsIdentities, TableType, ColumnsOut] + ): SelectAllWrapper[AllColumnsIdentities, TableType, ColumnsOut] = + SelectAllWrapper( + table, + table.columns.asInstanceOf[Product].productIterator.toList.map(_.asInstanceOf[Expr[_, TableType, _]]) ) - } } diff --git a/core/jvm/src/main/scala/zio/sql/select/SelectAllHelper.scala b/core/jvm/src/main/scala/zio/sql/select/SelectAllHelper.scala deleted file mode 100644 index 4f363519e..000000000 --- a/core/jvm/src/main/scala/zio/sql/select/SelectAllHelper.scala +++ /dev/null @@ -1,944 +0,0 @@ -package zio.sql.select - -import scala.annotation.implicitNotFound - -import zio.sql.expr.Expr -import zio.sql.select._ - -@implicitNotFound( - "SELECT * currently not supported on joined tables, derived tables and for table of size bigger than 22." -) -sealed trait SelectAllHelper[ColumnsOut, TableType] { - type F - type SelSet <: SelectionSet[TableType] - type ResultTypeRepr - type ColumnHead - type SelectionTail <: SelectionSet[TableType] - - def apply(columns: ColumnsOut): SelectBuilder[F, TableType, SelSet] -} - - // format: off -object SelectAllHelper { - - type Aux[ColumnsOut0, TableType0, F0, SelectionSet0, ResultTypeRepr0, ColumnsHead0, SelectionTail0] = - SelectAllHelper[ColumnsOut0, TableType0] { - type F = F0 - - type SelSet = SelectionSet0 - - type ResultTypeRepr = ResultTypeRepr0 - type ColumnHead = ColumnsHead0 - type SelectionTail = SelectionTail0 - } - - implicit def instance1[F1, TableType, A1]: SelectAllHelper.Aux[Expr[ - F1, - TableType, - A1 - ], TableType, F1, SelectionSet.Cons[TableType, A1, SelectionSet.Empty], A1, A1, SelectionSet.Empty] = - new SelectAllHelper[Expr[F1, TableType, A1], TableType] { - - override type F = F1 - override type SelSet = SelectionSet.Cons[TableType, A1, SelectionSet.Empty] - - override type ResultTypeRepr = A1 - - override type ColumnHead = A1 - override type SelectionTail = SelectionSet.Empty - - override def apply(columns: Expr[F1, TableType, A1]) = - SelectBuilder[F1, TableType, SelectionSet.Cons[TableType, A1, SelectionSet.Empty]](columns) - } - - implicit def instance2[F1, F2, TableType, A1, A2] - : SelectAllHelper.Aux[(Expr[F1, TableType, A1], Expr[F2, TableType, A2]), TableType, F1 with F2, SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Empty] - ], (A1, A2), A1, SelectionSet.Cons[TableType, A2, SelectionSet.Empty]] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2]), TableType] { - - override type F = F1 with F2 - override type SelSet = SelectionSet.Cons[TableType, A1, SelectionSet.Cons[TableType, A2, SelectionSet.Empty]] - - override type ResultTypeRepr = (A1, A2) - - override type ColumnHead = A1 - override type SelectionTail = SelectionSet.Cons[TableType, A2, SelectionSet.Empty] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2])) = { - val selection = columns._1 ++ columns._2 - - SelectBuilder[ - F1 with F2, - TableType, - SelectionSet.Cons[TableType, A1, SelectionSet.Cons[TableType, A2, SelectionSet.Empty]] - ](selection) - } - } - - implicit def instance3[F1, F2, F3, TableType, A1, A2, A3]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3]), - TableType, - F1 with F2 with F3, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Empty]] - ], - (A1, A2, A3), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Empty]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3]), TableType] { - - override type F = F1 with F2 with F3 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Empty]] - ] - - override type ResultTypeRepr = (A1, A2, A3) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Empty]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 - - SelectBuilder[ - F1 with F2 with F3, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Empty]] - ] - ](selection) - } - } - - - implicit def instance4[F1, F2, F3, F4, TableType, A1, A2, A3, A4]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4]), - TableType, - F1 with F2 with F3 with F4, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Empty]]] - ], - (A1, A2, A3, A4), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Empty]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4]), TableType] { - - override type F = F1 with F2 with F3 with F4 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Empty]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Empty]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 - - SelectBuilder[ - F1 with F2 with F3 with F4, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Empty]]] - ] - ](selection) - } - } - - implicit def instance5[F1, F2, F3, F4, F5, TableType, A1, A2, A3, A4, A5]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5]), - TableType, - F1 with F2 with F3 with F4 with F5, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Empty]]]] - ], - (A1, A2, A3, A4, A5), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Empty]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Empty]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Empty]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Empty]]]] - ] - ](selection) - } - } - - implicit def instance6[F1, F2, F3, F4, F5, F6, TableType, A1, A2, A3, A4, A5, A6]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Empty]]]]] - ], - (A1, A2, A3, A4, A5, A6), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Empty]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Empty]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Empty]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Empty]]]]] - ] - ](selection) - } - } - - implicit def instance7[F1, F2, F3, F4, F5, F6, F7, TableType, A1, A2, A3, A4, A5, A6, A7]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Empty]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Empty]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Empty]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Empty]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Empty]]]]]] - ] - ](selection) - } - } - - implicit def instance8[F1, F2, F3, F4, F5, F6, F7, F8, TableType, A1, A2, A3, A4, A5, A6, A7, A8]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Empty]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Empty]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Empty]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Empty]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Empty]]]]]]] - ] - ](selection) - } - } - - implicit def instance9[F1, F2, F3, F4, F5, F6, F7, F8, F9, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Empty]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Empty]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Empty]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Empty]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Empty]]]]]]]] - ] - ](selection) - } - } - - - implicit def instance10[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Empty]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Empty]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Empty]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Empty]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Empty]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance11[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Empty]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Empty]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Empty]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Empty]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Empty]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance12[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Empty]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Empty]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Empty]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Empty]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Empty]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance13[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Empty]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Empty]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Empty]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Empty]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Empty]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance14[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Empty]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Empty]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Empty]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Empty]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Empty]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance15[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Empty]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Empty]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Empty]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Empty]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Empty]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance16[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Empty]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Empty]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Empty]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Empty]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Empty]]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance17[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Empty]]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Empty]]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Empty]]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Empty]]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 ++ columns._17 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Empty]]]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance18[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Empty]]]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Empty]]]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Empty]]]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Empty]]]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 ++ columns._17 ++ columns._18 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Empty]]]]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance19[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Empty]]]]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Empty]]]]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Empty]]]]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Empty]]]]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 ++ columns._17 ++ columns._18 ++ columns._19 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Empty]]]]]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance20[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 ++ columns._17 ++ columns._18 ++ columns._19 ++ columns._20 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance21[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20], Expr[F21, TableType, A21]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20], Expr[F21, TableType, A21]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20], Expr[F21, TableType, A21])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 ++ columns._17 ++ columns._18 ++ columns._19 ++ columns._20 ++ columns._21 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]] - ] - ](selection) - } - } - - implicit def instance22[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, TableType, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22]: SelectAllHelper.Aux[ - (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20], Expr[F21, TableType, A21], Expr[F22, TableType, A22]), - TableType, - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 with F22, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Cons[TableType, A22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]] - ], - (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22), - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Cons[TableType, A22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]] - ] = - new SelectAllHelper[(Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20], Expr[F21, TableType, A21], Expr[F22, TableType, A22]), TableType] { - - override type F = F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 with F22 - override type SelSet = SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10,SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Cons[TableType, A22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]] - ] - - override type ResultTypeRepr = (A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22) - - override type ColumnHead = A1 - override type SelectionTail = - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Cons[TableType, A22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]] - - override def apply(columns: (Expr[F1, TableType, A1], Expr[F2, TableType, A2], Expr[F3, TableType, A3], Expr[F4, TableType, A4], Expr[F5, TableType, A5], Expr[F6, TableType, A6], Expr[F7, TableType, A7], Expr[F8, TableType, A8], Expr[F9, TableType, A9], Expr[F10, TableType, A10], Expr[F11, TableType, A11], Expr[F12, TableType, A12], Expr[F13, TableType, A13], Expr[F14, TableType, A14], Expr[F15, TableType, A15], Expr[F16, TableType, A16], Expr[F17, TableType, A17], Expr[F18, TableType, A18], Expr[F19, TableType, A19], Expr[F20, TableType, A20], Expr[F21, TableType, A21], Expr[F22, TableType, A22])) = { - val selection = columns._1 ++ columns._2 ++ columns._3 ++ columns._4 ++ columns._5 ++ columns._6 ++ columns._7 ++ columns._8 ++ columns._9 ++ columns._10 ++ columns._11 ++ columns._12 ++ columns._13 ++ columns._14 ++ columns._15 ++ columns._16 ++ columns._17 ++ columns._18 ++ columns._19 ++ columns._20 ++ columns._21 ++ columns._22 - - SelectBuilder[ - F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 with F22, - TableType, - SelectionSet.Cons[ - TableType, - A1, - SelectionSet.Cons[TableType, A2, SelectionSet.Cons[TableType, A3, SelectionSet.Cons[TableType, A4, SelectionSet.Cons[TableType, A5, SelectionSet.Cons[TableType, A6, SelectionSet.Cons[TableType, A7, SelectionSet.Cons[TableType, A8, SelectionSet.Cons[TableType, A9, SelectionSet.Cons[TableType, A10, SelectionSet.Cons[TableType, A11, SelectionSet.Cons[TableType, A12, SelectionSet.Cons[TableType, A13, SelectionSet.Cons[TableType, A14, SelectionSet.Cons[TableType, A15, SelectionSet.Cons[TableType, A16, SelectionSet.Cons[TableType, A17, SelectionSet.Cons[TableType, A18, SelectionSet.Cons[TableType, A19, SelectionSet.Cons[TableType, A20, SelectionSet.Cons[TableType, A21, SelectionSet.Cons[TableType, A22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]] - ] - ](selection) - } - } - -} - // format: on diff --git a/core/jvm/src/main/scala/zio/sql/select/SelectByCommaBuilder.scala b/core/jvm/src/main/scala/zio/sql/select/SelectByCommaBuilder.scala index 57a81ee95..17bc675a5 100644 --- a/core/jvm/src/main/scala/zio/sql/select/SelectByCommaBuilder.scala +++ b/core/jvm/src/main/scala/zio/sql/select/SelectByCommaBuilder.scala @@ -1,252 +1,9 @@ package zio.sql.select import zio.sql.expr.Expr -import zio.sql.select._ - -// format: off +import scala.language.experimental.macros final case class SelectByCommaBuilder() { - - def apply[F1, Source, B1](expr1: Expr[F1, Source, B1]) = { - SelectBuilder[F1, Source, SelectionSet.Cons[Source, B1, SelectionSet.Empty]](expr1) - } - - def apply[F1, F2, Source, B1, B2](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2]) = { - val selection = expr1 ++ expr2 - SelectBuilder[F1 with F2, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Empty]]](selection) - } - - def apply[F1, F2, F3, Source, B1, B2, B3](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3]) = { - val selection = expr1 ++ expr2 ++ expr3 - SelectBuilder[F1 with F2 with F3, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Empty]]]](selection) - } - - def apply[F1, F2, F3, F4, Source, B1, B2, B3, B4](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 - SelectBuilder[F1 with F2 with F3 with F4, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Empty]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, Source, B1, B2, B3, B4, B5](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 - SelectBuilder[F1 with F2 with F3 with F4 with F5, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Empty]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, Source, B1, B2, B3, B4, B5, B6](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Empty]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, Source, B1, B2, B3, B4, B5, B6, B7](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Empty]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, Source, B1, B2, B3, B4, B5, B6, B7, B8](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 , Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Empty]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 , Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Empty]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 , Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Empty]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Empty]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Empty]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Empty]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Empty]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Empty]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Empty]]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Empty]]]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Empty]]]]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20], expr21: Expr[F21, Source, B21])= { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 ++ expr21 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Cons[Source, B21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]]](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21, B22](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20], expr21: Expr[F21, Source, B21], expr22: Expr[F22, Source, B22]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 ++ expr21 ++ expr22 - SelectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 with F22, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Cons[Source, B21, SelectionSet.Cons[Source, B22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]]]](selection) - } -} - -final class SubselectPartiallyApplied[ParentTable] { - def apply[F, A, B <: SelectionSet[A]](selection: Selection[F, A, B]) = - SubselectBuilder[F, A, B, ParentTable](selection) - - def apply[F1, F2, Source, B1, B2](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2]) = { - val selection = expr1 ++ expr2 - SubselectBuilder[F1 with F2, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Empty]], ParentTable](selection) - } - - def apply[F1, F2, F3, Source, B1, B2, B3](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3]) = { - val selection = expr1 ++ expr2 ++ expr3 - SubselectBuilder[F1 with F2 with F3, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Empty]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, Source, B1, B2, B3, B4](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 - SubselectBuilder[F1 with F2 with F3 with F4, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Empty]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, Source, B1, B2, B3, B4, B5](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 - SubselectBuilder[F1 with F2 with F3 with F4 with F5, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Empty]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, Source, B1, B2, B3, B4, B5, B6](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Empty]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, Source, B1, B2, B3, B4, B5, B6, B7](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Empty]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, Source, B1, B2, B3, B4, B5, B6, B7, B8](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Empty]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9]) = { - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Empty]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Empty]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Empty]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Empty]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Empty]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Empty]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Empty]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Empty]]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Empty]]]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Empty]]]]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 , Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Empty]]]]]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20], expr21: Expr[F21, Source, B21]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 ++ expr21 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Cons[Source, B21, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]], ParentTable](selection) - } - - def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, Source, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21, B22](expr1: Expr[F1, Source, B1], expr2: Expr[F2, Source, B2], expr3: Expr[F3, Source, B3], expr4: Expr[F4, Source, B4], expr5: Expr[F5, Source, B5], expr6: Expr[F6, Source, B6], expr7: Expr[F7, Source, B7], expr8: Expr[F8, Source, B8], expr9: Expr[F9, Source, B9], expr10: Expr[F10, Source, B10], expr11: Expr[F11, Source, B11], expr12: Expr[F12, Source, B12], expr13: Expr[F13, Source, B13], expr14: Expr[F14, Source, B14], expr15: Expr[F15, Source, B15], expr16: Expr[F16, Source, B16], expr17: Expr[F17, Source, B17], expr18: Expr[F18, Source, B18], expr19: Expr[F19, Source, B19], expr20: Expr[F20, Source, B20], expr21: Expr[F21, Source, B21], expr22: Expr[F22, Source, B22]) = { - - val selection = expr1 ++ expr2 ++ expr3 ++ expr4 ++ expr5 ++ expr6 ++ expr7 ++ expr8 ++ expr9 ++ expr10 ++ expr11 ++ expr12 ++ expr13 ++ expr14 ++ expr15 ++ expr16 ++ expr17 ++ expr18 ++ expr19 ++ expr20 ++ expr21 ++ expr22 - SubselectBuilder[F1 with F2 with F3 with F4 with F5 with F6 with F7 with F8 with F9 with F10 with F11 with F12 with F13 with F14 with F15 with F16 with F17 with F18 with F19 with F20 with F21 with F22, Source, SelectionSet.Cons[Source, B1, SelectionSet.Cons[Source, B2, SelectionSet.Cons[Source, B3, SelectionSet.Cons[Source, B4, SelectionSet.Cons[Source, B5, SelectionSet.Cons[Source, B6, SelectionSet.Cons[Source, B7, SelectionSet.Cons[Source, B8, SelectionSet.Cons[Source, B9, SelectionSet.Cons[Source, B10, SelectionSet.Cons[Source, B11, SelectionSet.Cons[Source, B12, SelectionSet.Cons[Source, B13, SelectionSet.Cons[Source, B14, SelectionSet.Cons[Source, B15, SelectionSet.Cons[Source, B16, SelectionSet.Cons[Source, B17, SelectionSet.Cons[Source, B18, SelectionSet.Cons[Source, B19, SelectionSet.Cons[Source, B20, SelectionSet.Cons[Source, B21, SelectionSet.Cons[Source, B22, SelectionSet.Empty]]]]]]]]]]]]]]]]]]]]]], ParentTable](selection) - } + def apply[F, Source, Set <: SelectionSet[Source]](exprs: Expr[F, Source, _]*): SelectBuilder[F, Source, Set] = + macro SelectionMacro.selectApplyMacro[F, Source] } -// format: on diff --git a/core/jvm/src/main/scala/zio/sql/select/Selection.scala b/core/jvm/src/main/scala/zio/sql/select/Selection.scala index cc922805f..d95a1a855 100644 --- a/core/jvm/src/main/scala/zio/sql/select/Selection.scala +++ b/core/jvm/src/main/scala/zio/sql/select/Selection.scala @@ -6,7 +6,7 @@ import zio.sql.expr.Expr /** * A columnar selection of `B` from a source `A`, modeled as `A => B`. */ -final case class Selection[F, -A, +B <: SelectionSet[A]](value: B) { self => +final case class Selection[-F, -A, +B <: SelectionSet[A]](value: B) { self => type ColsRepr = value.ResultTypeRepr diff --git a/core/jvm/src/main/scala/zio/sql/select/SelectionMacro.scala b/core/jvm/src/main/scala/zio/sql/select/SelectionMacro.scala new file mode 100644 index 000000000..7e486523b --- /dev/null +++ b/core/jvm/src/main/scala/zio/sql/select/SelectionMacro.scala @@ -0,0 +1,147 @@ +package zio.sql.select + +import scala.reflect.macros.whitebox +import zio.sql.expr.{ Expr => ZExpr } +import scala.collection.immutable + +private[sql] class SelectionMacro(val c: whitebox.Context) { + import c.universe._ + + def selectApplyMacro[F, Source]( + exprs: c.Expr[ZExpr[F, Source, _]]* + )(implicit i1: c.WeakTypeTag[F], i2: c.WeakTypeTag[Source]): c.Tree = { + + val selection = buildSelectionFromExpr[F, Source](exprs.toList) + + q"""zio.sql.select.SelectBuilder( + ${selection.tree} + )""" + } + + def subselectApplyMacro[F, Source, ParentTable]( + exprs: c.Expr[ZExpr[F, Source, _]]* + )(implicit i1: c.WeakTypeTag[F], i2: c.WeakTypeTag[Source], i3: c.WeakTypeTag[ParentTable]): c.Tree = { + + val fType = weakTypeOf[F] + val sourceType = weakTypeOf[Source] + val parentTable = weakTypeOf[ParentTable] + + val selection = buildSelectionFromExpr[F, Source](exprs.toList) + + val selectionSetType = buildSelectionSetType(exprs.toList.map(e => e.actualType), sourceType) + + q"""zio.sql.select.SubselectBuilder[${q"$fType"}, ${q"$sourceType"}, ${q"${selectionSetType}"} , ${q"$parentTable"}]( + ${selection.tree} + )""" + } + + def insertApplyMacro[F, Source, AllColumnIdentities]( + table: c.Expr[zio.sql.table.Table.Source.Aux_[Source, AllColumnIdentities]] + )(selections: c.Expr[Selection[F, Source, _]]*): c.Tree = { + + val selection = buildSelection[F, Source](selections.toList) + + q""" + zio.sql.insert.InsertBuilder( + ${table.tree}, + ${selection.tree} + ) + """ + } + + // TODO clean up :) - extract common functionality etc. + def buildSelectAll[AllColumnsIdentities, ColumnsOut: WeakTypeTag, TableType: WeakTypeTag]( + wrapper: c.Expr[SelectAllWrapper[AllColumnsIdentities, TableType, ColumnsOut]] + ): c.Tree = { + + val tableType = weakTypeOf[TableType] + val columnsOutType = weakTypeOf[ColumnsOut] + + val exprs = splitTuple(columnsOutType) + + val expList: List[(Type, Type, Type)] = exprs.map(e => splitExpr(e)) + + val intF = buildIntesectionF(expList.map(_._1)) + + val selSetTail = buildSelectionSetType(exprs.tail, tableType) + + val tupleOfTypes = expList.map(_._3) + val repr = tq"(..$tupleOfTypes)" + + val headType = expList.head._3 + + val table = reify(wrapper.splice.table) + + val selection = reify { + wrapper.splice.exprs + .map(e => zio.sql.expr.Expr.expToSelection(e)) + .reduce[zio.sql.select.Selection[_, TableType, _ <: SelectionSet[TableType]]] { case (ex1, ex2) => + ex1 ++ ex2 + } + } + + val selSet = q"${buildSelectionSetType( + exprs, + tableType + )}.asInstanceOf[zio.sql.select.SelectionSet.ConsAux[${repr},${q"${tableType}"},${q"${headType}"}, ${q"${selSetTail}"}]]" + + q""" + zio.sql.select.Read.Subselect[${q"${intF}"}, ${repr}, ${q"${tableType}"}, ${q"${tableType}"}, ${q"${headType}"}, ${q"${selSetTail}"}]( + ${selection.tree}.asInstanceOf[zio.sql.select.Selection[${q"${intF}"}, ${tableType}, ${q"${selSet}"}]], + Some(${table}), + true + ) + """ + } + + private def buildIntesectionF(l: List[Type]): Tree = + l match { + case immutable.Nil => tq"" + case head :: Nil => tq"${q"$head"} " + case head :: tail => tq"${q"$head"} with ${buildIntesectionF(tail)}" + } + + private def splitTuple(tuple: Type): List[Type] = + tuple.dealias match { + case TypeRef(_, _, args) => args.map(_.dealias) + case e => c.abort(c.enclosingPosition, s"Error extracting table and expr type: ${e}") + } + + private def buildSelection[F, Source](sels: List[c.Expr[Selection[F, Source, _]]]) = + sels + .map(_.asInstanceOf[c.Expr[Selection[F, Source, _ <: SelectionSet[Source]]]]) + .reduce[c.Expr[zio.sql.select.Selection[F, Source, _ <: SelectionSet[Source]]]] { case (ex1, ex2) => + reify { + ex1.splice ++ ex2.splice + } + } + + private def buildSelectionFromExpr[F, Source](exprs: List[c.Expr[ZExpr[F, Source, _]]]) = + exprs + .map(e => + reify { + zio.sql.expr.Expr.expToSelection(e.splice) + } + ) + .reduce[c.Expr[zio.sql.select.Selection[F, Source, _ <: SelectionSet[Source]]]] { case (ex1, ex2) => + reify { + ex1.splice ++ ex2.splice + } + } + + private def splitExpr(f: Type): (Type, Type, Type) = + f.dealias match { + case TypeRef(_, _, args) if args.size == 3 => (args(0), args(1), args(2)) + case e => c.abort(c.enclosingPosition, s"Error extracting table and expr type: ${e}") + } + + // Table type in subselect is the intersection type of parent table and sub table (not only subtable taken from the expr) + private def buildSelectionSetType(types: List[Type], parentTableType: Type): Tree = + types match { + case Nil => + tq"zio.sql.select.SelectionSet.Empty" + case head :: tail => + val (_, _, a) = splitExpr(head) + tq"zio.sql.select.SelectionSet.Cons[${q"${parentTableType.dealias}"}, ${q"$a"}, ${buildSelectionSetType(tail, parentTableType)}]" + } +} diff --git a/core/jvm/src/main/scala/zio/sql/select/SubselectByCommaBuilder.scala b/core/jvm/src/main/scala/zio/sql/select/SubselectByCommaBuilder.scala new file mode 100644 index 000000000..4f30d29fa --- /dev/null +++ b/core/jvm/src/main/scala/zio/sql/select/SubselectByCommaBuilder.scala @@ -0,0 +1,15 @@ +package zio.sql.select + +import zio.sql.expr.Expr +import zio.sql.select._ +import scala.language.experimental.macros + +final case class SubselectByCommaBuilder[ParentTable]() { + def apply[F, A, B <: SelectionSet[A]](selection: Selection[F, A, B]) = + SubselectBuilder[F, A, B, ParentTable](selection) + + def apply[F, Source, Set <: SelectionSet[Source]]( + exprs: Expr[F, Source, _]* + ): SubselectBuilder[F, Source, Set, ParentTable] = + macro SelectionMacro.subselectApplyMacro[F, Source, ParentTable] +} diff --git a/core/jvm/src/main/scala/zio/sql/table/Table.scala b/core/jvm/src/main/scala/zio/sql/table/Table.scala index 88452ffc7..efd9f15b7 100644 --- a/core/jvm/src/main/scala/zio/sql/table/Table.scala +++ b/core/jvm/src/main/scala/zio/sql/table/Table.scala @@ -27,7 +27,7 @@ sealed trait Table { self => final def rightOuter[That](that: Table.Aux[That]): Table.JoinBuilder[self.TableType, That] = new Table.JoinBuilder[self.TableType, That](JoinType.RightOuter, self, that) - final val subselect: SubselectPartiallyApplied[TableType] = new SubselectPartiallyApplied[TableType] + final val subselect: SubselectByCommaBuilder[TableType] = new SubselectByCommaBuilder[TableType] } object Table { @@ -80,8 +80,7 @@ object Table { schema: Schema.Record[T], tableLike: TableSchema[T] ): Table.Source.WithTableDetails[schema.Terms, T, schema.Accessors[Lens, Prism, Traversal]] = - new Table.Source { - + new Table.Source { self => protected[sql] val exprAccessorBuilder = new ExprAccessorBuilder(tableName) override protected[sql] type AllColumnIdentities = schema.Terms @@ -93,11 +92,6 @@ object Table { override val columns: ColumnsOut = schema.makeAccessors(exprAccessorBuilder) - override protected[sql] def all(implicit - helper: SelectAllHelper[ColumnsOut, TableType] - ): SelectBuilder[helper.F, TableType, helper.SelSet] = - helper.apply(columns) - override val name: String = tableName.toLowerCase() } @@ -144,10 +138,6 @@ object Table { protected[sql] type ColumnsOut val columns: ColumnsOut - - protected[sql] def all(implicit - helper: SelectAllHelper[ColumnsOut, TableType] - ): SelectBuilder[helper.F, TableType, helper.SelSet] } object Source { diff --git a/core/jvm/src/test/scala/zio/sql/ProductSchema.scala b/core/jvm/src/test/scala/zio/sql/ProductSchema.scala index dddf1283c..2c93fb539 100644 --- a/core/jvm/src/test/scala/zio/sql/ProductSchema.scala +++ b/core/jvm/src/test/scala/zio/sql/ProductSchema.scala @@ -1,7 +1,8 @@ package zio.sql -import zio.schema.Schema import java.time.LocalDate + +import zio.schema.Schema import zio.schema.DeriveSchema import zio.schema.StandardType import zio.sql.table._ @@ -12,11 +13,10 @@ import zio.sql.delete._ object ProductSchema { val sql = new Sql { self => - override def renderDelete(delete: Delete[_]): String = ??? - override def renderRead(read: Read[_]): String = ??? - override def renderUpdate(update: Update[_]): String = ??? - - override def renderInsert[A: Schema](insert: Insert[_, A]): String = ??? + override def renderDelete(delete: Delete[_]): String = ??? + override def renderRead(read: Read[_]): String = ??? + override def renderUpdate(update: Update[_]): String = ??? + override def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement = ??? } import sql._ diff --git a/core/jvm/src/test/scala/zio/sql/TestBasicSelectSpec.scala b/core/jvm/src/test/scala/zio/sql/TestBasicSelectSpec.scala index 8723b53b7..6a1846c6b 100644 --- a/core/jvm/src/test/scala/zio/sql/TestBasicSelectSpec.scala +++ b/core/jvm/src/test/scala/zio/sql/TestBasicSelectSpec.scala @@ -14,10 +14,10 @@ import zio.sql.delete._ object TestBasicSelect { val userSql = new Sql { self => - override def renderDelete(delete: Delete[_]): String = ??? - override def renderRead(read: Read[_]): String = ??? - override def renderUpdate(update: Update[_]): String = ??? - override def renderInsert[A: Schema](insert: Insert[_, A]): String = ??? + override def renderDelete(delete: Delete[_]): String = ??? + override def renderRead(read: Read[_]): String = ??? + override def renderUpdate(update: Update[_]): String = ??? + override def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement = ??? case class Users(user_id: String, dob: LocalDate, first_name: String, last_name: String) diff --git a/core/shared/src/test/scala/zio-sql/HelloWorldSpec.scala b/core/shared/src/test/scala/zio-sql/HelloWorldSpec.scala deleted file mode 100644 index 3673fdd8f..000000000 --- a/core/shared/src/test/scala/zio-sql/HelloWorldSpec.scala +++ /dev/null @@ -1,26 +0,0 @@ -package zio.sql - -import zio._ -import zio.test._ -import zio.test.Assertion._ - -import HelloWorld._ -import zio.test.ZIOSpecDefault - -object HelloWorld { - - def sayHello: ZIO[Any, Throwable, Unit] = - Console.printLine("Hello, World!") -} - -object HelloWorldSpec extends ZIOSpecDefault { - - def spec = suite("HelloWorldSpec")( - test("sayHello correctly displays output") { - for { - _ <- sayHello - output <- TestConsole.output - } yield assert(output)(equalTo(Vector("Hello, World!\n"))) - } - ) -} diff --git a/driver/src/main/scala/zio/sql/driver/Renderer.scala b/driver/src/main/scala/zio/sql/driver/Renderer.scala index db972550c..a1765e0b1 100644 --- a/driver/src/main/scala/zio/sql/driver/Renderer.scala +++ b/driver/src/main/scala/zio/sql/driver/Renderer.scala @@ -1,6 +1,6 @@ package zio.sql.driver -private[sql] class Renderer(val builder: StringBuilder) extends AnyVal { +private[sql] class Renderer(val builder: StringBuilder) { // not using vararg to avoid allocating `Seq`s def apply(s1: Any): Unit = { val _ = builder.append(s1) diff --git a/examples/src/main/scala/zio/sql/Examples.scala b/examples/src/main/scala/zio/sql/Examples.scala index 6de30718a..293351121 100644 --- a/examples/src/main/scala/zio/sql/Examples.scala +++ b/examples/src/main/scala/zio/sql/Examples.scala @@ -25,6 +25,7 @@ object Examples extends App with PostgresJdbcModule { val selectWithFunctions = select(age + 2, ConcatWs3(fName, " ", lName), Abs(-42.0)) .from(users) + .where(age === 10) .limit(10) .offset(20) .orderBy(age.descending) diff --git a/examples/src/main/scala/zio/sql/LiveExample.scala b/examples/src/main/scala/zio/sql/LiveExample.scala new file mode 100644 index 000000000..4162a4aba --- /dev/null +++ b/examples/src/main/scala/zio/sql/LiveExample.scala @@ -0,0 +1,80 @@ +package example + +import java.util.UUID +import java.time.LocalDate +import java.util.Properties + +import zio._ +import zio.schema.DeriveSchema +import zio.sql.{ ConnectionPool, ConnectionPoolConfig } +import zio.sql.postgresql.PostgresJdbcModule +import zio.sql.table._ + +/** + * + * docker run --name zio-sql-db -p 5432:5432 -e POSTGRES_DB=ziosqltest -e POSTGRES_PASSWORD=12345 -d postgres + * + * psql -h localhost -U postgres -p 5432 -d ziosqltest + * + * create table "customers" ( + * "id" uuid not null primary key, + * "age" integer not null, + * "dob" date not null, + * "first_name" varchar not null, + * "last_name" varchar not null + * ); + * + */ +object LiveExample extends ZIOAppDefault with PostgresJdbcModule { + + import Tables._ + + def run = myAppLogic + + val data = Customer(UUID.randomUUID(), 22, LocalDate.ofYearDay(1990, 1), "Ronald", "Russel") + + val stmt = insertInto(customers)( + userId, + age, + dob, + fName, + lName + ).values(data) + + val properties = { + val p = new Properties() + p.setProperty("user", "postgres") + p.setProperty("password", "12345") + p + } + + val cpConfig = + ZLayer( + ZIO.succeed( + ConnectionPoolConfig( + url = "jdbc:postgresql://localhost:5432/ziosqltest?loglevel=2", + properties = properties, + autoCommit = true + ) + ) + ) + + val myAppLogic = + execute(stmt) + .provide( + SqlDriver.live, + ConnectionPool.live, + cpConfig + ) + + object Tables { + + case class Customer(id: UUID, age: Int, dob: LocalDate, firstName: String, lastName: String) + + implicit val customerSchema = DeriveSchema.gen[Customer] + + val customers = Table.defineTable[Customer]("customers") + + val (userId, age, dob, fName, lName) = customers.columns + } +} diff --git a/examples/src/main/scala/zio/sql/OracleExamples.scala b/examples/src/main/scala/zio/sql/OracleExamples.scala new file mode 100644 index 000000000..3dbacbefa --- /dev/null +++ b/examples/src/main/scala/zio/sql/OracleExamples.scala @@ -0,0 +1,197 @@ +// package zio.sql + +// import java.util.UUID +// import java.time._ +// import zio.sql.oracle.OracleJdbcModule +// import zio.schema.DeriveSchema +// import zio.sql.expr.AggregationDef._ +// import zio.sql.expr.FunctionDef._ +// import zio.sql.table._ + +// object OracleExamples extends App with OracleJdbcModule { +// import Orders._ +// import Users._ +// import OrderDetails._ + +// val basicSelect = +// select(fName, lName).from(users) + +// println(renderRead(basicSelect)) + +// val selectAll1 = select(*).from(orderDetails) +// val selectAll2 = select(*).from(users) + +// // SELECT "users"."age" + 2, concat_ws("users"."first_name",' ',"users"."last_name"), abs(-42.0) FROM "users" ORDER BY "users"."age" DESC LIMIT 10 OFFSET 20 +// val selectWithFunctions = +// select(age + 2, ConcatWs3(fName, " ", lName), Abs(-42.0)) +// .from(users) +// .where(age === 10) +// .limit(10) +// .offset(20) +// .orderBy(age.descending) +// println(renderRead(selectWithFunctions)) + +// // SELECT "users"."first_name", "users"."last_name" FROM "users" ORDER BY "users"."last_name", "users"."first_name" DESC LIMIT 2 +// val selectWithRefinements = +// select(fName, lName) +// .from(users) +// .orderBy(lName, fName.desc) +// .limit(2) +// println(renderRead(selectWithRefinements)) + +// case class Person(fname: String, lname: String) + +// // execute(selectWithRefinements).to(Person) +// // execute(selectWithRefinements).to((_, _)) + +// // DELETE FROM "users" WHERE "users"."first_name" = 'Terrence' +// val basicDelete = +// deleteFrom(users).where(fName === "Terrence") +// println(renderDelete(basicDelete)) + +// /* +// val deleteFromWithSubquery = deleteFrom(orders).where(fkUserId in { +// select(userId as "id") from users where (fName === "Fred") //todo fix issue #36 +// }) */ + +// // SELECT "users"."first_name", "users"."last_name", "orders"."order_date" FROM "users" LEFT JOIN "orders" ON "orders"."usr_id" = "users"."id" +// val basicJoin = +// select(fName, lName, orderDate).from(users.leftOuter(orders).on(fkUserId === userId)) +// println(renderRead(basicJoin)) + +// // UPDATE "users" SET "first_name" = 'foo', "last_name" = 'bar', "age" = "users"."age" + 1 WHERE true and "users"."age" > 100 +// val basicUpdate = +// update(users) +// .set(fName, "foo") +// .set(lName, "bar") +// .set(age, age + 1) +// .where(age > 100) +// println(renderUpdate(basicUpdate)) + +// /* +// SELECT "users"."id", "users"."first_name", "users"."last_name", sum("order_details"."quantity" * "order_details"."unit_price"), sum(abs("order_details"."quantity")) +// FROM "users"x +// INNER JOIN "orders" ON "users"."id" = "orders"."usr_id" +// LEFT JOIN "order_details" ON "orders"."id" = "order_details"."order_id" +// GROUP BY "users"."id", "users"."first_name", "users"."last_name" */ +// val orderValues = +// select( +// userId, +// fName, +// lName, +// Sum(quantity * unitPrice), +// Sum(Abs(quantity)) +// ) +// .from( +// users +// .join(orders) +// .on(userId === fkUserId) +// .leftOuter(orderDetails) +// .on(orderId === fkOrderId) +// ) +// .groupBy(userId, fName, lName) +// println(renderRead(orderValues)) + +// import scala.language.postfixOps + +// // SELECT "users"."first_name", "users"."last_name" FROM "users" WHERE true and "users"."first_name" is not null +// val withPropertyOp = select(fName, lName).from(users).where(fName isNotNull) +// println(renderRead(withPropertyOp)) + +// // IN +// val subselectSurname = select(lName).from(users).where(age > 18) +// val subselectAge = select(age).from(users).where(age > 18) + +// select(fName, lName).from(users).where(lName in List("Jaro", "Peter")) + +// select(fName).from(users).where(lName in subselectSurname) +// select(fName).from(users).where(age in subselectAge) + +// /* +// insert tuples +// INSERT INTO +// users(uuid, age, date_of_birth, first_name, last_name) +// VALUES +// ('60b01fc9-c902-4468-8d49-3c0f989def37', ‘1983-01-05’, 22, 'Ronald', 'Russell') +// */ + +// val data = +// List( +// (UUID.randomUUID(), 22, LocalDate.ofYearDay(1990, 1), "Ronald1", "Russel1"), +// (UUID.randomUUID(), 32, LocalDate.ofYearDay(1980, 1), "Ronald2", "Russel2"), +// (UUID.randomUUID(), 42, LocalDate.ofYearDay(1970, 1), "Ronald3", "Russel3") +// ) +// val insertTuples = insertInto(users)(userId, age, dob, fName, lName) +// .values(data) + +// println("***************") +// println(renderInsert(insertTuples)) +// // val insertedTupleRows = execute(insertTuples) +// // println(s"$insertedTupleRows rows are inserted!") +// println("***************") + +// /* +// insert as case class with schema +// INSERT INTO +// users(uuid, age, date_of_birth, first_name, last_name) +// VALUES +// ('60b01fc9-c902-4468-8d49-3c0f989def37', ‘1983-01-05’, 22, 'Ronald', 'Russell') +// */ +// val dataSchema: Users.Users = Users.Users(UUID.randomUUID(), 22, LocalDate.ofYearDay(1990, 1), "Ronald", "Russel") + +// val insertSchema = insertInto(users)( +// userId, +// age, +// dob, +// fName, +// lName +// ).values(dataSchema) + +// println(renderInsert(insertSchema)) +// // val insertedSchemaRows = execute(insertSchema) +// // println(s"$insertedSchemaRows rows are inserted!") + +// /* SELECT "users"."user_id" FROM "users" +// UNION +// SELECT "orders"."usr_id" FROM "orders" +// */ +// val selectWithUnion = select(userId).from(users).union(select(fkUserId).from(orders)) + +// /* SELECT "users"."user_id" FROM "users" +// UNION ALL +// SELECT "orders"."usr_id" FROM "orders" +// */ +// val selectWithUnionAll = select(userId).from(users).unionAll(select(fkUserId).from(orders)) + +// object Users { + +// case class Users(id: UUID, age: Int, dob: LocalDate, firstName: String, lastName: String) + +// implicit val userSchema = DeriveSchema.gen[Users] + +// val users = Table.defineTable[Users] + +// val (userId, age, dob, fName, lName) = users.columns +// } + +// object Orders { + +// case class Orders(id: java.util.UUID, userId: java.util.UUID, orderDate: LocalDate) + +// implicit val orderSchema = DeriveSchema.gen[Orders] + +// val orders = Table.defineTable[Orders] + +// val (orderId, fkUserId, orderDate) = orders.columns +// } + +// object OrderDetails { +// case class OrderDetail(orderId: java.util.UUID, productId: Int, quantity: Double, unitPrice: Double) + +// implicit val orderDetailSchema = DeriveSchema.gen[OrderDetail] + +// val orderDetails = Table.defineTable[OrderDetail] + +// val (fkOrderId, fkProductId, quantity, unitPrice) = orderDetails.columns +// } +// } diff --git a/jdbc/src/main/scala/zio/sql/JdbcInternalModule.scala b/jdbc/src/main/scala/zio/sql/JdbcInternalModule.scala index ff3074a03..c07d1ab37 100644 --- a/jdbc/src/main/scala/zio/sql/JdbcInternalModule.scala +++ b/jdbc/src/main/scala/zio/sql/JdbcInternalModule.scala @@ -27,6 +27,7 @@ trait JdbcInternalModule { self: Jdbc => else try { val value = decoder + if (resultSet.wasNull()) return Right(null.asInstanceOf[A]) value match { case Some(value) => Right(value) diff --git a/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala b/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala index 2db3dfdf6..af6563645 100644 --- a/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala +++ b/jdbc/src/main/scala/zio/sql/SqlDriverLiveModule.scala @@ -1,6 +1,6 @@ package zio.sql -import java.sql._ +import java.sql.{ Connection, SQLException } import zio._ import zio.stream.{ Stream, ZStream } @@ -18,8 +18,6 @@ trait SqlDriverLiveModule { self: Jdbc => def updateOnBatch(update: List[Update[_]], conn: Connection): IO[Exception, List[Int]] - def insertOnBatch[A: Schema](insert: List[Insert[_, A]], conn: Connection): IO[Exception, List[Int]] - def deleteOn(delete: Delete[_], conn: Connection): IO[Exception, Int] def updateOn(update: Update[_], conn: Connection): IO[Exception, Int] @@ -113,26 +111,19 @@ trait SqlDriverLiveModule { self: Jdbc => override def insertOn[A: Schema](insert: Insert[_, A], conn: Connection): IO[Exception, Int] = ZIO.attemptBlocking { - val query = renderInsert(insert) + val SqlStatement(query, params) = renderInsert(insert) - val statement = conn.createStatement() + val ps = conn.prepareStatement(query) - statement.executeUpdate(query) - }.refineToOrDie[Exception] + setParams(params)(ps) + + ps.executeBatch().foldLeft(0) { case (acc, el) => acc + el } - override def insertOnBatch[A: Schema](insert: List[Insert[_, A]], conn: Connection): IO[Exception, List[Int]] = - ZIO.attemptBlocking { - val statement = conn.createStatement() - insert.map(insert_ => statement.addBatch(renderInsert(insert_))) - statement.executeBatch().toList }.refineToOrDie[Exception] override def insert[A: Schema](insert: Insert[_, A]): IO[Exception, Int] = ZIO.scoped(pool.connection.flatMap(insertOn(insert, _))) - def insert[A: Schema](insert: List[Insert[_, A]]): IO[Exception, List[Int]] = - ZIO.scoped(pool.connection.flatMap(insertOnBatch(insert, _))) - override def transaction: ZLayer[Any, Exception, SqlTransaction] = ZLayer.scoped { for { diff --git a/jdbc/src/main/scala/zio/sql/jdbc.scala b/jdbc/src/main/scala/zio/sql/jdbc.scala index 575d04e36..eb1674a93 100644 --- a/jdbc/src/main/scala/zio/sql/jdbc.scala +++ b/jdbc/src/main/scala/zio/sql/jdbc.scala @@ -23,8 +23,6 @@ trait Jdbc extends Sql with JdbcInternalModule with SqlDriverLiveModule with Tra def insert[A: Schema](insert: Insert[_, A]): IO[Exception, Int] - def insert[A: Schema](insert: List[Insert[_, A]]): IO[Exception, List[Int]] - def transaction: ZLayer[Any, Exception, SqlTransaction] } object SqlDriver { @@ -45,6 +43,17 @@ trait Jdbc extends Sql with JdbcInternalModule with SqlDriverLiveModule with Tra } + def setParam(param: SqlParameter, jdbcIndex: Int): java.sql.PreparedStatement => Unit + + private[sql] def setParams(rows: List[SqlRow]): java.sql.PreparedStatement => Unit = ps => + rows.foreach { row => + row.params.zipWithIndex.foreach { case (param, i) => + val jdbcIndex = i + 1 + setParam(param, jdbcIndex)(ps) + } + ps.addBatch() + } + def execute[A](read: Read[A]): ZStream[SqlDriver, Exception, A] = ZStream.serviceWithStream(_.read(read)) @@ -62,9 +71,6 @@ trait Jdbc extends Sql with JdbcInternalModule with SqlDriverLiveModule with Tra def execute[A: Schema](insert: Insert[_, A]): ZIO[SqlDriver, Exception, Int] = ZIO.serviceWithZIO(_.insert(insert)) - def executeBatchInsert[A: Schema](insert: List[Insert[_, A]]): ZIO[SqlDriver, Exception, List[Int]] = - ZIO.serviceWithZIO(_.insert(insert)) - def execute(update: Update[_]): ZIO[SqlDriver, Exception, Int] = ZIO.serviceWithZIO(_.update(update)) @@ -73,4 +79,5 @@ trait Jdbc extends Sql with JdbcInternalModule with SqlDriverLiveModule with Tra val transact: ZLayer[SqlDriver, Exception, SqlTransaction] = ZLayer(ZIO.serviceWith[SqlDriver](_.transaction)).flatten + } diff --git a/macros/src/main/scala-2/zio/sql/macros/insertlike.scala b/macros/src/main/scala-2/zio/sql/macros/insertlike.scala index 8b510afdb..b8ead35c8 100644 --- a/macros/src/main/scala-2/zio/sql/macros/insertlike.scala +++ b/macros/src/main/scala-2/zio/sql/macros/insertlike.scala @@ -26,7 +26,7 @@ object InsertLike { F, ColsRepr, AllColumnIdentities, - Z, + Z ] = macro createInsertLikeImpl[F, ColsRepr, AllColumnIdentities, Z] def createInsertLikeImpl[ diff --git a/macros/src/main/scala-3/zio/sql/macros/groupbylike.scala b/macros/src/main/scala-3/zio/sql/macros/groupbylike.scala index e6d4d65ce..4e02cbced 100644 --- a/macros/src/main/scala-3/zio/sql/macros/groupbylike.scala +++ b/macros/src/main/scala-3/zio/sql/macros/groupbylike.scala @@ -1,11 +1,10 @@ package zio.sql.macros - sealed trait GroupByLike[All, Grouped] object GroupByLike { - final case class CanBeGrouped[All, Grouped]() extends GroupByLike[All, Grouped] + final case class CanBeGrouped[All, Grouped]() extends GroupByLike[All, Grouped] - implicit def createGroupByLike[All, Grouped]: GroupByLike[All, Grouped] = CanBeGrouped[All, Grouped]() -} \ No newline at end of file + implicit def createGroupByLike[All, Grouped]: GroupByLike[All, Grouped] = CanBeGrouped[All, Grouped]() +} diff --git a/macros/src/main/scala-3/zio/sql/macros/havinglike.scala b/macros/src/main/scala-3/zio/sql/macros/havinglike.scala index d3d410889..c8cf4e8b1 100644 --- a/macros/src/main/scala-3/zio/sql/macros/havinglike.scala +++ b/macros/src/main/scala-3/zio/sql/macros/havinglike.scala @@ -1,4 +1,4 @@ -package zio.sql.macros +package zio.sql.macros sealed trait HavingIsSound[AllF, GroupByF, HavingF] @@ -6,6 +6,7 @@ object HavingIsSound { final case class HavingCanBeCalled[AllF, GroupByF, HavingF]() extends HavingIsSound[AllF, GroupByF, HavingF] - implicit def materializeHavingIsSound[AllF, GroupByF, HavingF]: HavingIsSound[AllF, GroupByF, HavingF] = HavingCanBeCalled[AllF, GroupByF, HavingF]() + implicit def materializeHavingIsSound[AllF, GroupByF, HavingF]: HavingIsSound[AllF, GroupByF, HavingF] = + HavingCanBeCalled[AllF, GroupByF, HavingF]() -} \ No newline at end of file +} diff --git a/macros/src/main/scala-3/zio/sql/macros/insertlike.scala b/macros/src/main/scala-3/zio/sql/macros/insertlike.scala index f8795952a..eff5ca575 100644 --- a/macros/src/main/scala-3/zio/sql/macros/insertlike.scala +++ b/macros/src/main/scala-3/zio/sql/macros/insertlike.scala @@ -16,6 +16,6 @@ object InsertLike { F, ColsRepr, AllColumnIdentities, - Z, + Z ] = CanBeInserted[F, ColsRepr, AllColumnIdentities, Z]() } diff --git a/macros/src/main/scala-3/zio/sql/macros/normalizer.scala b/macros/src/main/scala-3/zio/sql/macros/normalizer.scala index a0390a141..3b30d3be1 100644 --- a/macros/src/main/scala-3/zio/sql/macros/normalizer.scala +++ b/macros/src/main/scala-3/zio/sql/macros/normalizer.scala @@ -13,8 +13,7 @@ object Normalizer { // override type Out = Out2 // } - implicit def createNormalizer[In]: Normalizer[In] = { + implicit def createNormalizer[In]: Normalizer[In] = new Normalizer[In] {} - } } diff --git a/macros/src/main/scala-3/zio/sql/macros/notliteral.scala b/macros/src/main/scala-3/zio/sql/macros/notliteral.scala index 4d7bc1197..219b881ef 100644 --- a/macros/src/main/scala-3/zio/sql/macros/notliteral.scala +++ b/macros/src/main/scala-3/zio/sql/macros/notliteral.scala @@ -1,12 +1,11 @@ -package zio.sql.macros +package zio.sql.macros sealed trait IsNotLiteral[F] object IsNotLiteral { - final case class FIsNotLiteral[F]() extends IsNotLiteral[F] + final case class FIsNotLiteral[F]() extends IsNotLiteral[F] - implicit def materializeIsNotLiteral[F]: IsNotLiteral[F] = { - FIsNotLiteral[F]() - } -} \ No newline at end of file + implicit def materializeIsNotLiteral[F]: IsNotLiteral[F] = + FIsNotLiteral[F]() +} diff --git a/macros/src/main/scala-3/zio/sql/macros/tablelike.scala b/macros/src/main/scala-3/zio/sql/macros/tablelike.scala index 881bb52de..3d9a05ed9 100644 --- a/macros/src/main/scala-3/zio/sql/macros/tablelike.scala +++ b/macros/src/main/scala-3/zio/sql/macros/tablelike.scala @@ -6,7 +6,6 @@ object TableSchema { final case class Compatible[T]() extends TableSchema[T] - implicit def materializeTableSchema[T]: TableSchema[T] = Compatible[T]() -} \ No newline at end of file +} diff --git a/macros/src/main/scala-3/zio/sql/macros/wherelike.scala b/macros/src/main/scala-3/zio/sql/macros/wherelike.scala index c6ce1fc3c..474b5aae4 100644 --- a/macros/src/main/scala-3/zio/sql/macros/wherelike.scala +++ b/macros/src/main/scala-3/zio/sql/macros/wherelike.scala @@ -1,10 +1,10 @@ -package zio.sql.macros +package zio.sql.macros sealed trait WhereIsSound[WhereF, GroupByF] object WhereIsSound { final case class WhereCanBeCalled[WhereF, GroupByF]() extends WhereIsSound[WhereF, GroupByF] - implicit def materializeWhereIsSound[WhereF, GroupByF]: WhereIsSound[WhereF, GroupByF] = + implicit def materializeWhereIsSound[WhereF, GroupByF]: WhereIsSound[WhereF, GroupByF] = WhereCanBeCalled[WhereF, GroupByF]() -} \ No newline at end of file +} diff --git a/mysql/project/build.properties b/mysql/project/build.properties index 46e43a97e..72413de15 100644 --- a/mysql/project/build.properties +++ b/mysql/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.8.3 diff --git a/mysql/src/main/scala/zio/sql/mysql/MysqlJdbcModule.scala b/mysql/src/main/scala/zio/sql/mysql/MysqlJdbcModule.scala index 73de71523..076f67e54 100644 --- a/mysql/src/main/scala/zio/sql/mysql/MysqlJdbcModule.scala +++ b/mysql/src/main/scala/zio/sql/mysql/MysqlJdbcModule.scala @@ -1,5 +1,47 @@ package zio.sql.mysql -import zio.sql.Jdbc +import java.sql.Timestamp +import java.time._ +import java.util.UUID -trait MysqlJdbcModule extends MysqlRenderModule with Jdbc +import zio.schema.StandardType._ +import zio.sql.{ Jdbc, SqlParameter } + +trait MysqlJdbcModule extends MysqlRenderModule with Jdbc { + + override def setParam(param: SqlParameter, jdbcIndex: Int): java.sql.PreparedStatement => Unit = ps => + param._type match { + case BigDecimalType => ps.setBigDecimal(jdbcIndex, param.value.asInstanceOf[java.math.BigDecimal]) + case InstantType => ps.setTimestamp(jdbcIndex, Timestamp.from(param.value.asInstanceOf[Instant])) + case ByteType => ps.setByte(jdbcIndex, param.value.asInstanceOf[Byte]) + case CharType => ps.setString(jdbcIndex, String.valueOf(param.value.asInstanceOf[Char])) + case IntType => ps.setInt(jdbcIndex, param.value.asInstanceOf[Int]) + case MonthDayType => ps.setString(jdbcIndex, param.value.toString()) + case BinaryType => ps.setString(jdbcIndex, param.value.toString()) + case MonthType => ps.setString(jdbcIndex, param.value.toString()) + case LocalDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDateTime]) + case UnitType => ps.setObject(jdbcIndex, null) + case YearMonthType => ps.setString(jdbcIndex, param.value.toString()) + case DoubleType => ps.setDouble(jdbcIndex, param.value.asInstanceOf[Double]) + case YearType => ps.setString(jdbcIndex, param.value.toString()) + case OffsetDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetDateTime]) + case ZonedDateTimeType => + ps.setObject(jdbcIndex, Timestamp.from(param.value.asInstanceOf[ZonedDateTime].toInstant)) + case BigIntegerType => ps.setLong(jdbcIndex, param.value.asInstanceOf[BigInt].longValue) + case UUIDType => ps.setString(jdbcIndex, param.value.asInstanceOf[UUID].toString()) + case ZoneOffsetType => ps.setString(jdbcIndex, param.value.toString()) + case ShortType => ps.setShort(jdbcIndex, param.value.asInstanceOf[Short]) + case LocalTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalTime]) + case OffsetTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetTime]) + case LongType => ps.setLong(jdbcIndex, param.value.asInstanceOf[Long]) + case StringType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case PeriodType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case ZoneIdType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case LocalDateType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDate]) + case BoolType => ps.setBoolean(jdbcIndex, param.value.asInstanceOf[Boolean]) + case DayOfWeekType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case FloatType => ps.setFloat(jdbcIndex, param.value.asInstanceOf[Float]) + case DurationType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + } + +} diff --git a/mysql/src/main/scala/zio/sql/mysql/MysqlRenderModule.scala b/mysql/src/main/scala/zio/sql/mysql/MysqlRenderModule.scala index e3ce7df97..353a682dd 100644 --- a/mysql/src/main/scala/zio/sql/mysql/MysqlRenderModule.scala +++ b/mysql/src/main/scala/zio/sql/mysql/MysqlRenderModule.scala @@ -1,11 +1,8 @@ package zio.sql.mysql -import java.time._ -import java.time.format.DateTimeFormatter -import java.time.format.DateTimeFormatter._ import zio.Chunk import zio.schema._ -import zio.schema.StandardType._ +import zio.sql.{ SqlParameter, SqlRow, SqlStatement } import zio.sql.driver.Renderer import zio.sql.update._ import zio.sql.select._ @@ -23,10 +20,10 @@ trait MysqlRenderModule extends MysqlSqlModule { self => render.toString } - override def renderInsert[A: Schema](insert: Insert[_, A]): String = { + override def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement = { implicit val render: Renderer = Renderer() - MysqlRenderer.renderInsertImpl(insert) - render.toString + val rows = MysqlRenderer.renderInsertImpl(insert) + SqlStatement(render.toString, rows) } override def renderDelete(delete: Delete[_]): String = { @@ -42,7 +39,7 @@ trait MysqlRenderModule extends MysqlSqlModule { self => } object MysqlRenderer { - def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]) = { + def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]): List[SqlRow] = { render("INSERT INTO ") renderTable(insert.table) @@ -50,7 +47,9 @@ trait MysqlRenderModule extends MysqlSqlModule { self => renderColumnNames(insert.sources) render(") VALUES ") - renderInsertValues(insert.values) + renderInsertPlaceholders(insert.values) + + buildInsertList(insert.values) } def renderDeleteImpl(delete: Delete[_])(implicit render: Renderer) = { @@ -129,98 +128,88 @@ trait MysqlRenderModule extends MysqlSqlModule { self => render(" (", values.mkString(","), ") ") // todo fix needs escaping } - private def renderInsertValues[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = + private def buildInsertList[A](col: Seq[A])(implicit schema: Schema[A]): List[SqlRow] = + col.foldLeft(List.empty[SqlRow]) { case (a, z) => + val row = schema.toDynamic(z) match { + case DynamicValue.Record(_, listMap) => + val params = listMap.values.foldLeft(List.empty[SqlParameter]) { case (acc, el) => + acc ::: buildInsertRow(el) + } + SqlRow(params) + case value => + SqlRow(buildInsertRow(value)) + } + row :: a + } + + private def buildInsertRow(dynValue: DynamicValue): List[SqlParameter] = + dynValue match { + case DynamicValue.Primitive(value, typeTag) => + // need to do this since StandardType is invariant in A + StandardType.fromString(typeTag.tag) match { + case Some(v) => + List(SqlParameter(v, value)) + case None => Nil + } + case DynamicValue.Tuple(left, right) => + buildInsertRow(left) ::: buildInsertRow(right) + case DynamicValue.SomeValue(value) => buildInsertRow(value) + case DynamicValue.NoneValue => + List(SqlParameter(StandardType.UnitType, null)) + case DynamicValue.Sequence(chunk) => + val bytes = chunk.map { + case DynamicValue.Primitive(v, t) if t == StandardType.ByteType => + v.asInstanceOf[Byte] + case _ => throw new IllegalArgumentException("Only Byte sequences are supported.") + }.toArray + List(SqlParameter(StandardType.BinaryType, bytes)) + case _ => Nil + } + + private def renderInsertPlaceholders[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = col.toList match { - case head :: Nil => + case head :: _ => render("(") - renderInsertValue(head) + renderInsertPlaceholder(head) render(");") - case head :: next => - render("(") - renderInsertValue(head)(render, schema) - render(" ),") - renderInsertValues(next) - case Nil => () + case Nil => () } - private def renderInsertValue[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = + private def renderInsertPlaceholder[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = schema.toDynamic(z) match { case DynamicValue.Record(_, listMap) => listMap.values.toList match { - case head :: Nil => renderDynamicValue(head) + case head :: Nil => renderPlaceholder(head) case head :: next => - renderDynamicValue(head) + renderPlaceholder(head) render(", ") - renderDynamicValues(next) + renderPlaceholders(next) case Nil => () } - case value => renderDynamicValue(value) + case value => renderPlaceholder(value) } - private def renderDynamicValues(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = + private def renderPlaceholders(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = dynValues match { - case head :: Nil => renderDynamicValue(head) + case head :: Nil => renderPlaceholder(head) case head :: tail => - renderDynamicValue(head) + renderPlaceholder(head) render(", ") - renderDynamicValues(tail) + renderPlaceholders(tail) case Nil => () } - def renderDynamicValue(dynValue: DynamicValue)(implicit render: Renderer): Unit = + def renderPlaceholder(dynValue: DynamicValue)(implicit render: Renderer): Unit = dynValue match { - case DynamicValue.Primitive(value, typeTag) => - StandardType.fromString(typeTag.tag) match { - case Some(v) => - v match { - case BigDecimalType => - render(value) - case StandardType.InstantType => - render(s"'${ISO_INSTANT.format(value.asInstanceOf[Instant])}'") - case ByteType => render(s"'${value}'") - case CharType => render(s"'${value}'") - case IntType => render(value) - case StandardType.MonthDayType => render(s"'${value}'") - case BinaryType => render(s"'${value}'") - case StandardType.MonthType => render(s"'${value}'") - case StandardType.LocalDateTimeType => - render(s"'${ISO_LOCAL_DATE_TIME.format(value.asInstanceOf[LocalDateTime])}'") - case UnitType => render("null") // None is encoded as Schema[Unit].transform(_ => None, _ => ()) - case StandardType.YearMonthType => render(s"'${value}'") - case DoubleType => render(value) - case StandardType.YearType => render(s"'${value}'") - case StandardType.OffsetDateTimeType => - render(s"'${ISO_OFFSET_DATE_TIME.format(value.asInstanceOf[OffsetDateTime])}'") - case StandardType.ZonedDateTimeType => - render(s"'${DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value.asInstanceOf[ZonedDateTime])}'") - case BigIntegerType => render(s"'${value}'") - case UUIDType => render(s"'${value}'") - case StandardType.ZoneOffsetType => render(s"'${value}'") - case ShortType => render(value) - case StandardType.LocalTimeType => - render(s"'${ISO_LOCAL_TIME.format(value.asInstanceOf[LocalTime])}'") - case StandardType.OffsetTimeType => - render(s"'${ISO_OFFSET_TIME.format(value.asInstanceOf[OffsetTime])}'") - case LongType => render(value) - case StringType => render(s"'${value}'") - case StandardType.PeriodType => render(s"'${value}'") - case StandardType.ZoneIdType => render(s"'${value}'") - case StandardType.LocalDateType => - render(s"'${ISO_LOCAL_DATE.format(value.asInstanceOf[LocalDate])}'") - case BoolType => render(value) - case DayOfWeekType => render(s"'${value}'") - case FloatType => render(value) - case StandardType.DurationType => render(s"'${value}'") - } - case None => () - } - case DynamicValue.Tuple(left, right) => - renderDynamicValue(left) + case DynamicValue.Primitive(_, _) => render("?") + case DynamicValue.Tuple(left, right) => + renderPlaceholder(left) render(", ") - renderDynamicValue(right) - case DynamicValue.SomeValue(value) => renderDynamicValue(value) - case DynamicValue.NoneValue => render("null") - case _ => () + renderPlaceholder(right) + case DynamicValue.SomeValue(value) => renderPlaceholder(value) + case DynamicValue.NoneValue => render("?") + case DynamicValue.Sequence(_) => render("?") + case _ => () } private def renderColumnNames(sources: SelectionSet[_])(implicit render: Renderer): Unit = diff --git a/oracle/src/main/scala/zio/sql/oracle/OracleJdbcModule.scala b/oracle/src/main/scala/zio/sql/oracle/OracleJdbcModule.scala index c5c6c319f..e957a6c32 100644 --- a/oracle/src/main/scala/zio/sql/oracle/OracleJdbcModule.scala +++ b/oracle/src/main/scala/zio/sql/oracle/OracleJdbcModule.scala @@ -1,5 +1,49 @@ package zio.sql.oracle -import zio.sql.Jdbc +import java.sql.Timestamp +import java.time._ +import java.util.UUID -trait OracleJdbcModule extends OracleRenderModule with Jdbc +import zio.schema.StandardType._ +import zio.sql.{ Jdbc, SqlParameter } + +trait OracleJdbcModule extends OracleRenderModule with Jdbc { + + override def setParam(param: SqlParameter, jdbcIndex: Int): java.sql.PreparedStatement => Unit = ps => + param._type match { + case BigDecimalType => ps.setBigDecimal(jdbcIndex, param.value.asInstanceOf[java.math.BigDecimal]) + case InstantType => ps.setTimestamp(jdbcIndex, Timestamp.from(param.value.asInstanceOf[Instant])) + case ByteType => ps.setByte(jdbcIndex, param.value.asInstanceOf[Byte]) + case CharType => ps.setString(jdbcIndex, String.valueOf(param.value.asInstanceOf[Char])) + case IntType => ps.setInt(jdbcIndex, param.value.asInstanceOf[Int]) + case MonthDayType => ps.setString(jdbcIndex, param.value.toString()) + case BinaryType => ps.setString(jdbcIndex, param.value.toString()) + case MonthType => ps.setString(jdbcIndex, param.value.toString()) + case LocalDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDateTime]) + case UnitType => ps.setObject(jdbcIndex, null) + case YearMonthType => ps.setString(jdbcIndex, param.value.toString()) + case DoubleType => ps.setDouble(jdbcIndex, param.value.asInstanceOf[Double]) + case YearType => ps.setString(jdbcIndex, param.value.toString()) + case OffsetDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetDateTime]) + case ZonedDateTimeType => + ps.setObject(jdbcIndex, Timestamp.from(param.value.asInstanceOf[ZonedDateTime].toInstant)) + case BigIntegerType => ps.setLong(jdbcIndex, param.value.asInstanceOf[BigInt].longValue) + + // Oracle doesn't natively support UUID + case UUIDType => ps.setString(jdbcIndex, param.value.asInstanceOf[UUID].toString()) + case ZoneOffsetType => ps.setString(jdbcIndex, param.value.toString()) + case ShortType => ps.setShort(jdbcIndex, param.value.asInstanceOf[Short]) + case LocalTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalTime]) + case OffsetTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetTime]) + case LongType => ps.setLong(jdbcIndex, param.value.asInstanceOf[Long]) + case StringType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case PeriodType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case ZoneIdType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case LocalDateType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDate]) + case BoolType => ps.setBoolean(jdbcIndex, param.value.asInstanceOf[Boolean]) + case DayOfWeekType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case FloatType => ps.setFloat(jdbcIndex, param.value.asInstanceOf[Float]) + case DurationType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + } + +} diff --git a/oracle/src/main/scala/zio/sql/oracle/OracleRenderModule.scala b/oracle/src/main/scala/zio/sql/oracle/OracleRenderModule.scala index 210abef2c..bc9d2ab33 100644 --- a/oracle/src/main/scala/zio/sql/oracle/OracleRenderModule.scala +++ b/oracle/src/main/scala/zio/sql/oracle/OracleRenderModule.scala @@ -1,32 +1,24 @@ package zio.sql.oracle +import java.time._ +import java.time.format.{ DateTimeFormatter, DateTimeFormatterBuilder } +import java.time.temporal.ChronoField._ + import zio.schema.Schema import zio.schema.DynamicValue import zio.schema.StandardType - -import java.time.Instant -import java.time.LocalDate -import java.time.LocalDateTime -import java.time.LocalTime -import java.time.OffsetTime -import java.time.ZonedDateTime -import zio.sql.driver.Renderer -import zio.Chunk -import java.time.format.DateTimeFormatter._ -import scala.collection.mutable -import java.time.OffsetDateTime -import java.time.YearMonth -import java.time.Duration -import java.time.format.{ DateTimeFormatter, DateTimeFormatterBuilder } -import java.time.temporal.ChronoField._ -import zio.sql.update._ -import zio.sql.select._ -import zio.sql.insert._ +import zio.sql.{ SqlParameter, SqlRow, SqlStatement } import zio.sql.delete._ +import zio.sql.driver.Renderer import zio.sql.expr._ +import zio.sql.insert._ +import zio.sql.ops.Operator._ +import zio.sql.select._ import zio.sql.table._ import zio.sql.typetag._ -import zio.sql.ops.Operator._ +import zio.sql.update._ + +import scala.collection.mutable trait OracleRenderModule extends OracleSqlModule { self => @@ -36,10 +28,10 @@ trait OracleRenderModule extends OracleSqlModule { self => builder.toString } - override def renderInsert[A: Schema](insert: Insert[_, A]): String = { - val builder = new StringBuilder - buildInsertString(insert, builder) - builder.toString() + override def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement = { + implicit val render: Renderer = Renderer() + val rows = OracleRender.renderInsertImpl(insert) + SqlStatement(render.toString, rows) } override def renderRead(read: Read[_]): String = { @@ -366,19 +358,7 @@ trait OracleRenderModule extends OracleSqlModule { self => val _ = builder.append(" (").append(values.mkString(",")).append(") ") // todo fix needs escaping } - private def buildInsertString[A: Schema](insert: Insert[_, A], builder: StringBuilder): Unit = { - - builder.append("INSERT INTO ") - renderTable(insert.table, builder) - - builder.append(" (") - renderColumnNames(insert.sources, builder) - builder.append(") ") - - renderInsertValues(insert.values, builder) - } - - private def renderTable(table: Table, builder: StringBuilder): Unit = table match { + private def renderTable(table: Table, builder: StringBuilder): Unit = table match { case Table.DerivedTable(read, name) => builder.append(" ( ") builder.append(renderRead(read.asInstanceOf[Read[_]])) @@ -404,184 +384,6 @@ trait OracleRenderModule extends OracleSqlModule { self => builder.append(source.name) () } - private def renderColumnNames(sources: SelectionSet[_], builder: StringBuilder): Unit = - sources match { - case SelectionSet.Empty => () // table is a collection of at least ONE column - case SelectionSet.Cons(columnSelection, tail) => - val _ = columnSelection.name.map { name => - builder.append(name) - } - tail.asInstanceOf[SelectionSet[_]] match { - case SelectionSet.Empty => () - case next @ SelectionSet.Cons(_, _) => - builder.append(", ") - renderColumnNames(next.asInstanceOf[SelectionSet[_]], builder) - } - } - private def renderInsertValues[A](values: Seq[A], builder: StringBuilder)(implicit schema: Schema[A]): Unit = - values.toList match { - case head :: Nil => - builder.append("SELECT ") - renderInsertValue(head, builder) - builder.append(" FROM DUAL") - () - case head :: next => - builder.append("SELECT ") - renderInsertValue(head, builder) - builder.append(" FROM DUAL UNION ALL ") - renderInsertValues(next, builder) - case Nil => () - } - - def renderInsertValue[Z](z: Z, builder: StringBuilder)(implicit schema: Schema[Z]): Unit = - schema.toDynamic(z) match { - case DynamicValue.Record(_, listMap) => - listMap.values.toList match { - case head :: Nil => renderDynamicValue(head, builder) - case head :: next => - renderDynamicValue(head, builder) - builder.append(", ") - renderDynamicValues(next, builder) - case Nil => () - } - case value => renderDynamicValue(value, builder) - } - - def renderDynamicValue(dynValue: DynamicValue, builder: StringBuilder): Unit = - dynValue match { - case DynamicValue.Primitive(value, typeTag) => - // need to do this since StandardType is invariant in A - import StandardType._ - StandardType.fromString(typeTag.tag) match { - case Some(v) => - v match { - case BigDecimalType => - builder.append(value) - () - case StandardType.InstantType => - builder.append( - s"""TO_TIMESTAMP_TZ('${ISO_INSTANT.format( - value.asInstanceOf[Instant] - )}', 'SYYYY-MM-DD"T"HH24:MI:SS.FF9TZH:TZM')""" - ) - () - case CharType => - builder.append(s"'${value}'") - () - case IntType => - builder.append(value) - () - case BinaryType => - val chunk = value.asInstanceOf[Chunk[Object]] - builder.append("'") - for (b <- chunk) - builder.append("%02x".format(b)) - builder.append("'") - () - case StandardType.LocalDateTimeType => - builder.append( - s"""TO_TIMESTAMP('${ISO_LOCAL_DATE_TIME.format( - value.asInstanceOf[LocalDateTime] - )}', 'SYYYY-MM-DD"T"HH24:MI:SS.FF9')""" - ) - () - case StandardType.YearMonthType => - val yearMonth = value.asInstanceOf[YearMonth] - builder.append(s"INTERVAL '${yearMonth.getYear}-${yearMonth.getMonth.getValue}' YEAR(4) TO MONTH") - () - case DoubleType => - builder.append(value) - () - case StandardType.OffsetDateTimeType => - builder.append( - s"""TO_TIMESTAMP_TZ('${ISO_OFFSET_DATE_TIME.format( - value.asInstanceOf[OffsetDateTime] - )}', 'SYYYY-MM-DD"T"HH24:MI:SS.FF9TZH:TZM')""" - ) - () - case StandardType.ZonedDateTimeType => - builder.append( - s"""TO_TIMESTAMP_TZ('${ISO_ZONED_DATE_TIME.format( - value.asInstanceOf[ZonedDateTime] - )}', 'SYYYY-MM-DD"T"HH24:MI:SS.FF9 TZR')""" - ) - () - case UUIDType => - builder.append(s"'${value}'") - () - case ShortType => - builder.append(value) - () - case StandardType.LocalTimeType => - val localTime = value.asInstanceOf[LocalTime] - builder.append( - s"INTERVAL '${localTime.getHour}:${localTime.getMinute}:${localTime.getSecond}.${localTime.getNano}' HOUR TO SECOND(9)" - ) - () - case StandardType.OffsetTimeType => - builder.append( - s"TO_TIMESTAMP_TZ('${ISO_OFFSET_TIME.format(value.asInstanceOf[OffsetTime])}', 'HH24:MI:SS.FF9TZH:TZM')" - ) - () - case LongType => - builder.append(value) - () - case StringType => - builder.append(s"'${value}'") - () - case StandardType.LocalDateType => - builder.append(s"DATE '${ISO_LOCAL_DATE.format(value.asInstanceOf[LocalDate])}'") - () - case BoolType => - val b = value.asInstanceOf[Boolean] - if (b) { - builder.append('1') - } else { - builder.append('0') - } - () - case FloatType => - builder.append(value) - () - case StandardType.DurationType => - val duration = value.asInstanceOf[Duration] - val days = duration.toDays() - val hours = duration.toHours() % 24 - val minutes = duration.toMinutes() % 60 - val seconds = duration.getSeconds % 60 - val nanos = duration.getNano - builder.append(s"INTERVAL '$days $hours:$minutes:$seconds.$nanos' DAY(9) TO SECOND(9)") - () - case _ => - throw new IllegalStateException("unsupported") - } - case None => () - } - case DynamicValue.Tuple(left, right) => - renderDynamicValue(left, builder) - builder.append(", ") - renderDynamicValue(right, builder) - case DynamicValue.SomeValue(value) => renderDynamicValue(value, builder) - case DynamicValue.NoneValue => - builder.append("null") - () - case DynamicValue.Sequence(chunk) => - builder.append("'") - for (DynamicValue.Primitive(v, _) <- chunk) - builder.append("%02x".format(v)) - val _ = builder.append("'") - case _ => () - } - - def renderDynamicValues(dynValues: List[DynamicValue], builder: StringBuilder): Unit = - dynValues match { - case head :: Nil => renderDynamicValue(head, builder) - case head :: tail => - renderDynamicValue(head, builder) - builder.append(", ") - renderDynamicValues(tail, builder) - case Nil => () - } private def buildExprList(expr: Read.ExprSet[_], builder: StringBuilder): Unit = expr match { @@ -685,6 +487,120 @@ trait OracleRenderModule extends OracleSqlModule { self => private[oracle] object OracleRender { + def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]): List[SqlRow] = { + + render("INSERT INTO ") + renderTable(insert.table, render.builder) + + render(" (") + renderColumnNames(insert.sources) + render(") VALUES ") + + renderInsertPlaceholders(insert.values) + + buildInsertList(insert.values) + } + + private def buildInsertList[A](col: Seq[A])(implicit schema: Schema[A]): List[SqlRow] = + col.foldLeft(List.empty[SqlRow]) { case (a, z) => + val row = schema.toDynamic(z) match { + case DynamicValue.Record(_, listMap) => + val params = listMap.values.foldLeft(List.empty[SqlParameter]) { case (acc, el) => + acc ::: buildInsertRow(el) + } + SqlRow(params) + case value => + SqlRow(buildInsertRow(value)) + } + row :: a + } + + private def buildInsertRow(dynValue: DynamicValue): List[SqlParameter] = + dynValue match { + case DynamicValue.Primitive(value, typeTag) => + // need to do this since StandardType is invariant in A + StandardType.fromString(typeTag.tag) match { + case Some(v) => + List(SqlParameter(v, value)) + case None => Nil + } + case DynamicValue.Tuple(left, right) => + buildInsertRow(left) ::: buildInsertRow(right) + case DynamicValue.SomeValue(value) => buildInsertRow(value) + case DynamicValue.NoneValue => + List(SqlParameter(StandardType.UnitType, null)) + case DynamicValue.Sequence(chunk) => + val bytes = chunk.map { + case DynamicValue.Primitive(v, t) if t == StandardType.ByteType => + v.asInstanceOf[Byte] + case _ => throw new IllegalArgumentException("Only Byte sequences are supported.") + }.toArray + List(SqlParameter(StandardType.BinaryType, bytes)) + case _ => Nil + } + + private def renderInsertPlaceholders[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = + // TODO any performance penalty because of toList ? + col.toList match { + case head :: _ => + render("(") + renderInsertPlaceholder(head) + render(")") + case Nil => () + } + + private def renderInsertPlaceholder[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = + schema.toDynamic(z) match { + case DynamicValue.Record(_, listMap) => + listMap.values.toList match { + case head :: Nil => renderPlaceholder(head) + case head :: next => + renderPlaceholder(head) + render(", ") + renderPlaceholders(next) + case Nil => () + } + case value => renderPlaceholder(value) + } + + private def renderPlaceholders(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = + dynValues match { + case head :: Nil => renderPlaceholder(head) + case head :: tail => + renderPlaceholder(head) + render(", ") + renderPlaceholders(tail) + case Nil => () + } + + private def renderPlaceholder(dynValue: DynamicValue)(implicit render: Renderer): Unit = + dynValue match { + case DynamicValue.Primitive(_, _) => render("?") + case DynamicValue.Tuple(left, right) => + renderPlaceholder(left) + render(", ") + renderPlaceholder(right) + case DynamicValue.SomeValue(value) => renderPlaceholder(value) + case DynamicValue.NoneValue => render("?") + case DynamicValue.Sequence(_) => render("?") + case _ => () + } + + private def renderColumnNames(sources: SelectionSet[_])(implicit render: Renderer): Unit = + sources match { + case SelectionSet.Empty => () // table is a collection of at least ONE column + case SelectionSet.Cons(columnSelection, tail) => + val _ = columnSelection.name.map { name => + render(name) + } + tail.asInstanceOf[SelectionSet[_]] match { + case SelectionSet.Empty => () + case next @ SelectionSet.Cons(_, _) => + render(", ") + renderColumnNames(next.asInstanceOf[SelectionSet[_]])(render) + } + } + def renderUpdateImpl(update: Update[_])(implicit render: Renderer): Unit = update match { case Update(table, set, whereExpr) => diff --git a/oracle/src/main/scala/zio/sql/oracle/OracleSqlModule.scala b/oracle/src/main/scala/zio/sql/oracle/OracleSqlModule.scala index 0549167e2..a22918da2 100644 --- a/oracle/src/main/scala/zio/sql/oracle/OracleSqlModule.scala +++ b/oracle/src/main/scala/zio/sql/oracle/OracleSqlModule.scala @@ -33,6 +33,7 @@ trait OracleSqlModule extends Sql { self => } object OracleFunctionDef { - val Sind = FunctionDef[Double, Double](FunctionName("sind")) + val Ltrim2 = FunctionDef[(String, String), String](FunctionName("ltrim")) + val Rtrim2 = FunctionDef[(String, String), String](FunctionName("rtrim")) } } diff --git a/oracle/src/test/scala/zio/sql/oracle/CommonFunctionDefSpec.scala b/oracle/src/test/scala/zio/sql/oracle/CommonFunctionDefSpec.scala index 1ffb4f6d2..bcf0e05c5 100644 --- a/oracle/src/test/scala/zio/sql/oracle/CommonFunctionDefSpec.scala +++ b/oracle/src/test/scala/zio/sql/oracle/CommonFunctionDefSpec.scala @@ -4,17 +4,11 @@ import zio.Cause import zio.stream.ZStream import zio.test.Assertion._ import zio.test._ -import zio.schema.DeriveSchema import zio.sql.expr.FunctionDef.{ CharLength => _, _ } -import zio.sql.table._ -object CommonFunctionDefSpec extends OracleRunnableSpec with ShopSchema { +object CommonFunctionDefSpec extends OracleRunnableSpec with ShopSchema with DualSchema { import Customers._ - - case class Dual(dummy: String) - implicit val dummySchema = DeriveSchema.gen[Dual] - val dual = Table.defineTable[Dual] - val dommy = dual.columns + import Dual._ private def collectAndCompare[R, E]( expected: Seq[String], diff --git a/oracle/src/test/scala/zio/sql/oracle/CustomFunctionDefSpec.scala b/oracle/src/test/scala/zio/sql/oracle/CustomFunctionDefSpec.scala new file mode 100644 index 000000000..94eefec6b --- /dev/null +++ b/oracle/src/test/scala/zio/sql/oracle/CustomFunctionDefSpec.scala @@ -0,0 +1,25 @@ +package zio.sql.oracle + +import zio.test.Assertion._ +import zio.test.TestAspect.timeout +import zio.test._ +import zio._ + +object CustomFunctionDefSpec extends OracleRunnableSpec with DualSchema { + import OracleFunctionDef._ + + import Dual._ + + override def specLayered = suite("Oracle FunctionDef")( + test("ltrim2") { + assertZIO(execute(select(Ltrim2("$## foo$#", "#$")).from(dual)).runHead.some)( + equalTo(" foo$#") + ) + }, + test("rtrim2") { + assertZIO(execute(select(Rtrim2("$#foo $##", "#$")).from(dual)).runHead.some)( + equalTo("$#foo ") + ) + } + ) @@ timeout(5.minutes) +} diff --git a/oracle/src/test/scala/zio/sql/oracle/DualSchema.scala b/oracle/src/test/scala/zio/sql/oracle/DualSchema.scala new file mode 100644 index 000000000..cc62e5924 --- /dev/null +++ b/oracle/src/test/scala/zio/sql/oracle/DualSchema.scala @@ -0,0 +1,14 @@ +package zio.sql.oracle + +import zio.schema.DeriveSchema +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 + } +} diff --git a/oracle/src/test/scala/zio/sql/oracle/OracleSqlModuleSpec.scala b/oracle/src/test/scala/zio/sql/oracle/OracleSqlModuleSpec.scala index 23df6abb1..f7672bc50 100644 --- a/oracle/src/test/scala/zio/sql/oracle/OracleSqlModuleSpec.scala +++ b/oracle/src/test/scala/zio/sql/oracle/OracleSqlModuleSpec.scala @@ -8,15 +8,50 @@ import zio.test._ import scala.language.postfixOps import java.util.UUID import java.time._ -import zio.schema.DeriveSchema object OracleSqlModuleSpec extends OracleRunnableSpec with ShopSchema { import Customers._ import Orders._ - final case class CustomerRow(id: UUID, dateOfBirth: LocalDate, firstName: String, lastName: String, verified: Boolean) - implicit val customerRowSchema = DeriveSchema.gen[CustomerRow] + // final case class CustomerRow(id: String, dateOfBirth: LocalDate, firstName: String, lastName: String, verified: Boolean) + + // implicit val customerRowSchema = DeriveSchema.gen[CustomerRow] + // implicit val customerRowSchema = + // Schema.CaseClass5[UUID, LocalDate, String, String, Boolean, CustomerRow]( + // TypeId.parse("zio.sql.oracle.OracleModuleSpec.CustomerRow"), + // Schema.Field( + // "id", + // Schema.primitive[UUID](zio.schema.StandardType.UUIDType), + // get0 = _.id, + // set0 = (r, a) => r.copy(id = a) + // ), + // Schema.Field( + // "dateOfBirth", + // Schema.primitive[LocalDate](zio.schema.StandardType.LocalDateType), + // get0 = _.dateOfBirth, + // set0 = (r, a) => r.copy(dateOfBirth = a) + // ), + // Schema.Field( + // "firstName", + // Schema.primitive[String](zio.schema.StandardType.StringType), + // get0 = _.firstName, + // set0 = (r, a) => r.copy(firstName = a) + // ), + // Schema.Field( + // "lastName", + // Schema.primitive[String](zio.schema.StandardType.StringType), + // get0 = _.lastName, + // set0 = (r, a) => r.copy(lastName = a) + // ), + // Schema.Field( + // "verified", + // Schema.primitive[Boolean](zio.schema.StandardType.BoolType), + // get0 = _.verified, + // set0 = (r, a) => r.copy(verified = a) + // ), + // CustomerRow.apply + // ) override def specLayered: Spec[SqlDriver with TestConfig with Sized, Exception] = suite("Oracle module")( test("`in` clause sequence") { @@ -102,8 +137,8 @@ object OracleSqlModuleSpec extends OracleRunnableSpec with ShopSchema { test("Can insert rows") { val rows = List( - CustomerRow(UUID.randomUUID(), LocalDate.ofYearDay(2001, 8), "Peter", "Parker", true), - CustomerRow(UUID.randomUUID(), LocalDate.ofYearDay(1980, 2), "Stephen", "Strange", false) + Customers.Customers(UUID.randomUUID(), LocalDate.ofYearDay(2001, 8), "Peter", "Parker", true), + Customers.Customers(UUID.randomUUID(), LocalDate.ofYearDay(1980, 2), "Stephen", "Strange", false) ) val command = insertInto(customers)( diff --git a/oracle/src/test/scala/zio/sql/oracle/ShopSchema.scala b/oracle/src/test/scala/zio/sql/oracle/ShopSchema.scala index c9049a2f8..6958ef9c3 100644 --- a/oracle/src/test/scala/zio/sql/oracle/ShopSchema.scala +++ b/oracle/src/test/scala/zio/sql/oracle/ShopSchema.scala @@ -1,10 +1,10 @@ package zio.sql.oracle +import java.math.BigDecimal import java.util.UUID import java.time._ import zio.Chunk import zio.schema.DeriveSchema -import java.math.BigDecimal import zio.sql.table._ trait ShopSchema extends OracleSqlModule { self => diff --git a/postgres/src/main/scala/zio/sql/postgresql/PostgresJdbcModule.scala b/postgres/src/main/scala/zio/sql/postgresql/PostgresJdbcModule.scala index 5f81193eb..6ba452023 100644 --- a/postgres/src/main/scala/zio/sql/postgresql/PostgresJdbcModule.scala +++ b/postgres/src/main/scala/zio/sql/postgresql/PostgresJdbcModule.scala @@ -1,5 +1,46 @@ package zio.sql.postgresql -import zio.sql.Jdbc +import java.sql.Timestamp +import java.time._ +import java.util.UUID -trait PostgresJdbcModule extends PostgresRenderModule with Jdbc +import zio.schema.StandardType._ +import zio.sql.{ Jdbc, SqlParameter } + +trait PostgresJdbcModule extends PostgresRenderModule with Jdbc { + + override def setParam(param: SqlParameter, jdbcIndex: Int): java.sql.PreparedStatement => Unit = ps => + param._type match { + case BigDecimalType => ps.setBigDecimal(jdbcIndex, param.value.asInstanceOf[java.math.BigDecimal]) + case InstantType => ps.setTimestamp(jdbcIndex, Timestamp.from(param.value.asInstanceOf[Instant])) + case ByteType => ps.setByte(jdbcIndex, param.value.asInstanceOf[Byte]) + case CharType => ps.setString(jdbcIndex, String.valueOf(param.value.asInstanceOf[Char])) + case IntType => ps.setInt(jdbcIndex, param.value.asInstanceOf[Int]) + case MonthDayType => ps.setString(jdbcIndex, param.value.toString()) + case BinaryType => ps.setString(jdbcIndex, param.value.toString()) + case MonthType => ps.setString(jdbcIndex, param.value.toString()) + case LocalDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDateTime]) + case UnitType => ps.setObject(jdbcIndex, null) + case YearMonthType => ps.setString(jdbcIndex, param.value.toString()) + case DoubleType => ps.setDouble(jdbcIndex, param.value.asInstanceOf[Double]) + case YearType => ps.setString(jdbcIndex, param.value.toString()) + case OffsetDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetDateTime]) + case ZonedDateTimeType => + ps.setObject(jdbcIndex, Timestamp.from(param.value.asInstanceOf[ZonedDateTime].toInstant)) + case BigIntegerType => ps.setLong(jdbcIndex, param.value.asInstanceOf[BigInt].longValue) + case UUIDType => ps.setObject(jdbcIndex, param.value.asInstanceOf[UUID]) + case ZoneOffsetType => ps.setString(jdbcIndex, param.value.toString()) + case ShortType => ps.setShort(jdbcIndex, param.value.asInstanceOf[Short]) + case LocalTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalTime]) + case OffsetTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetTime]) + case LongType => ps.setLong(jdbcIndex, param.value.asInstanceOf[Long]) + case StringType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case PeriodType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case ZoneIdType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case LocalDateType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDate]) + case BoolType => ps.setBoolean(jdbcIndex, param.value.asInstanceOf[Boolean]) + case DayOfWeekType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case FloatType => ps.setFloat(jdbcIndex, param.value.asInstanceOf[Float]) + case DurationType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + } +} diff --git a/postgres/src/main/scala/zio/sql/postgresql/PostgresRenderModule.scala b/postgres/src/main/scala/zio/sql/postgresql/PostgresRenderModule.scala index 86f0cab21..955f12a8a 100644 --- a/postgres/src/main/scala/zio/sql/postgresql/PostgresRenderModule.scala +++ b/postgres/src/main/scala/zio/sql/postgresql/PostgresRenderModule.scala @@ -1,20 +1,16 @@ package zio.sql.postgresql -import java.time._ -import java.time.format.DateTimeFormatter - import zio.Chunk import zio.schema._ -import zio.schema.StandardType._ -import zio.sql.driver.Renderer -import java.time.format.DateTimeFormatter._ -import zio.sql.update._ -import zio.sql.select._ -import zio.sql.insert._ +import zio.sql.{ SqlParameter, SqlRow, SqlStatement } import zio.sql.delete._ +import zio.sql.driver.Renderer import zio.sql.expr._ +import zio.sql.insert._ +import zio.sql.select._ import zio.sql.table._ import zio.sql.typetag._ +import zio.sql.update._ trait PostgresRenderModule extends PostgresSqlModule { self => @@ -30,10 +26,10 @@ trait PostgresRenderModule extends PostgresSqlModule { self => render.toString } - override def renderInsert[A: Schema](insert: Insert[_, A]): String = { + override def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement = { implicit val render: Renderer = Renderer() - PostgresRenderer.renderInsertImpl(insert) - render.toString + val rows = PostgresRenderer.renderInsertImpl(insert) + SqlStatement(render.toString, rows) } override def renderDelete(delete: Delete[_]): String = { @@ -44,7 +40,7 @@ trait PostgresRenderModule extends PostgresSqlModule { self => object PostgresRenderer { - def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]) = { + def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]): List[SqlRow] = { render("INSERT INTO ") renderTable(insert.table) @@ -52,104 +48,94 @@ trait PostgresRenderModule extends PostgresSqlModule { self => renderColumnNames(insert.sources) render(") VALUES ") - renderInsertValues(insert.values) + renderInsertPlaceholders(insert.values) + + buildInsertList(insert.values) } - private def renderInsertValues[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = + private def buildInsertList[A](col: Seq[A])(implicit schema: Schema[A]): List[SqlRow] = + col.foldLeft(List.empty[SqlRow]) { case (a, z) => + val row = schema.toDynamic(z) match { + case DynamicValue.Record(_, listMap) => + val params = listMap.values.foldLeft(List.empty[SqlParameter]) { case (acc, el) => + acc ::: buildInsertRow(el) + } + SqlRow(params) + case value => + SqlRow(buildInsertRow(value)) + } + row :: a + } + + private def buildInsertRow(dynValue: DynamicValue): List[SqlParameter] = + dynValue match { + case DynamicValue.Primitive(value, typeTag) => + // need to do this since StandardType is invariant in A + StandardType.fromString(typeTag.tag) match { + case Some(v) => + List(SqlParameter(v, value)) + case None => Nil + } + case DynamicValue.Tuple(left, right) => + buildInsertRow(left) ::: buildInsertRow(right) + case DynamicValue.SomeValue(value) => buildInsertRow(value) + case DynamicValue.NoneValue => + List(SqlParameter(StandardType.UnitType, null)) + case DynamicValue.Sequence(chunk) => + val bytes = chunk.map { + case DynamicValue.Primitive(v, t) if t == StandardType.ByteType => + v.asInstanceOf[Byte] + case _ => throw new IllegalArgumentException("Only Byte sequences are supported.") + }.toArray + List(SqlParameter(StandardType.BinaryType, bytes)) + case _ => Nil + } + + private def renderInsertPlaceholders[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = // TODO any performance penalty because of toList ? col.toList match { - case head :: Nil => + case head :: _ => render("(") - renderInserValue(head) + renderInsertPlaceholder(head) render(");") - case head :: next => - render("(") - renderInserValue(head)(render, schema) - render(" ),") - renderInsertValues(next) - case Nil => () + case Nil => () } - private def renderInserValue[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = + private def renderInsertPlaceholder[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = schema.toDynamic(z) match { case DynamicValue.Record(_, listMap) => listMap.values.toList match { - case head :: Nil => renderDynamicValue(head) + case head :: Nil => renderPlaceholder(head) case head :: next => - renderDynamicValue(head) + renderPlaceholder(head) render(", ") - renderDynamicValues(next) + renderPlaceholders(next) case Nil => () } - case value => renderDynamicValue(value) + case value => renderPlaceholder(value) } - private def renderDynamicValues(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = + private def renderPlaceholders(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = dynValues match { - case head :: Nil => renderDynamicValue(head) + case head :: Nil => renderPlaceholder(head) case head :: tail => - renderDynamicValue(head) + renderPlaceholder(head) render(", ") - renderDynamicValues(tail) + renderPlaceholders(tail) case Nil => () } - // TODO render each type according to their specifics & test it - private def renderDynamicValue(dynValue: DynamicValue)(implicit render: Renderer): Unit = + private def renderPlaceholder(dynValue: DynamicValue)(implicit render: Renderer): Unit = dynValue match { - case DynamicValue.Primitive(value, typeTag) => - // need to do this since StandardType is invariant in A - StandardType.fromString(typeTag.tag) match { - case Some(v) => - v match { - case BigDecimalType => - render(value) - case StandardType.InstantType => - render(s"'${ISO_INSTANT.format(value.asInstanceOf[Instant])}'") - case ByteType => render(s"'${value}'") - case CharType => render(s"'${value}'") - case IntType => render(value) - case StandardType.MonthDayType => render(s"'${value}'") - case BinaryType => render(s"'${value}'") - case StandardType.MonthType => render(s"'${value}'") - case StandardType.LocalDateTimeType => - render(s"'${ISO_LOCAL_DATE_TIME.format(value.asInstanceOf[LocalDateTime])}'") - case UnitType => render("null") // None is encoded as Schema[Unit].transform(_ => None, _ => ()) - case StandardType.YearMonthType => render(s"'${value}'") - case DoubleType => render(value) - case StandardType.YearType => render(s"'${value}'") - case StandardType.OffsetDateTimeType => - render(s"'${ISO_OFFSET_DATE_TIME.format(value.asInstanceOf[OffsetDateTime])}'") - case StandardType.ZonedDateTimeType => - render(s"'${DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value.asInstanceOf[ZonedDateTime])}'") - case BigIntegerType => render(s"'${value}'") - case UUIDType => render(s"'${value}'") - case StandardType.ZoneOffsetType => render(s"'${value}'") - case ShortType => render(value) - case StandardType.LocalTimeType => - render(s"'${DateTimeFormatter.ISO_LOCAL_TIME.format(value.asInstanceOf[LocalTime])}'") - case StandardType.OffsetTimeType => - render(s"'${DateTimeFormatter.ISO_OFFSET_TIME.format(value.asInstanceOf[OffsetTime])}'") - case LongType => render(value) - case StringType => render(s"'${value}'") - case StandardType.PeriodType => render(s"'${value}'") - case StandardType.ZoneIdType => render(s"'${value}'") - case StandardType.LocalDateType => - render(s"'${ISO_DATE.format(value.asInstanceOf[LocalDate])}'") - case BoolType => render(value) - case DayOfWeekType => render(s"'${value}'") - case FloatType => render(value) - case StandardType.DurationType => render(s"'${value}'") - } - case None => () - } - case DynamicValue.Tuple(left, right) => - renderDynamicValue(left) + case DynamicValue.Primitive(_, _) => render("?") + case DynamicValue.Tuple(left, right) => + renderPlaceholder(left) render(", ") - renderDynamicValue(right) - case DynamicValue.SomeValue(value) => renderDynamicValue(value) - case DynamicValue.NoneValue => render("null") - case _ => () + renderPlaceholder(right) + case DynamicValue.SomeValue(value) => renderPlaceholder(value) + case DynamicValue.NoneValue => render("?") + case DynamicValue.Sequence(_) => render("?") + case _ => () } private def renderColumnNames(sources: SelectionSet[_])(implicit render: Renderer): Unit = @@ -254,7 +240,8 @@ trait PostgresRenderModule extends PostgresSqlModule { self => case _ => () } - private[zio] def quoted(name: String): String = "\"" + name + "\"" + private[zio] def quoted(name: String): String = + name.split('.').map("\"" + _ + "\"").mkString(".") private[zio] def renderExpr[A, B](expr: Expr[_, A, B])(implicit render: Renderer): Unit = expr match { case Expr.Subselect(subselect) => diff --git a/postgres/src/main/scala/zio/sql/postgresql/PostgresSqlModule.scala b/postgres/src/main/scala/zio/sql/postgresql/PostgresSqlModule.scala index 8010b1f72..0b34511e6 100644 --- a/postgres/src/main/scala/zio/sql/postgresql/PostgresSqlModule.scala +++ b/postgres/src/main/scala/zio/sql/postgresql/PostgresSqlModule.scala @@ -250,6 +250,7 @@ trait PostgresSqlModule extends Sql { self => val LocaltimestampWithPrecision = FunctionDef[Int, Instant](FunctionName("localtimestamp")) val LocaltimeWithPrecision = FunctionDef[Int, LocalTime](FunctionName("localtime")) val LPad = FunctionDef[(String, Int, String), String](FunctionName("lpad")) + val Ltrim2 = FunctionDef[(String, String), String](FunctionName("ltrim")) val MakeDate = FunctionDef[(Int, Int, Int), LocalDate](FunctionName("make_date")) val MakeInterval = FunctionDef[Interval, Interval](FunctionName("make_interval")) val MakeTime = FunctionDef[(Int, Int, Double), LocalTime](FunctionName("make_time")) @@ -271,6 +272,7 @@ trait PostgresSqlModule extends Sql { self => val Reverse = FunctionDef[String, String](FunctionName("reverse")) val Right = FunctionDef[(String, Int), String](FunctionName("right")) val RPad = FunctionDef[(String, Int, String), String](FunctionName("rpad")) + val Rtrim2 = FunctionDef[(String, String), String](FunctionName("rtrim")) val SetSeed = FunctionDef[Double, Unit](FunctionName("setseed")) val Sind = FunctionDef[Double, Double](FunctionName("sind")) val SplitPart = FunctionDef[(String, String, Int), String](FunctionName("split_part")) diff --git a/postgres/src/test/resources/db_schema.sql b/postgres/src/test/resources/db_schema.sql index 3c0d61f1d..db5860ad5 100644 --- a/postgres/src/test/resources/db_schema.sql +++ b/postgres/src/test/resources/db_schema.sql @@ -78,6 +78,14 @@ ALTER TABLE metro_line ADD CONSTRAINT metro_line_id PRIMARY KEY(id); ALTER TABLE metro_line ADD CONSTRAINT metro_line_system_fk FOREIGN KEY(system_id) REFERENCES metro_system(id) ON DELETE CASCADE ON UPDATE CASCADE; +create table movies +( + id int not null primary key, + rating int +); + +insert into "movies" ("id", "rating") values (1, null); + insert into "customers" ("id", "first_name", "last_name", "verified", "dob", "created_timestamp_string", "created_timestamp") values diff --git a/postgres/src/test/scala/zio/sql/postgresql/CustomFunctionDefSpec.scala b/postgres/src/test/scala/zio/sql/postgresql/CustomFunctionDefSpec.scala index 92e565eae..468382dcf 100644 --- a/postgres/src/test/scala/zio/sql/postgresql/CustomFunctionDefSpec.scala +++ b/postgres/src/test/scala/zio/sql/postgresql/CustomFunctionDefSpec.scala @@ -145,7 +145,17 @@ object CustomFunctionDefSpec extends PostgresRunnableSpec with DbSchema { val testResult = execute(query) collectAndCompare(expected, testResult) } - ) + ), + test("ltrim2") { + assertZIO(execute(select(Ltrim2("$## foo$#", "#$"))).runHead.some)( + equalTo(" foo$#") + ) + }, + test("rtrim2") { + assertZIO(execute(select(Rtrim2("$#foo $##", "#$"))).runHead.some)( + equalTo("$#foo ") + ) + } ), test("repeat") { assertZIO(execute(select(Repeat("Zio", 3))).runHead.some)(equalTo("ZioZioZio")) diff --git a/postgres/src/test/scala/zio/sql/postgresql/DbSchema.scala b/postgres/src/test/scala/zio/sql/postgresql/DbSchema.scala index e3466b497..9f2a3a940 100644 --- a/postgres/src/test/scala/zio/sql/postgresql/DbSchema.scala +++ b/postgres/src/test/scala/zio/sql/postgresql/DbSchema.scala @@ -122,4 +122,17 @@ trait DbSchema extends PostgresJdbcModule { self => val (personsId, personsName, birthDate) = persons.columns } + + object MoviesSchema { + + case class Movies(id: Int, rating: Option[Int]) + + implicit val moviesSchema = DeriveSchema.gen[Movies] + + val movies = Table.defineTableSmart[Movies] + + val (id, rating) = movies.columns + + } + } diff --git a/postgres/src/test/scala/zio/sql/postgresql/PostgresSqlModuleSpec.scala b/postgres/src/test/scala/zio/sql/postgresql/PostgresSqlModuleSpec.scala index 833750ab9..e33d211d3 100644 --- a/postgres/src/test/scala/zio/sql/postgresql/PostgresSqlModuleSpec.scala +++ b/postgres/src/test/scala/zio/sql/postgresql/PostgresSqlModuleSpec.scala @@ -3,7 +3,6 @@ package zio.sql.postgresql import java.math.BigDecimal import java.time._ import java.util.UUID - import zio._ import zio.schema._ import zio.test._ @@ -12,6 +11,7 @@ import zio.test.TestAspect._ import zio.sql.expr.AggregationDef._ import zio.sql.expr._ import zio.sql.select._ + import scala.language.postfixOps object PostgresSqlModuleSpec extends PostgresRunnableSpec with DbSchema { @@ -443,7 +443,7 @@ object PostgresSqlModuleSpec extends PostgresRunnableSpec with DbSchema { lastName: String, verified: Boolean, dateOfBirth: LocalDate, - cretedTimestampString: String, + createdTimestampString: String, createdTimestamp: ZonedDateTime ) @@ -488,8 +488,8 @@ object PostgresSqlModuleSpec extends PostgresRunnableSpec with DbSchema { Schema.Field( "cretedTimestampString", Schema.primitive[String](zio.schema.StandardType.StringType), - get0 = _.cretedTimestampString, - set0 = (r, a) => r.copy(cretedTimestampString = a) + get0 = _.createdTimestampString, + set0 = (r, a) => r.copy(createdTimestampString = a) ), Schema.Field( "createdTimestamp", @@ -691,12 +691,36 @@ object PostgresSqlModuleSpec extends PostgresRunnableSpec with DbSchema { }, test("select all rows") { import CustomerSchema._ + import OrdersSchema._ + import ProductSchema._ - val query = select(*).from(customers) + val allCustomers = select(*).from(customers) + val allOrders = select(*).from(orders) + val allProducts = select(*).from(products) for { - result <- execute(query).runCollect - } yield assertTrue(result.length == 2) + customers <- execute(allCustomers).runCollect + orders <- execute(allOrders).runCollect + products <- execute(allProducts).runCollect + } yield assertTrue(customers.length == 2) && assertTrue(orders.length == 35) && assertTrue(products.length == 10) + }, + test("Select null int value as None Option") { + val movieColumns = MoviesSchema.id ++ MoviesSchema.rating + val selectStmt = select(movieColumns).from(MoviesSchema.movies).where(MoviesSchema.id === 1) + val selectResult = execute(selectStmt.to((MoviesSchema.Movies.apply _).tupled)).runCollect + + for { + movies <- selectResult + } yield assert(movies.toList)( + equalTo( + List( + MoviesSchema.Movies( + id = 1, + rating = None + ) + ) + ) + ) } ) @@ sequential } diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index 6d33d8f7f..e0f22bc6f 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -9,7 +9,7 @@ import BuildInfoKeys._ import scalafix.sbt.ScalafixPlugin.autoImport.scalafixSemanticdb object BuildHelper { - val SilencerVersion = "1.7.12" + val SilencerVersion = "1.7.13" val Scala212 = "2.12.17" val Scala213 = "2.13.10" val ScalaDotty = "3.2.1" diff --git a/project/build.properties b/project/build.properties index 46e43a97e..72413de15 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.8.3 diff --git a/project/plugins.sbt b/project/plugins.sbt index c81f8d2b7..036c889c9 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,10 @@ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.12.0") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6") -addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.3") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.9") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.9") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.1") diff --git a/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerJdbcModule.scala b/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerJdbcModule.scala index d9108dfc7..8fc08832a 100644 --- a/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerJdbcModule.scala +++ b/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerJdbcModule.scala @@ -1,5 +1,53 @@ package zio.sql.sqlserver -import zio.sql.Jdbc +import java.sql.Timestamp +import java.time._ +import java.time.format.{ DateTimeFormatter, DateTimeFormatterBuilder } +import java.util.UUID -trait SqlServerJdbcModule extends SqlServerRenderModule with Jdbc +import zio.schema.StandardType._ +import zio.sql.{ Jdbc, SqlParameter } + +trait SqlServerJdbcModule extends SqlServerRenderModule with Jdbc { + + private val fmtDateTimeOffset = new DateTimeFormatterBuilder().parseCaseInsensitive + .append(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + .appendOffset("+HH:MM", "Z") + .toFormatter() + + override def setParam(param: SqlParameter, jdbcIndex: Int): java.sql.PreparedStatement => Unit = ps => + param._type match { + case BigDecimalType => ps.setBigDecimal(jdbcIndex, param.value.asInstanceOf[java.math.BigDecimal]) + case InstantType => ps.setTimestamp(jdbcIndex, Timestamp.from(param.value.asInstanceOf[Instant])) + case ByteType => ps.setByte(jdbcIndex, param.value.asInstanceOf[Byte]) + case CharType => ps.setString(jdbcIndex, String.valueOf(param.value.asInstanceOf[Char])) + case IntType => ps.setInt(jdbcIndex, param.value.asInstanceOf[Int]) + case MonthDayType => ps.setString(jdbcIndex, param.value.toString()) + case BinaryType => ps.setBytes(jdbcIndex, param.value.asInstanceOf[Array[Byte]]) + case MonthType => ps.setString(jdbcIndex, param.value.toString()) + case LocalDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDateTime]) + case UnitType => ps.setObject(jdbcIndex, null) + case YearMonthType => ps.setString(jdbcIndex, param.value.toString()) + case DoubleType => ps.setDouble(jdbcIndex, param.value.asInstanceOf[Double]) + case YearType => ps.setString(jdbcIndex, param.value.toString()) + case OffsetDateTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetDateTime]) + case ZonedDateTimeType => + ps.setString(jdbcIndex, fmtDateTimeOffset.format(param.value.asInstanceOf[ZonedDateTime])) + case BigIntegerType => ps.setLong(jdbcIndex, param.value.asInstanceOf[BigInt].longValue) + case UUIDType => ps.setString(jdbcIndex, param.value.asInstanceOf[UUID].toString()) + case ZoneOffsetType => ps.setString(jdbcIndex, param.value.toString()) + case ShortType => ps.setShort(jdbcIndex, param.value.asInstanceOf[Short]) + case LocalTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalTime]) + case OffsetTimeType => ps.setObject(jdbcIndex, param.value.asInstanceOf[OffsetTime]) + case LongType => ps.setLong(jdbcIndex, param.value.asInstanceOf[Long]) + case StringType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case PeriodType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case ZoneIdType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case LocalDateType => ps.setObject(jdbcIndex, param.value.asInstanceOf[LocalDate]) + case BoolType => ps.setBoolean(jdbcIndex, param.value.asInstanceOf[Boolean]) + case DayOfWeekType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + case FloatType => ps.setFloat(jdbcIndex, param.value.asInstanceOf[Float]) + case DurationType => ps.setString(jdbcIndex, param.value.asInstanceOf[String]) + } + +} diff --git a/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerRenderModule.scala b/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerRenderModule.scala index 900b2d510..80cd82bda 100644 --- a/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerRenderModule.scala +++ b/sqlserver/src/main/scala/zio/sql/sqlserver/SqlServerRenderModule.scala @@ -1,20 +1,19 @@ package zio.sql.sqlserver -import zio.Chunk -import zio.schema.StandardType._ -import zio.schema._ -import zio.sql.driver.Renderer -import java.time.format.DateTimeFormatter._ -import java.time.format.{ DateTimeFormatter, DateTimeFormatterBuilder } import java.time._ -import zio.sql.update._ -import zio.sql.select._ -import zio.sql.insert._ +import java.time.format.{ DateTimeFormatter, DateTimeFormatterBuilder } + +import zio.schema._ +import zio.sql.{ SqlParameter, SqlRow, SqlStatement } import zio.sql.delete._ +import zio.sql.driver.Renderer import zio.sql.expr._ +import zio.sql.insert._ +import zio.sql.ops.Operator._ +import zio.sql.select._ import zio.sql.table._ import zio.sql.typetag._ -import zio.sql.ops.Operator._ +import zio.sql.update._ trait SqlServerRenderModule extends SqlServerSqlModule { self => @@ -30,10 +29,10 @@ trait SqlServerRenderModule extends SqlServerSqlModule { self => render.toString } - override def renderInsert[A: Schema](insert: Insert[_, A]): String = { + override def renderInsert[A: Schema](insert: Insert[_, A]): SqlStatement = { implicit val render: Renderer = Renderer() - SqlServerRenderer.renderInsertImpl(insert) - render.toString + val rows = SqlServerRenderer.renderInsertImpl(insert) + SqlStatement(render.toString, rows) } override def renderDelete(delete: Delete[_]): String = { @@ -433,116 +432,51 @@ trait SqlServerRenderModule extends SqlServerSqlModule { self => } } - private def buildInsertValues[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = + private def renderInsertPlaceholders[A](col: Seq[A])(implicit render: Renderer, schema: Schema[A]): Unit = col.toList match { - case head :: Nil => + case head :: _ => render("(") - buildInsertValue(head) + renderInsertPlaceholder(head) render(");") - case head :: next => - render("(") - buildInsertValue(head)(render, schema) - render(" ),") - buildInsertValues(next) - case Nil => () + case Nil => () } - private def buildInsertValue[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = + private def renderInsertPlaceholder[Z](z: Z)(implicit render: Renderer, schema: Schema[Z]): Unit = schema.toDynamic(z) match { case DynamicValue.Record(_, listMap) => listMap.values.toList match { - case head :: Nil => buildDynamicValue(head) + case head :: Nil => renderPlaceholder(head) case head :: next => - buildDynamicValue(head) + renderPlaceholder(head) render(", ") - buildDynamicValues(next) + renderPlaceholders(next) case Nil => () } - case value => buildDynamicValue(value) + case value => renderPlaceholder(value) } - private def buildDynamicValues(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = + private def renderPlaceholders(dynValues: List[DynamicValue])(implicit render: Renderer): Unit = dynValues match { - case head :: Nil => buildDynamicValue(head) + case head :: Nil => renderPlaceholder(head) case head :: tail => - buildDynamicValue(head) + renderPlaceholder(head) render(", ") - buildDynamicValues(tail) + renderPlaceholders(tail) case Nil => () } // TODO render each type according to their specifics & test it - private def buildDynamicValue(dynValue: DynamicValue)(implicit render: Renderer): Unit = + private def renderPlaceholder(dynValue: DynamicValue)(implicit render: Renderer): Unit = dynValue match { - case DynamicValue.Primitive(value, typeTag) => - // need to do this since StandardType is invariant in A - StandardType.fromString(typeTag.tag) match { - case Some(v) => - v match { - case BigDecimalType => - render(value) - case StandardType.InstantType => - render(s"'${ISO_INSTANT.format(value.asInstanceOf[Instant])}'") - case ByteType => render(s"${value}") - case CharType => render(s"N'${value}'") - case IntType => render(value) - case StandardType.MonthDayType => render(s"'${value}'") - case BinaryType => - val chunk = value.asInstanceOf[Chunk[Object]] - render("CONVERT(VARBINARY(MAX),'") - for (b <- chunk) - render("%02x".format(b)) - render("', 2)") - case StandardType.MonthType => render(s"'${value}'") - case StandardType.LocalDateTimeType => - render(s"'${ISO_LOCAL_DATE_TIME.format(value.asInstanceOf[LocalDateTime])}'") - case UnitType => render("null") // None is encoded as Schema[Unit].transform(_ => None, _ => ()) - case StandardType.YearMonthType => render(s"'${value}'") - case DoubleType => render(value) - case StandardType.YearType => render(s"'${value}'") - case StandardType.OffsetDateTimeType => - render(s"'${fmtDateTimeOffset.format(value.asInstanceOf[OffsetDateTime])}'") - case StandardType.ZonedDateTimeType => - render(s"'${fmtDateTimeOffset.format(value.asInstanceOf[ZonedDateTime])}'") - case BigIntegerType => render(value) - case UUIDType => render(s"'${value}'") - case StandardType.ZoneOffsetType => render(s"'${value}'") - case ShortType => render(value) - case StandardType.LocalTimeType => - render(s"'${DateTimeFormatter.ISO_LOCAL_TIME.format(value.asInstanceOf[LocalTime])}'") - case StandardType.OffsetTimeType => - render(s"'${fmtTimeOffset.format(value.asInstanceOf[OffsetTime])}'") - case LongType => render(value) - case StringType => render(s"N'${value}'") - case StandardType.PeriodType => render(s"'${value}'") - case StandardType.ZoneIdType => render(s"'${value}'") - case StandardType.LocalDateType => - render(s"'${DateTimeFormatter.ISO_LOCAL_DATE.format(value.asInstanceOf[LocalDate])}'") - case BoolType => - val b = value.asInstanceOf[Boolean] - if (b) { - render('1') - } else { - render('0') - } - case DayOfWeekType => render(s"'${value}'") - case FloatType => render(value) - case StandardType.DurationType => render(s"'${value}'") - } - case None => () - } - case DynamicValue.Tuple(left, right) => - buildDynamicValue(left) + case DynamicValue.Primitive(_, _) => render("?") + case DynamicValue.Tuple(left, right) => + renderPlaceholder(left) render(", ") - buildDynamicValue(right) - case DynamicValue.SomeValue(value) => buildDynamicValue(value) - case DynamicValue.NoneValue => render("null") - case DynamicValue.Sequence(chunk) => - render("CONVERT(VARBINARY(MAX),'") - for (DynamicValue.Primitive(v, _) <- chunk) - render("%02x".format(v)) - render("', 2)") - case _ => () + renderPlaceholder(right) + case DynamicValue.SomeValue(value) => renderPlaceholder(value) + case DynamicValue.NoneValue => render("?") + case DynamicValue.Sequence(_) => render("?") + case _ => () } private def buildSet(set: List[Set[_, _]])(implicit render: Renderer): Unit = @@ -560,6 +494,44 @@ trait SqlServerRenderModule extends SqlServerSqlModule { self => case Nil => // TODO restrict Update to not allow empty set } + private def buildInsertList[A](col: Seq[A])(implicit schema: Schema[A]): List[SqlRow] = + col.foldLeft(List.empty[SqlRow]) { case (a, z) => + val row = schema.toDynamic(z) match { + case DynamicValue.Record(_, listMap) => + val params = listMap.values.foldLeft(List.empty[SqlParameter]) { case (acc, el) => + acc ::: buildInsertRow(el) + } + SqlRow(params) + case value => + SqlRow(buildInsertRow(value)) + } + row :: a + } + + private def buildInsertRow(dynValue: DynamicValue): List[SqlParameter] = + dynValue match { + case DynamicValue.Primitive(value, typeTag) => + // need to do this since StandardType is invariant in A + StandardType.fromString(typeTag.tag) match { + case Some(v) => + List(SqlParameter(v, value)) + case None => Nil + } + case DynamicValue.Tuple(left, right) => + buildInsertRow(left) ::: buildInsertRow(right) + case DynamicValue.SomeValue(value) => buildInsertRow(value) + case DynamicValue.NoneValue => + List(SqlParameter(StandardType.UnitType, null)) + case DynamicValue.Sequence(chunk) => + val bytes = chunk.map { + case DynamicValue.Primitive(v, t) if t == StandardType.ByteType => + v.asInstanceOf[Byte] + case _ => throw new IllegalArgumentException("Only Byte sequences are supported.") + }.toArray + List(SqlParameter(StandardType.BinaryType, bytes)) + case _ => Nil + } + def renderDeleteImpl(delete: Delete[_])(implicit render: Renderer) = { render("DELETE FROM ") buildTable(delete.table) @@ -576,7 +548,7 @@ trait SqlServerRenderModule extends SqlServerSqlModule { self => buildWhereExpr(whereExpr) } - def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]) = { + def renderInsertImpl[A](insert: Insert[_, A])(implicit render: Renderer, schema: Schema[A]): List[SqlRow] = { render("INSERT INTO ") buildTable(insert.table) @@ -584,7 +556,9 @@ trait SqlServerRenderModule extends SqlServerSqlModule { self => buildColumnNames(insert.sources) render(") VALUES ") - buildInsertValues(insert.values) + renderInsertPlaceholders(insert.values) + + buildInsertList(insert.values) } } }