Skip to content

Commit

Permalink
Fix comment detection
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanovicz committed Apr 25, 2022
1 parent 040a194 commit 5d5dc6d
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ public static List<String> splitStatements(String query, Character identifierQuo
Stack<SplitState> state = new Stack<>();
state.push(SplitState.NORMAL);
int dollars = 0;
boolean afterHyphen = false;
Character c = null, prevChar = null;
int parLevel = 0;
StringBuilder currentQuery = new StringBuilder();
for (int i = 0; i < query.length(); ++i)
{
Character c = query.charAt(i);
prevChar = c;
c = query.charAt(i);
if(state.peek() != SplitState.COMMENT) currentQuery.append(c);
switch (state.peek())
{
Expand All @@ -199,16 +200,11 @@ public static List<String> splitStatements(String query, Character identifierQuo
{
case '-':
{
if (afterHyphen)
if (prevChar != null && prevChar == '-')
{
afterHyphen = false;
state.push(SplitState.COMMENT);
currentQuery.delete(currentQuery.length() - 2, currentQuery.length());
}
else
{
afterHyphen = true;
}
break;
}
case '\'':
Expand Down

0 comments on commit 5d5dc6d

Please sign in to comment.