Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
wip, got things compiling, need to wrap up timestamp and timestampz p…
Browse files Browse the repository at this point in the history
…lus interval def
  • Loading branch information
brbrown25 committed Nov 23, 2020
1 parent c41fff6 commit 831554c
Show file tree
Hide file tree
Showing 3 changed files with 482 additions and 34 deletions.
300 changes: 299 additions & 1 deletion core/jvm/src/main/scala/zio/sql/expr.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package zio.sql

import java.time._

import scala.language.implicitConversions

trait ExprModule extends NewtypesModule with FeaturesModule with OpsModule {
Expand Down Expand Up @@ -193,6 +192,160 @@ trait ExprModule extends NewtypesModule with FeaturesModule with OpsModule {
) extends InvariantExpr[Features.Union[F1, Features.Union[F2, Features.Union[F3, F4]]], A, Z] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}

sealed case class FunctionCall5[F1, F2, F3, F4, F5, A, B, C, D, E, F, Z: TypeTag](
param1: Expr[F1, A, B],
param2: Expr[F2, A, C],
param3: Expr[F3, A, D],
param4: Expr[F4, A, E],
param5: Expr[F5, A, F],
function: FunctionDef[(B, C, D, E, F), Z]
) extends InvariantExpr[Features.Union[F1, Features.Union[F2, Features.Union[F3, Features.Union[F4, F5]]]], A, Z] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}

sealed case class FunctionCall6[F1, F2, F3, F4, F5, F6, A, B, C, D, E, F, G, Z: TypeTag](
param1: Expr[F1, A, B],
param2: Expr[F2, A, C],
param3: Expr[F3, A, D],
param4: Expr[F4, A, E],
param5: Expr[F5, A, F],
param6: Expr[F6, A, G],
function: FunctionDef[(B, C, D, E, F, G), Z]
) extends InvariantExpr[
Features.Union[F1, Features.Union[F2, Features.Union[F3, Features.Union[F4, Features.Union[F5, F6]]]]],
A,
Z
] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}

sealed case class FunctionCall7[F1, F2, F3, F4, F5, F6, F7, A, B, C, D, E, F, G, H, Z: TypeTag](
param1: Expr[F1, A, B],
param2: Expr[F2, A, C],
param3: Expr[F3, A, D],
param4: Expr[F4, A, E],
param5: Expr[F5, A, F],
param6: Expr[F6, A, G],
param7: Expr[F7, A, H],
function: FunctionDef[(B, C, D, E, F, G, H), Z]
) extends InvariantExpr[
Features.Union[
F1,
Features.Union[F2, Features.Union[F3, Features.Union[F4, Features.Union[F5, Features.Union[F6, F7]]]]]
],
A,
Z
] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}

sealed case class FunctionCall8[F1, F2, F3, F4, F5, F6, F7, F8, A, B, C, D, E, F, G, H, I, Z: TypeTag](
param1: Expr[F1, A, B],
param2: Expr[F2, A, C],
param3: Expr[F3, A, D],
param4: Expr[F4, A, E],
param5: Expr[F5, A, F],
param6: Expr[F6, A, G],
param7: Expr[F7, A, H],
param8: Expr[F8, A, I],
function: FunctionDef[(B, C, D, E, F, G, H, I), Z]
) extends InvariantExpr[
Features.Union[
F1,
Features.Union[
F2,
Features.Union[F3, Features.Union[F4, Features.Union[F5, Features.Union[F6, Features.Union[F7, F8]]]]]
]
],
A,
Z
] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}

