Skip to content

Commit

Permalink
Fixed bug for string literals immediately following keyword. #123
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-dunwiddie committed Jun 19, 2024
1 parent e0529c2 commit d5f2cc8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions TSQL_Parser/TSQL_Parser/TSQLTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ private void SetCurrent()
case '\t':
case '\r':
case '\n':
case '\'':
case '.':
case ',':
case ';':
Expand Down
25 changes: 23 additions & 2 deletions TSQL_Parser/Tests/Clauses/SelectClauseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,27 @@ public void SelectClause_UnaryOperator()
Assert.AreEqual(TSQLExpressionType.Constant, tsqlOperator.RightSide.Type);
Assert.AreEqual(1, tsqlOperator.RightSide.AsConstant.Literal.AsNumericLiteral.Value);
}
}
}
}

[Test]
public void SelectClause_NoWhitespace()
{
using (StringReader reader = new StringReader(
@"SELECT'1'"))
using (ITSQLTokenizer tokenizer = new TSQLTokenizer(reader))
{
Assert.IsTrue(tokenizer.MoveNext());

TSQLSelectClause select = new TSQLSelectClauseParser().Parse(tokenizer);
Assert.AreEqual(2, select.Tokens.Count);

Assert.AreEqual(1, select.Columns.Count);

TSQLSelectColumn column = select.Columns[0];

Assert.IsNull(column.ColumnAlias);
Assert.AreEqual(TSQLExpressionType.Constant, column.Expression.Type);
}
}
}
}

1 comment on commit d5f2cc8

@bruce-dunwiddie
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referenced the wrong issue. Should have been #132 .

Please sign in to comment.