Skip to content

Commit a8e4f88

Browse files
committed
fix buckets
1 parent afa33fd commit a8e4f88

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sql/src/main/scala/app/softnetwork/elastic/sql/query/SQLSearchRequest.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,19 @@ case class SQLSearchRequest(
5454

5555
def update(): SQLSearchRequest = {
5656
(for {
57-
from <- Option(this.copy(from = from.update(this)))
58-
select <- Option(from.copy(select = select.update(from)))
57+
from <- Option(this.copy(from = from.update(this)))
58+
select <- Option(
59+
from.copy(
60+
select = select.update(from),
61+
groupBy = groupBy.map(_.update(from)),
62+
having = having.map(_.update(from))
63+
)
64+
)
5965
where <- Option(select.copy(where = where.map(_.update(select))))
60-
groupBy <- Option(where.copy(groupBy = groupBy.map(_.update(where))))
61-
having <- Option(groupBy.copy(having = having.map(_.update(groupBy))))
62-
updated <- Option(having.copy(orderBy = orderBy.map(_.update(having))))
63-
} yield updated).get
66+
updated <- Option(where.copy(orderBy = orderBy.map(_.update(where))))
67+
} yield updated).getOrElse(
68+
throw new IllegalStateException("Failed to update SQLSearchRequest")
69+
)
6470
}
6571

6672
lazy val scriptFields: Seq[Field] = select.fields.filter(_.isScriptField)

0 commit comments

Comments
 (0)