sealed case class FunctionCall9[F1, F2, F3, F4, F5, F6, F7, F8, F9, A, B, C, D, E, F, G, H, I, J, Z: TypeTag](
param1: Expr[F1, A, B],
param2: Expr[F2, A, C],
param3: Expr[F3, A, D],
param4: Expr[F4, A, E],
param5: Expr[F5, A, F],
param6: Expr[F6, A, G],
param7: Expr[F7, A, H],
param8: Expr[F8, A, I],
param9: Expr[F9, A, J],
function: FunctionDef[(B, C, D, E, F, G, H, I, J), Z]
) extends InvariantExpr[
Features.Union[
F1,
Features.Union[
F2,
Features.Union[
F3,
Features.Union[F4, Features.Union[F5, Features.Union[F6, Features.Union[F7, Features.Union[F8, F9]]]]]
]
]
],
A,
Z
] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}

sealed case class FunctionCall10[
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
Z: TypeTag
](
param1: Expr[F1, A, B],
param2: Expr[F2, A, C],
param3: Expr[F3, A, D],
param4: Expr[F4, A, E],
param5: Expr[F5, A, F],
param6: Expr[F6, A, G],
param7: Expr[F7, A, H],
param8: Expr[F8, A, I],
param9: Expr[F9, A, J],
param10: Expr[F10, A, K],
function: FunctionDef[(B, C, D, E, F, G, H, I, J, K), Z]
) extends InvariantExpr[
Features.Union[
F1,
Features.Union[
F2,
Features.Union[
F3,
Features.Union[F4, Features.Union[
F5,
Features.Union[F6, Features.Union[F7, Features.Union[F8, Features.Union[F9, F10]]]]
]]
]
]
],
A,
Z
] {
def typeTag: TypeTag[Z] = implicitly[TypeTag[Z]]
}
}

