Skip to content

Commit 326a242

Browse files
authored
Cleanup, Tests | MultipartIdentifier (#3891)
1 parent ae9294b commit 326a242

File tree

8 files changed

+506
-407
lines changed

8 files changed

+506
-407
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs

Lines changed: 125 additions & 135 deletions
Large diffs are not rendered by default.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ private string CreateInitialQuery()
424424
string[] parts;
425425
try
426426
{
427-
parts = MultipartIdentifier.ParseMultipartIdentifier(DestinationTableName, "[\"", "]\"", Strings.SQL_BulkCopyDestinationTableName, true);
427+
parts = MultipartIdentifier.ParseMultipartIdentifier(DestinationTableName, Strings.SQL_BulkCopyDestinationTableName, true);
428428
}
429429
catch (Exception e)
430430
{
@@ -578,7 +578,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
578578
throw SQL.BulkLoadNoCollation();
579579
}
580580

581-
string[] parts = MultipartIdentifier.ParseMultipartIdentifier(DestinationTableName, "[\"", "]\"", Strings.SQL_BulkCopyDestinationTableName, true);
581+
string[] parts = MultipartIdentifier.ParseMultipartIdentifier(DestinationTableName, Strings.SQL_BulkCopyDestinationTableName, true);
582582
updateBulkCommandText.AppendFormat("insert bulk {0} (", ADP.BuildMultiPartName(parts));
583583

584584
// Throw if there is a transaction but no flag is set

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommand.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,11 +1291,9 @@ internal void DeriveParameters()
12911291
// Use common parser for SqlClient and OleDb - parse into 4 parts - Server, Catalog,
12921292
// Schema, ProcedureName
12931293
string[] parsedSProc = MultipartIdentifier.ParseMultipartIdentifier(
1294-
name: CommandText,
1295-
leftQuote: "[\"",
1296-
rightQuote: "]\"",
1294+
identifier: CommandText,
12971295
property: Strings.SQL_SqlCommandCommandText,
1298-
ThrowOnEmptyMultipartName: false);
1296+
throwOnEmptyMultipartIdentifier: false);
12991297

13001298
if (string.IsNullOrEmpty(parsedSProc[3]))
13011299
{
@@ -2809,10 +2807,8 @@ private void SetUpRPCParameters(_SqlRPC rpc, bool inSchema, SqlParameterCollecti
28092807
{
28102808
string[] parts = MultipartIdentifier.ParseMultipartIdentifier(
28112809
parameter.TypeName,
2812-
leftQuote: "[\"",
2813-
rightQuote: "]\"",
28142810
property: Strings.SQL_TDSParserTableName,
2815-
ThrowOnEmptyMultipartName: false);
2811+
throwOnEmptyMultipartIdentifier: false);
28162812
// @TODO: Combine this and inner if statement
28172813
if (parts?.Length == 4)
28182814
{

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,7 @@ internal static string[] ParseTypeName(string typeName, bool isUdtTypeName)
25142514
try
25152515
{
25162516
string errorMsg = isUdtTypeName ? Strings.SQL_UDTTypeName : Strings.SQL_TypeName;
2517-
return MultipartIdentifier.ParseMultipartIdentifier(typeName, "[\"", "]\"", '.', 3, true, errorMsg, true);
2517+
return MultipartIdentifier.ParseMultipartIdentifier(typeName, errorMsg, true, limit: 3);
25182518
}
25192519
catch (ArgumentException)
25202520
{

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ private void ParseMultipartName()
777777
{
778778
if (_multipartName != null)
779779
{
780-
string[] parts = MultipartIdentifier.ParseMultipartIdentifier(_multipartName, "[\"", "]\"", Strings.SQL_TDSParserTableName, false);
780+
string[] parts = MultipartIdentifier.ParseMultipartIdentifier(_multipartName, Strings.SQL_TDSParserTableName, false);
781781
_serverName = parts[0];
782782
_catalogName = parts[1];
783783
_schemaName = parts[2];

src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<!-- compile them as part of this project. This is not ideal in the slightest, and they -->
2727
<!-- should ideally be UnitTests if they need to access internals. But detangling these -->
2828
<!-- tests is far beyond the scope of the common project, so it is left as a TODO for now. -->
29-
<Compile Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs" />
3029
<Compile Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Packet.cs" />
3130
<Compile Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.Multiplexer.cs" />
3231
</ItemGroup>

src/Microsoft.Data.SqlClient/tests/FunctionalTests/MultipartIdentifierTests.cs

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)