Permalink
Browse files

fixed: forceInsertQuery with identical values issue

  • Loading branch information...
1 parent cada417 commit d00eaf73d99b16fa28d9cbfe603be5a92b28d359 @coutoPL coutoPL committed Apr 25, 2016
Showing with 4 additions and 4 deletions.
  1. +4 −4 slick/src/main/scala/slick/compiler/HoistClientOps.scala
@@ -17,12 +17,12 @@ class HoistClientOps extends Phase {
from1 match {
case Bind(s2, from2, Pure(StructNode(defs2), ts2)) =>
// Extract client-side operations into ResultSetMapping
- val hoisted = defs2.map { case (ts, n) => (ts, n, unwrap(n, true)) }
+ val hoisted = defs2.map { case (ts, n) => (ts, n, unwrap(n, topLevel = true)) }
logger.debug("Hoisting operations from defs: " + hoisted.iterator.filter(t => t._2 ne t._3._1).map(_._1).mkString(", "))
- val newDefsM = hoisted.iterator.map { case (ts, n, (n2, wrap)) => (n2, new AnonSymbol) }.toMap
+ val newDefsM = hoisted.iterator.zipWithIndex.map { case ((ts, n, (n2, wrap)), idx) => (idx, (n2, new AnonSymbol)) }.toMap
logger.debug("New defs: "+newDefsM)
- val oldDefsM = hoisted.iterator.map { case (ts, n, (n2, wrap)) => (ts, wrap(Select(Ref(rsm.generator), newDefsM(n2)))) }.toMap
- val bind2 = rewriteDBSide(Bind(s2, from2, Pure(StructNode(ConstArray.from(newDefsM.map(_.swap))), new AnonTypeSymbol)).infer())
+ val oldDefsM = hoisted.iterator.zipWithIndex.map { case ((ts, n, (n2, wrap)), idx) => (ts, wrap(Select(Ref(rsm.generator), newDefsM(idx)._2))) }.toMap
+ val bind2 = rewriteDBSide(Bind(s2, from2, Pure(StructNode(ConstArray.from(newDefsM.map(_._2.swap))), new AnonTypeSymbol)).infer())
val rsm2 = rsm.copy(from = bind2, map = rsm.map.replace {
case Select(Ref(s), f) if s == rsm.generator => oldDefsM(f)
}).infer()

0 comments on commit d00eaf7

Please sign in to comment.