Skip to content

Commit 531f178

Browse files
committed
Use IndexOf instead of hardcoded values
1 parent 7272117 commit 531f178

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

Test/SqlDom/ParserErrorsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6824,7 +6824,7 @@ RETURNS VARCHAR(20)
68246824
RETURN '$' + CAST(@amount AS VARCHAR)
68256825
END;
68266826
";
6827-
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax, new ParserErrorInfo(330, "SQL46026", "ENCRYPTION"));
6827+
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax, new ParserErrorInfo(scalarFunctionSyntax.IndexOf("ENCRYPTION"), "SQL46026", "ENCRYPTION"));
68286828

68296829
string scalarFunctionSyntax2 = @"CREATE OR ALTER FUNCTION dbo.ConcatNames
68306830
(
@@ -6837,7 +6837,7 @@ RETURNS NVARCHAR(101)
68376837
BEGIN
68386838
RETURN @first + ' ' + @last
68396839
END;";
6840-
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax2, new ParserErrorInfo(425, "SQL46010", "INLINE"));
6840+
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax2, new ParserErrorInfo(scalarFunctionSyntax2.IndexOf("INLINE"), "SQL46010", "INLINE"));
68416841

68426842
string scalarFunctionSyntax3 = @"CREATE OR ALTER FUNCTION dbo.CountProducts
68436843
(
@@ -6849,7 +6849,7 @@ WITH SCHEMABINDING
68496849
BEGIN
68506850
RETURN (SELECT COUNT(*) FROM @ProductTable)
68516851
END;";
6852-
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax3, new ParserErrorInfo(172, "SQL46026", "READONLY"));
6852+
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax3, new ParserErrorInfo(scalarFunctionSyntax3.IndexOf("READONLY"), "SQL46026", "READONLY"));
68536853

68546854
string scalarFunctionSyntax4 = @"CREATE OR ALTER FUNCTION sales.TotalSalesForRegion
68556855
(
@@ -6866,7 +6866,7 @@ FROM @SalesData
68666866
WHERE RegionId = @RegionId
68676867
)
68686868
END;";
6869-
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax4, new ParserErrorInfo(171, "SQL46010", "NULL"));
6869+
ParserTestUtils.ErrorTestFabricDW(scalarFunctionSyntax4, new ParserErrorInfo(scalarFunctionSyntax4.IndexOf("NULL"), "SQL46010", "NULL"));
68706870
}
68716871
}
68726872
}

Test/SqlDom/TestUtilities.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,7 @@ public static TSqlFragment ParseStringNoErrors(TSqlParser parser, string source)
394394
}
395395

396396
public static TSqlFragment ParseString(TSqlParser parser, string source, out IList<ParseError> errors)
397-
{
398-
#if NET
399-
// Convert line endings from \n to \r\n
400-
if (System.Environment.NewLine == "\n")
401-
source = source.ReplaceLineEndings("\r\n");
402-
#endif
403-
397+
{
404398
TSqlFragment fragment;
405399
using (StringReader sr = new StringReader(source))
406400
{

0 commit comments

Comments
 (0)