Skip to content

Commit ff1349c

Browse files
committed
update query normalization before parsing it
1 parent dc226a7 commit ff1349c

File tree

1 file changed

+5
-1
lines changed
  • sql/src/main/scala/app/softnetwork/elastic/sql/parser

1 file changed

+5
-1
lines changed

sql/src/main/scala/app/softnetwork/elastic/sql/parser/Parser.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ object Parser
6969
query: String
7070
): Either[ParserError, Either[SQLSearchRequest, SQLMultiSearchRequest]] = {
7171
val normalizedQuery =
72-
query.split("\n").map(_.trim).filterNot(_.isEmpty).filterNot(_.startsWith("--")).mkString(" ")
72+
query
73+
.split("\n")
74+
.map(_.split("--")(0).trim)
75+
.filterNot(w => w.isEmpty || w.startsWith("--"))
76+
.mkString(" ")
7377
val reader = new PackratReader(new CharSequenceReader(normalizedQuery))
7478
parse(requests, reader) match {
7579
case NoSuccess(msg, _) =>

0 commit comments

Comments
 (0)