-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #829 from sviezypan/select_all_from
select(*).from(table)
- Loading branch information
Showing
11 changed files
with
1,080 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package zio.sql.macros | ||
|
||
import scala.reflect.macros.whitebox | ||
import scala.language.experimental.macros | ||
|
||
sealed trait Normalizer[In] { | ||
type Out | ||
} | ||
|
||
object Normalizer { | ||
|
||
final case class Instance[In, Out2]() extends Normalizer[In] { | ||
override type Out = Out2 | ||
} | ||
|
||
implicit def createNormalizer[In, Out]: Instance[In, Out] = macro createNormalizerImpl[In, Out] | ||
|
||
def createNormalizerImpl[In: c.WeakTypeTag, Out: c.WeakTypeTag]( | ||
c: whitebox.Context | ||
): c.Tree = { | ||
import c.universe._ | ||
|
||
val inType = weakTypeOf[In] | ||
val _ = weakTypeOf[Out] | ||
|
||
def deconstructType(t: Type): List[Type] = | ||
t.dealias match { | ||
case TypeRef(_, y, types) if (types != Nil && (y == symbolOf[scala.Tuple2[_, _]])) => | ||
types.head :: deconstructType(types.tail.head) | ||
case TypeRef(_, _, types) if (types == Nil) => | ||
Nil | ||
case s => | ||
c.abort(c.enclosingPosition, s"Error ${showRaw(s)}") | ||
} | ||
|
||
val values = deconstructType(inType) | ||
val outType = tq"(..$values)" | ||
|
||
q"""zio.sql.macros.Normalizer.Instance[${q"$inType"}, $outType]()""" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package zio.sql.macros | ||
|
||
import scala.language.experimental.macros | ||
|
||
sealed trait Normalizer[In] { | ||
type Out | ||
} | ||
|
||
// TODO transparent inline | ||
object Normalizer { | ||
|
||
// final case class Instance[In, Out2]() extends Normalizer[In] { | ||
// override type Out = Out2 | ||
// } | ||
|
||
implicit def createNormalizer[In]: Normalizer[In] = { | ||
new Normalizer[In] {} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters