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 d5f2cc8 commit e21b200
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
3 changes: 2 additions & 1 deletion TSQL_Parser/TSQL_Parser/TSQLTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ private void SetCurrent()
case '\r':
case '\n':
case '\'':
case '.':
case '\"':
case '.':
case ',':
case ';':
case '(':
Expand Down
6 changes: 0 additions & 6 deletions TSQL_Parser/TSQL_Parser/Tokens/TSQLIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ internal protected TSQLIdentifier(
.Substring(1, Text.Length - 2)
.Replace("\"\"", "\"");
}
else if (Text.StartsWith("N\""))
{
Name = Text
.Substring(2, Text.Length - 3)
.Replace("\"\"", "\"");
}
else
{
Name = Text;
Expand Down
13 changes: 3 additions & 10 deletions TSQL_Parser/Tests/Tokens/IdentifierTokenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ public void IdentifierToken_QuotedIdentifier()
}

[Test]
public void IdentifierToken_QuotedUnicodeIdentifier()
public void IdentifierToken_UnicodeLiteral()
{
List<TSQLToken> tokens = TSQLTokenizer.ParseTokens("N\"name\" ", useQuotedIdentifiers: true, includeWhitespace: true);
List<TSQLToken> tokens = TSQLTokenizer.ParseTokens("N\'name\' ", useQuotedIdentifiers: true, includeWhitespace: true);
TokenComparisons.CompareTokenLists(
new List<TSQLToken>()
{
new TSQLIdentifier(0, "N\"name\""),
new TSQLStringLiteral(0, "N\'name\'"),
new TSQLWhitespace(7, " ")
},
tokens);
Expand Down Expand Up @@ -183,12 +183,5 @@ public void IdentifierToken_QuotedName()
TSQLIdentifier token = new TSQLIdentifier(0, "\"name\"");
Assert.AreEqual("name", token.Name);
}

[Test]
public void IdentifierToken_QuotedUnicodeName()
{
TSQLIdentifier token = new TSQLIdentifier(0, "N\"name\"");
Assert.AreEqual("name", token.Name);
}
}
}

0 comments on commit e21b200

Please sign in to comment.