Permalink
Browse files

Move createResultSetMapping down after forceOuterBinds

  • Loading branch information...
szeiger committed Apr 8, 2015
1 parent dd2ab5f commit f53f06e6a39917f91f9ab2426ebc11ad4cbe53ae
@@ -16,9 +16,7 @@ class CreateResultSetMapping extends Phase {
logger.debug("Client-side result type: "+n.nodeType)
val n2 = removeTypeMapping(n)
logger.debug("Removed type mapping:", n2)
val n3 = toCollection(n2)
logger.debug("Converted to collection:", n3)
ClientSideOp.mapServerSide(n3) { ch =>
ClientSideOp.mapServerSide(n2) { ch =>
val gen = new AnonSymbol
ResultSetMapping(gen, ch, createResult(gen, n.nodeType match {
case CollectionType(_, el) => el
@@ -37,16 +35,6 @@ class CreateResultSetMapping extends Phase {
if(tpe2 eq tpe) n2 else n2.nodeTypedOrCopy(tpe2)
}
/** Force collection return type. This might get more complicated in the
* future. For now, all primitive types should be set (but collection-typed
* nodes and product nodes may have UnassignedType) and ProductNodes cannot
* contain nested collections. */
def toCollection(n: Node): Node = n match {
case _: Apply | _: ProductNode => First(Pure(n))
case n if n.nodeType != UnassignedType && !n.nodeType.isInstanceOf[CollectionType] => First(Pure(n))
case n => n
}
/** Remove MappedTypes from a Type */
def removeMappedType(tpe: Type): Type = tpe match {
case m: MappedScalaType => removeMappedType(m.baseType)
@@ -9,9 +9,15 @@ import slick.ast._
class ForceOuterBinds extends Phase {
val name = "forceOuterBinds"
def apply(state: CompilerState): CompilerState = state.map { n => ClientSideOp.mapServerSide(n)(apply) }
def apply(n: Node): Node = wrap(n).nodeWithComputedType(SymbolScope.empty, typeChildren = true, retype = false)
def apply(state: CompilerState): CompilerState = state.map(apply)
def apply(n: Node): Node = {
val t = n.nodeType.structuralRec
val n2 =
if(t != UnassignedType && !t.isInstanceOf[CollectionType]) First(wrap(Pure(n)))
else wrap(n)
n2.nodeWithComputedType(SymbolScope.empty, typeChildren = true, retype = false)
}
def idBind(n: Node): Bind = {
val gen = new AnonSymbol
@@ -91,8 +91,8 @@ object QueryCompiler {
// Distribute and normalize
Phase.inferTypes,
Phase.expandTables,
Phase.createResultSetMapping,
Phase.forceOuterBinds,
Phase.createResultSetMapping,
// Convert to column form
Phase.expandSums,
Phase.expandConditionals,

0 comments on commit f53f06e

Please sign in to comment.