sealed case class AggregationDef[-A, +B](name: FunctionName) { self =>
Expand Down Expand Up @@ -247,6 +400,151 @@ trait ExprModule extends NewtypesModule with FeaturesModule with OpsModule {
self.narrow[(P1, P2, P3, P4)]: FunctionDef[(P1, P2, P3, P4), B1]
)

def apply[F1, F2, F3, F4, F5, Source, P1, P2, P3, P4, P5, B1 >: B](
param1: Expr[F1, Source, P1],
param2: Expr[F2, Source, P2],
param3: Expr[F3, Source, P3],
param4: Expr[F4, Source, P4],
param5: Expr[F5, Source, P5]
)(implicit
ev: (P1, P2, P3, P4, P5) <:< A,
typeTag: TypeTag[B1]
): Expr[F1 :||: F2 :||: F3 :||: F4 :||: F5, Source, B1] =
Expr.FunctionCall5(
param1,
param2,
param3,
param4,
param5,
self.narrow[(P1, P2, P3, P4, P5)]: FunctionDef[(P1, P2, P3, P4, P5), B1]
)

def apply[F1, F2, F3, F4, F5, F6, Source, P1, P2, P3, P4, P5, P6, B1 >: B](
param1: Expr[F1, Source, P1],
param2: Expr[F2, Source, P2],
param3: Expr[F3, Source, P3],
param4: Expr[F4, Source, P4],
param5: Expr[F5, Source, P5],
param6: Expr[F6, Source, P6]
)(implicit
ev: (P1, P2, P3, P4, P5, P6) <:< A,
typeTag: TypeTag[B1]
): Expr[F1 :||: F2 :||: F3 :||: F4 :||: F5 :||: F6, Source, B1] =
Expr.FunctionCall6(
param1,
param2,
param3,
param4,
param5,
param6,
self.narrow[(P1, P2, P3, P4, P5, P6)]: FunctionDef[(P1, P2, P3, P4, P5, P6), B1]
)

def apply[F1, F2, F3, F4, F5, F6, F7, Source, P1, P2, P3, P4, P5, P6, P7, B1 >: B](
param1: Expr[F1, Source, P1],
param2: Expr[F2, Source, P2],
param3: Expr[F3, Source, P3],
param4: Expr[F4, Source, P4],
param5: Expr[F5, Source, P5],
param6: Expr[F6, Source, P6],
param7: Expr[F7, Source, P7]
)(implicit
ev: (P1, P2, P3, P4, P5, P6, P7) <:< A,
typeTag: TypeTag[B1]
): Expr[F1 :||: F2 :||: F3 :||: F4 :||: F5 :||: F6 :||: F7, Source, B1] =
Expr.FunctionCall7(
param1,
param2,
param3,
param4,
param5,
param6,
param7,
self.narrow[(P1, P2, P3, P4, P5, P6, P7)]: FunctionDef[(P1, P2, P3, P4, P5, P6, P7), B1]
)

def apply[F1, F2, F3, F4, F5, F6, F7, F8, Source, P1, P2, P3, P4, P5, P6, P7, P8, B1 >: B](
param1: Expr[F1, Source, P1],
param2: Expr[F2, Source, P2],
param3: Expr[F3, Source, P3],
param4: Expr[F4, Source, P4],
param5: Expr[F5, Source, P5],
param6: Expr[F6, Source, P6],
param7: Expr[F7, Source, P7],
param8: Expr[F8, Source, P8]
)(implicit
ev: (P1, P2, P3, P4, P5, P6, P7, P8) <:< A,
typeTag: TypeTag[B1]
): Expr[F1 :||: F2 :||: F3 :||: F4 :||: F5 :||: F6 :||: F7 :||: F8, Source, B1] =
Expr.FunctionCall8(
param1,
param2,
param3,
param4,
param5,
param6,
param7,
param8,
self.narrow[(P1, P2, P3, P4, P5, P6, P7, P8)]: FunctionDef[(P1, P2, P3, P4, P5, P6, P7, P8), B1]
)

def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, Source, P1, P2, P3, P4, P5, P6, P7, P8, P9, B1 >: B](
param1: Expr[F1, Source, P1],
param2: Expr[F2, Source, P2],
param3: Expr[F3, Source, P3],
param4: Expr[F4, Source, P4],
param5: Expr[F5, Source, P5],
param6: Expr[F6, Source, P6],
param7: Expr[F7, Source, P7],
param8: Expr[F8, Source, P8],
param9: Expr[F9, Source, P9]
)(implicit
ev: (P1, P2, P3, P4, P5, P6, P7, P8, P9) <:< A,
typeTag: TypeTag[B1]
): Expr[F1 :||: F2 :||: F3 :||: F4 :||: F5 :||: F6 :||: F7 :||: F8 :||: F9, Source, B1] =
Expr.FunctionCall9(
param1,
param2,
param3,
param4,
param5,
param6,
param7,
param8,
param9,
self.narrow[(P1, P2, P3, P4, P5, P6, P7, P8, P9)]: FunctionDef[(P1, P2, P3, P4, P5, P6, P7, P8, P9), B1]
)

def apply[F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, Source, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, B1 >: B](
param1: Expr[F1, Source, P1],
param2: Expr[F2, Source, P2],
param3: Expr[F3, Source, P3],
param4: Expr[F4, Source, P4],
param5: Expr[F5, Source, P5],
param6: Expr[F6, Source, P6],
param7: Expr[F7, Source, P7],
param8: Expr[F8, Source, P8],
param9: Expr[F9, Source, P9],
param10: Expr[F10, Source, P10]
)(implicit
ev: (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) <:< A,
typeTag: TypeTag[B1]
): Expr[F1 :||: F2 :||: F3 :||: F4 :||: F5 :||: F6 :||: F7 :||: F8 :||: F9 :||: F10, Source, B1] =
Expr.FunctionCall10(
param1,
param2,
param3,
param4,
param5,
param6,
param7,
param8,
param9,
param10,
self
.narrow[(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10)]: FunctionDef[(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10), B1]
)

def narrow[C](implicit ev: C <:< A): FunctionDef[C, B] = {
val _ = ev
self.asInstanceOf[FunctionDef[C, B]]
Expand Down
Loading

0 comments on commit 831554c

Please sign in to comment.