Skip to content

Commit 2ca9f7c

Browse files
committed
fix match criteria with group
1 parent d4f33e7 commit 2ca9f7c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sql/src/main/scala/app/softnetwork/elastic/sql/SQLWhere.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,19 @@ case class SQLMatch(
456456
private[this] def toCriteria(matches: List[ElasticMatch], curr: SQLCriteria): SQLCriteria =
457457
matches match {
458458
case Nil => curr
459-
case single :: Nil => SQLPredicate(curr, Or, single, group = true)
460-
case first :: rest => toCriteria(rest, SQLPredicate(curr, Or, first, group = true))
459+
case single :: Nil => SQLPredicate(curr, Or, single)
460+
case first :: rest => toCriteria(rest, SQLPredicate(curr, Or, first))
461461
}
462462

463-
lazy val criteria: SQLCriteria = {
464-
identifiers.map(id => ElasticMatch(id, value, None)) match {
463+
lazy val criteria: SQLCriteria =
464+
(identifiers.map(id => ElasticMatch(id, value, None)) match {
465465
case Nil => throw new IllegalArgumentException("No identifiers for MATCH")
466466
case single :: Nil => single
467467
case first :: rest => toCriteria(rest, first)
468+
}) match {
469+
case p: SQLPredicate => p.copy(group = true)
470+
case other => other
468471
}
469-
}
470472

471473
override def asFilter(currentQuery: Option[ElasticBoolQuery]): ElasticFilter = criteria match {
472474
case predicate: SQLPredicate => predicate.copy(group = true).asFilter(currentQuery)

0 commit comments

Comments
 (0)