From 429d882951801e31d0d57775870afdb94e0e95fb Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Wed, 19 Jun 2024 07:36:51 +0200 Subject: [PATCH 1/2] No-op if engineedition is 6 or 11 due to lack of support for ASSEMBLYPROPERTY function fixes #2588 --- .../src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs index e71e20514e..dac6478ea5 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs @@ -51,11 +51,13 @@ private void addUDTsToDataTypesTable(DataTable dataTypesTable, SqlConnection con SqlCommand engineEditionCommand = connection.CreateCommand(); engineEditionCommand.CommandText = "SELECT SERVERPROPERTY('EngineEdition');"; - var engineEdition = (int)engineEditionCommand.ExecuteScalar()!; + var engineEdition = (int)engineEditionCommand.ExecuteScalar(); - if (engineEdition == 9) + if (engineEdition is 6 or 9 or 11) { - // Azure SQL Edge throws an exception when querying sys.assemblies + // Azure SQL Edge (9) throws an exception when querying sys.assemblies + // Azure Synapse Analytics (6) and Azure Synapse serverless SQL pool (11) + // do not support ASSEMBLYPROPERTY return; } From cdbbb0b3ffec6a6470a6d13017dcf9a2319e3fb6 Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Tue, 25 Jun 2024 12:44:08 +0200 Subject: [PATCH 2/2] PR feedback --- .../src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs index dac6478ea5..da39c1f375 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Data; using System.Data.Common; using System.IO; @@ -17,7 +18,7 @@ internal sealed class SqlMetaDataFactory : DbMetaDataFactory private const string ServerVersionNormalized90 = "09.00.0000"; private const string ServerVersionNormalized10 = "10.00.0000"; - + private readonly HashSet _assemblyPropertyUnsupportedEngines = new() { 6, 9, 11 }; public SqlMetaDataFactory(Stream XMLStream, string serverVersion, @@ -53,7 +54,7 @@ private void addUDTsToDataTypesTable(DataTable dataTypesTable, SqlConnection con engineEditionCommand.CommandText = "SELECT SERVERPROPERTY('EngineEdition');"; var engineEdition = (int)engineEditionCommand.ExecuteScalar(); - if (engineEdition is 6 or 9 or 11) + if (_assemblyPropertyUnsupportedEngines.Contains(engineEdition)) { // Azure SQL Edge (9) throws an exception when querying sys.assemblies // Azure Synapse Analytics (6) and Azure Synapse serverless SQL pool (11)