Permalink
Browse files

Allow selective translation for Take or Drop in removeTakeDrop:

This can be used when a database supports a “fetch” equivalent natively
but needs any combination with “offset” to be emulated.
  • Loading branch information...
szeiger committed Sep 9, 2015
1 parent dc1c551 commit 07cd37a4f9e79758e453b5bcedd1e884ae6a360b
Showing with 2 additions and 2 deletions.
  1. +2 −2 slick/src/main/scala/slick/compiler/RemoveTakeDrop.scala
@@ -9,13 +9,13 @@ import scala.collection.mutable
/** Replace all occurrences of `Take` and `Drop` with row number computations based on
* `zipWithIndex` operations. */
class RemoveTakeDrop extends Phase {
class RemoveTakeDrop(val translateTake: Boolean = true, val translateDrop: Boolean = true) extends Phase {
val name = "removeTakeDrop"
def apply(state: CompilerState) = state.map { n =>
val invalid = mutable.Set[TypeSymbol]()
def tr(n: Node): Node = n.replace {
case n @ TakeDrop(from, t, d) =>
case n @ TakeDrop(from, t, d) if (translateTake && t.isDefined) || (translateDrop && d.isDefined) =>
logger.debug(s"""Translating "drop $d, then take $t" to zipWithIndex operation:""", n)
val fromRetyped = tr(from).infer()
val from2 = fromRetyped match {

0 comments on commit 07cd37a

Please sign in to comment.