Skip to content

Commit 3953e73

Browse files
committed
Fix tests and PR feedback
1 parent ecfca89 commit 3953e73

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
using Microsoft.Identity.Client;
2525
using Microsoft.SqlServer.Server;
2626
using System.Security.Authentication;
27-
using System.Linq;
28-
2927

3028
#if NETFRAMEWORK
3129
using System.Reflection;
@@ -791,18 +789,17 @@ internal static Version GetAssemblyVersion()
791789
/// </summary>
792790
/// <remarks>This array contains predefined endpoint strings used to identify Azure Synapse and
793791
/// associated services, such as Fabric Data Warehouse and Power BI Data Warehouse.</remarks>
794-
internal static readonly string[] s_azureSynapseEndpoints = { AZURE_SYNAPSE,
795-
FABRIC_DATAWAREHOUSE,
792+
internal static readonly string[] s_azureSynapseEndpoints = { FABRIC_DATAWAREHOUSE,
796793
PBI_DATAWAREHOUSE,
797794
PBI_DATAWAREHOUSE2,
798795
PBI_DATAWAREHOUSE3 };
799796

800-
internal static readonly string[] s_azureSynapseOnDemandEndpoints = s_azureSqlServerOnDemandEndpoints
801-
.Concat(s_azureSynapseEndpoints)
802-
.ToArray();
797+
internal static readonly string[] s_azureSynapseOnDemandEndpoints = [.. s_azureSqlServerOnDemandEndpoints, .. s_azureSynapseEndpoints];
798+
803799
internal static bool IsAzureSynapseOnDemandEndpoint(string dataSource)
804800
{
805-
return IsEndpoint(dataSource, s_azureSynapseOnDemandEndpoints);
801+
return IsEndpoint(dataSource, s_azureSynapseOnDemandEndpoints)
802+
|| dataSource.IndexOf(AZURE_SYNAPSE, StringComparison.OrdinalIgnoreCase) >= 0;
806803
}
807804

808805
internal static bool IsAzureSqlServerEndpoint(string dataSource)
@@ -846,7 +843,7 @@ private static bool IsEndpoint(string dataSource, string[] endpoints)
846843
// check if servername ends with any endpoints
847844
foreach (var endpoint in endpoints)
848845
{
849-
if (length > endpoint.Length)
846+
if (length >= endpoint.Length)
850847
{
851848
if (string.Compare(dataSource, length - endpoint.Length, endpoint, 0, endpoint.Length, StringComparison.OrdinalIgnoreCase) == 0)
852849
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ public void ConnectionString_WithOnlyComma()
11001100
[InlineData("myserver.database.windows.net")]
11011101
[InlineData("myserver.database.cloudapi.de")]
11021102
[InlineData("myserver.database.usgovcloudapi.net")]
1103+
[InlineData("myserver.DATABASE.usgovcloudapi.net")]
11031104
[InlineData("myserver.database.chinacloudapi.cn")]
11041105
[InlineData("myserver.database.fabric.microsoft.com")]
11051106
public void ConnectionRetryForAzureDbEndpoints(string serverName)
@@ -1112,8 +1113,10 @@ public void ConnectionRetryForAzureDbEndpoints(string serverName)
11121113

11131114
[Theory]
11141115
[InlineData("myserver-ondemand.sql.azuresynapse.net")]
1116+
[InlineData("myserver-ondemand.SQL.azuresynapse.net")]
11151117
[InlineData("someserver-ondemand.database.windows.net")]
11161118
[InlineData("datawarehouse.fabric.microsoft.com")]
1119+
[InlineData("datawarehouse.FABRIC.microsoft.com")]
11171120
[InlineData("datawarehouse.pbidedicated.microsoft.com")]
11181121
[InlineData("someserver.pbidedicated.microsoft.com")]
11191122
[InlineData("someserver.pbidedicated.windows.net")]

0 commit comments

Comments
 (0)