Skip to content

Commit

Permalink
fix zio#318
Browse files Browse the repository at this point in the history
  • Loading branch information
timzaak committed Dec 8, 2023
1 parent 8977738 commit 167e404
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,9 @@ object PrepareDynamicExecution {
matchingExternals: List[External],
secondaryLifts: List[Planter[_, _, _]] = List()
): Either[String, (List[Planter[_, _, _]], List[Planter[_, _, _]])] = {
val encodeablesMap =
lifts.map(e => (e.uid, e)).toMap

var encodeablesMap =
lifts.groupBy(_.uid)

val secondaryEncodeablesMap =
secondaryLifts.map(e => (e.uid, e)).toMap
Expand Down Expand Up @@ -599,8 +600,10 @@ object PrepareDynamicExecution {
uidsOfScalarTags
.map { uid =>
encodeablesMap.get(uid) match {
case Some(element) => UidStatus.Primary(uid, element)
case None =>
case Some(head::tails) =>
encodeablesMap += (uid, tails)
UidStatus.Primary(uid, head)
case _ =>
secondaryEncodeablesMap.get(uid) match {
case Some(element) => UidStatus.Secondary(uid, element)
case None => UidStatus.NotFound(uid)
Expand Down
24 changes: 24 additions & 0 deletions quill-sql/src/test/scala/io/getquill/issues/Issue318.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.getquill.issues

import io.getquill.*

case class Custom(name: String)



class Issue318 extends Spec {
"reproduce" in {
val nameFilter = Seq("a", "b")

val ctx = new SqlMirrorContext(MirrorSqlDialect, Literal)
import ctx._

val query = dynamicQuery[Custom].filter(v =>
nameFilter.map(name => quote(sql"${v.name} == ${lift(name)}".asCondition))
.reduce((l,r) => quote(l || r))
)
val sql = ctx.translate(query)
assert(sql.contains("'a'"))
assert(sql.contains("'b'"))
}
}

0 comments on commit 167e404

Please sign in to comment.