Skip to content

Commit 04249a2

Browse files
authored
Update to v161.47027.0 (#107)
1 parent 73cd2cb commit 04249a2

38 files changed

+785
-662
lines changed

Nuget/CHANGELOG.md

+75-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
21
# Introduction
32

43
This file will log substantial changes made to SMO between public releases to nuget.org.
54

5+
## 161.47027.0
6+
7+
- Fix distribution columns on scripting for taking into consideration more than one distribution column
8+
- Add new EXTGOV_OPERATION_GROUP audit action type
9+
- Force [quoted identifier on](https://github.com/microsoft/sqlmanagementobjects/issues/96) for table scripts
10+
- Fix EnumObjects sort by Schema
11+
- Add new enumeration values for SQL Server 2022 permissions
12+
- Script FIRST_ROW support for serverless Synapse
13+
614
## 161.47021.0
715

816
- Add `LedgerViewSchema` property to table objects
@@ -24,10 +32,10 @@ This file will log substantial changes made to SMO between public releases to nu
2432
- Add `LoginType` property to `ILoginOptions` interface.
2533
- `Login.PasswordPolicyEnforced` now returns `false` for Windows logins instead of throwing an exception
2634
- Remove net461 binaries from nuget packages
27-
- Added Scripting Support for Ledger tables for SQL 2022+
35+
- Added Scripting Support for Ledger tables for Sql 2022+
2836
- Change the `Size` property on `Server/Drive` objects to `System.Int64`. These objects don't have a C# wrapper class so it's not breaking any compilation.
29-
- Add support for SQL Server version 16
30-
- Add new permissions for SQL 2019+ to SMO enumerations
37+
- Add support for Sql Server version 16
38+
- Add new permissions for Sql 2019+ to SMO enumerations
3139
- Added External Stream object and External Streaming Jobs object for scripting
3240
- Add support for XML compression
3341

@@ -43,7 +51,7 @@ This file will log substantial changes made to SMO between public releases to nu
4351
## 161.46437.65
4452

4553
- Update Microsoft.Data.SqlClient dependency to version 3.0.0
46-
- Added Scripting Support for Ledger table in Azure SQLDB
54+
- Added Scripting Support for Ledger table in Azure Sql db
4755
- Change `Server.MasterDBPath` and `Server.MasterDBLogPath` properties to use `file_id` instead of `name` from `sys.database_files`
4856
- Enable Index creation for memory optimized tables in Azure
4957
- Fix Server/Logins to show external Logins for Azure SQLDB as they are now supported
@@ -122,7 +130,65 @@ This file will log substantial changes made to SMO between public releases to nu
122130
- Enabled Server.EnumServerAttributes API on Azure SQL Database
123131
- Enabled Lock enumeration APIs on Azure SQL Database
124132
- Deleted the Database.CheckIdentityValues API
125-
- Added new property "RequestMaximumMemoryGrantPercentageAsDouble" in WorkloadGroup to accept decimal values in Resource Governor (SQL 2019+).
126-
- Changed the netfx binaries in Microsoft.SqlServer.SqlManagementObjects package to use Microsoft.Data.SqlClient
127-
- Added a new package, Microsoft.SqlServer.SqlManagementObjects.SSMS, which only has netfx binaries and that uses System.Data.SqlClient
128-
133+
- Added new property "RequestMaximumMemoryGrantPercentageAsDouble" in WorkloadGroup to accept decimal values in Resource Governor (SQL2019 and above).
134+
- Fixed a scripting issue with statistics on filtered indexes where the filter from the index would be scripted with the UPDATE STATISTICS TSQL.
135+
- Enabled Security Policy and Security Predicate objects on Azure SQL DataWarehouse
136+
137+
## 160.2004021.0
138+
139+
- First non-preview 160 release, aligned with [SQL Server Management Studio](https://aka.ms/ssmsfullsetup) 18.5
140+
- Script extended properties for Azure SQL Database objects
141+
- Enable Jupyter Notebook output for SqlScriptPublishModel. SSMS 18.5 can output a Notebook for Azure Data Studio in Generate Scripts now.
142+
- Fix issue where Table.EnableAllIndexes(Recreate) did nothing
143+
- Fix Database.EnumObjectPermissions usage in NetStandard binaries
144+
- Remove FORCE ORDER hint from table enumeration that was causing major performance issues
145+
- Fix Transfer with PrefetchAllObjects == false for pre-Sql 2014 versions so it doesn't throw an exception
146+
- Extend value range for platform, name, and engineEdition JSON properties of SQL Assessment targets with arrays of strings:
147+
148+
```JSON
149+
"target": {
150+
"platform": ["Windows", "Linux"],
151+
"name": ["master", "temp"]
152+
}
153+
```
154+
155+
- Add 13 new [SQL Assessment rules](https://github.com/microsoft/sql-server-samples/blob/master/samples/manage/sql-assessment-api/release-notes.md)
156+
- Fix help link in XTPHashAvgChainBuckets SQL Assessment rule
157+
- Units for threshold parameter of FullBackup SQL Assessment rule changed from hours to days
158+
159+
## 160.201141.0-preview
160+
161+
- Remove unneeded "using" TSQL statements from Database.CheckTables method implementations
162+
- Enable ColumnMasterKey properties Signature and AllowEnclaveComputations for Azure SQL DB
163+
- Fix Database.EncryptionEnabled and Database.DatabaseEncryptionKey behavior during Database.Alter(). Now, this code will correctly create a new key using the server certificate named MyCertificate:
164+
165+
```C#
166+
db.EncryptionEnabled = true;
167+
db.DatabaseEncryptionKey.EncryptorName = "MyCertificate";
168+
db.DatabaseEncryptionKey.EncryptionAlgorithm = DatabaseEncryptionAlgorithm.Aes256;
169+
db.DatabaseEncryptionKey.EncryptionType = DatabaseEncryptionType.ServerCertificate;
170+
db.Alter()
171+
```
172+
173+
- Fixed the "like" and "contains" URN filter functions to work with parameters containing single quotes. These operators can be used to optimally initialize collections:
174+
175+
```C#
176+
// populate the collection with databases that have Name starting with "RDA"
177+
var server = Server(new ServerConnection(sqlConnection));
178+
server.Databases.ClearAndInitialize("[like(@Name, 'RDA%')]", new string[] { });
179+
```
180+
181+
- Make Table.Location property optional for creating or scripting external tables.
182+
- Enable scripting of ANSI_PADDING settings for Azure SQL Database tables.
183+
- Remove obsolete types ServerActiveDirectory and DatabaseActiveDirectory
184+
- Added BLOB_STORAGE scripting support for external data sources
185+
- Fixed [error scripting external tables](https://feedback.azure.com/forums/908035-sql-server/suggestions/38267746-cannot-script-external-table-in-ssms-18-2) for Azure SQL Database
186+
- Replace Microsoft.SqlServer.Management.SqlParser.dll with a dependency to its Nuget package
187+
188+
## 160.1911221.0-preview
189+
190+
- Increase major version from 15 to 16
191+
- Remove dependency on native batch parser from NetFx components
192+
- Change NetStandard client driver to Microsoft.Data.SqlClient
193+
- Add distribution property for DW materialized views
194+
- Script FILLFACTOR for indexes on Azure SQL Database

docs/media/certsettings.png

134 KB
Loading

init.cmd

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ doskey smoenum=pushd %BASEDIR%src\Microsoft\SqlServer\Management\SqlEnum\$*
2929
doskey clean=powershell.exe -ExecutionPolicy Unrestricted -File "%BASEDIR%init.ps1" -Clean
3030
doskey tst=pushd %BASEDIR%src\FunctionalTest\Smo\$*
3131

32-
3332
REM == Common test command:
3433
doskey rtests=pushd %BASEDIR%target\distrib\debug\net462$Tvstest.console.exe microsoft.sqlserver.test.smo.dll /logger:trx /TestCaseFilter:"(TestCategory != Staging)" /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings $*
3534
doskey netcoretests=pushd %BASEDIR%target\distrib\debug\netcoreapp3.1$Tvstest.console.exe microsoft.sqlserver.test.smo.dll /logger:trx /TestCaseFilter:"(TestCategory != Staging)" /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings $*

src/Codegen/cfg.xml

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
<property name="AutoCreateIncrementalStatisticsEnabled" generate="true" is_intrinsic="false" />
174174
<property name="AutoUpdateStatisticsEnabled" generate="true" is_intrinsic="false" />
175175
<property name="AzureEdition" generate="true" is_intrinsic="false" />
176+
<property name="RealEngineEdition" generate="false" is_intrinsic="false" />
176177
<property name="AzureServiceObjective" generate="true" is_intrinsic="false" />
177178
<property name="CaseSensitive" generate="true" is_intrinsic="false" />
178179
<!-- Change Tracking Properties for the database-->

src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</PropertyGroup>
9090
<PropertyGroup>
9191
<!-- these variables are referenced by packagebuild.proj for inclusion in nuspecs and used by packages.props -->
92-
<SqlParserPackageVersion>160.22504.0</SqlParserPackageVersion>
92+
<SqlParserPackageVersion>160.22510.0</SqlParserPackageVersion>
9393
<SqlClientPackage>Microsoft.Data.SqlClient</SqlClientPackage>
9494
<SqlClientPackageVersion>3.1.0</SqlClientPackageVersion>
9595
</PropertyGroup>

src/FunctionalTest/Smo/Agent/JobServerTests.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Data;
6-
using System.Diagnostics;
76
using System.Linq;
87
using Microsoft.SqlServer.Management.Common;
98
using Microsoft.SqlServer.Management.Sdk.Sfc;
@@ -18,10 +17,10 @@
1817
namespace Microsoft.SqlServer.Test.SMO.Agent
1918
{
2019
[TestClass]
21-
[SupportedServerVersionRange(Edition = Management.Common.DatabaseEngineEdition.Enterprise)]
2220
public class JobServerTests : SqlTestBase
2321
{
2422
[TestMethod]
23+
[SupportedServerVersionRange(Edition = Management.Common.DatabaseEngineEdition.Enterprise)]
2524
public void JobServer_PurgeJobHistory_generates_correct_query()
2625
{
2726
ExecuteTest(() =>
@@ -49,6 +48,7 @@ public void JobServer_PurgeJobHistory_generates_correct_query()
4948

5049
[TestMethod]
5150
[UnsupportedHostPlatform(SqlHostPlatforms.Linux)]
51+
[SupportedServerVersionRange(MinMajor = 16, Edition = DatabaseEngineEdition.Enterprise)]
5252
public void JobServer_EnumPerformanceCounters_returns_agent_counters()
5353
{
5454
ExecuteTest(() =>
@@ -70,6 +70,7 @@ public void JobServer_EnumPerformanceCounters_returns_agent_counters()
7070
}
7171

7272
[TestMethod]
73+
[SupportedServerVersionRange(Edition = Management.Common.DatabaseEngineEdition.Enterprise)]
7374
public void JobServer_Msx_methods_generate_correct_queries()
7475
{
7576
ExecuteTest(() =>
@@ -92,6 +93,8 @@ public void JobServer_Msx_methods_generate_correct_queries()
9293
}
9394

9495
[TestMethod]
96+
[SupportedServerVersionRange(Edition = Management.Common.DatabaseEngineEdition.Enterprise)]
97+
9598
public void JobServer_ErrorLog_methods_generate_correct_queries()
9699
{
97100
ExecuteTest(() =>
@@ -135,7 +138,9 @@ private Job CreateJob(string loginName = null)
135138
job.Refresh();
136139
return job;
137140
}
141+
138142
[TestMethod]
143+
[SupportedServerVersionRange(Edition = Management.Common.DatabaseEngineEdition.Enterprise)]
139144
public void JobServer_Job_methods()
140145
{
141146
ExecuteTest(() =>
@@ -180,6 +185,7 @@ public void JobServer_Job_methods()
180185
}
181186

182187
[TestMethod]
188+
[SupportedServerVersionRange(Edition = Management.Common.DatabaseEngineEdition.Enterprise)]
183189
public void JobServer_miscellaneous_methods_generate_correct_queries()
184190
{
185191
ExecuteTest(() =>

src/FunctionalTest/Smo/GeneralFunctionality/AuditSmoTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public void ServerAuditspecifications_Audit_Action_Types_In_DB_Should_Match_Enum
433433
UNION ALL SELECT name FROM (VALUES ('SELECT'),('UPDATE'),('INSERT'),('DELETE'),('EXECUTE'),('RECEIVE'),('REFERENCES')) actions(name)";
434434

435435
var dbAuditList = ServerContext.ConnectionContext.ExecuteWithResults(query).Tables[0].Rows.Cast<DataRow>().Select(row => row["name"].ToString());
436-
436+
System.Diagnostics.Trace.TraceInformation("Missing audit action types: {0}", string.Join(",", dbAuditList.Except(enumAttributeNames)));
437437
// enumAttributeNames is a superset of dbAuditList.
438438
Assert.That(enumAttributeNames, Is.SupersetOf(dbAuditList), @"Some types are missing in AuditActionType enum.
439439
Please, update enum AuditActionType in /src/Microsoft/SqlServer/Management/SqlEnum/enumstructs.cs");

src/FunctionalTest/Smo/GeneralFunctionality/DatabaseSmoTests.cs

+23-11
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,31 @@ public void EnumObjects_Sets_Synonym_Schema_And_Other_Properties()
119119
};
120120

121121
syn.Create();
122+
var script = database.ExecutionManager.RecordQueryText(() =>
123+
{
124+
// Now, we retrieve the same object we just created by calling EnumObjects()
125+
var objs = database.EnumObjects(DatabaseObjectTypes.Synonym, _SMO.SortOrder.Schema);
126+
var synobj = objs.Rows.Cast<System.Data.DataRow>().Where(r => (string)r["Name"] == expectedSynName).Single();
122127

123-
// Now, we retrieve the same object we just created by calling EnumObjects()
124-
var objs = database.EnumObjects(DatabaseObjectTypes.Synonym);
125-
var synobj = objs.Rows.Cast<System.Data.DataRow>().Where(r => (string)r["Name"] == expectedSynName).Single();
126-
127-
// The original bug was that Schema was coming back as blank, because there was an assumption
128-
// that synonyms did not have a schema (which was incorrect)
129-
Assert.That(synobj["Schema"], Is.EqualTo(expectedSynSchema), "Unexpected value for Schema");
128+
// The original bug was that Schema was coming back as blank, because there was an assumption
129+
// that synonyms did not have a schema (which was incorrect)
130+
Assert.That(synobj["Schema"], Is.EqualTo(expectedSynSchema), "Unexpected value for Schema");
130131

131-
// While we are at it, let's also check the other properties...
132-
Assert.That(synobj["DatabaseObjectTypes"], Is.EqualTo("Synonym"), "Unexpected value for DatabaseObjectTypes");
133-
Assert.That(synobj["Name"], Is.EqualTo(expectedSynName), "Unexpected value for Name");
134-
Assert.That(synobj["Urn"], Is.EqualTo(syn.Urn.ToString()), "Unexpected value for Urn");
132+
// While we are at it, let's also check the other properties...
133+
Assert.That(synobj["DatabaseObjectTypes"], Is.EqualTo("Synonym"), "Unexpected value for DatabaseObjectTypes");
134+
Assert.That(synobj["Name"], Is.EqualTo(expectedSynName), "Unexpected value for Name");
135+
Assert.That(synobj["Urn"], Is.EqualTo(syn.Urn.ToString()), "Unexpected value for Urn");
136+
}, alsoExecute: true);
137+
Assert.That(script.ToSingleString(), Contains.Substring("ORDER BY [Schema]"), "EnumObjects (SortOrder.Schema)");
138+
if (database.DatabaseEngineType == DatabaseEngineType.Standalone)
139+
{
140+
script = database.ExecutionManager.RecordQueryText(() => database.EnumObjects(), alsoExecute: true);
141+
Assert.That(script.ToSingleString(), Contains.Substring("ORDER BY [DatabaseObjectTypes]"), "EnumObjects()");
142+
}
143+
script = database.ExecutionManager.RecordQueryText(() => database.EnumObjects(DatabaseObjectTypes.Table, _SMO.SortOrder.Name), alsoExecute: true);
144+
Assert.That(script.ToSingleString(), Contains.Substring("ORDER BY [Name]"), "EnumObjects()");
145+
script = database.ExecutionManager.RecordQueryText(() => database.EnumObjects(DatabaseObjectTypes.View, _SMO.SortOrder.Urn), alsoExecute: true);
146+
Assert.That(script.ToSingleString(), Contains.Substring("ORDER BY [Urn]"), "EnumObjects()");
135147
});
136148
}
137149

src/FunctionalTest/Smo/GeneralFunctionality/DwSmoTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void Server_Databases_collection_enumerates_without_exception()
6565
}
6666

6767
});
68-
Assert.That(databases.FirstOrDefault(d => d.EndsWith("Unknown")), Is.Not.Null, "Expected at least one Unknown engine edition. Make sure the test server has a paused DW instance. " + String.Join(",", databases));
6968
});
7069
}
7170
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright (c) Microsoft.
2+
// Licensed under the MIT license.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Data;
7+
using System.Globalization;
8+
using System.Linq;
9+
using System.Text;
10+
using Microsoft.SqlServer.Management.Common;
11+
using Microsoft.SqlServer.Management.Smo;
12+
using Microsoft.SqlServer.Test.Manageability.Utils.TestFramework;
13+
using Microsoft.VisualStudio.TestTools.UnitTesting;
14+
using NUnit.Framework;
15+
using Assert = NUnit.Framework.Assert;
16+
17+
namespace Microsoft.SqlServer.Test.SMO.GeneralFunctionality
18+
{
19+
[TestClass]
20+
[UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlOnDemand)]
21+
public class PermissionsEnumTests : SqlTestBase
22+
{
23+
[TestMethod]
24+
public void PermEnum_DatabasePermissionSetValue_enum_is_complete()
25+
{
26+
ExecuteTest(() =>
27+
{
28+
CompareEnumToServerPermissions(typeof(DatabasePermissionSetValue), @"select type, permission_name from sys.fn_builtin_permissions('DATABASE')");
29+
});
30+
}
31+
32+
[TestMethod]
33+
public void PermEnum_ServerPermissionSetValue_enum_is_complete()
34+
{
35+
ExecuteTest(() =>
36+
{
37+
CompareEnumToServerPermissions(typeof(ServerPermissionSetValue), @"select type, permission_name from sys.fn_builtin_permissions('SERVER')");
38+
});
39+
}
40+
41+
[TestMethod]
42+
public void PermEnum_ObjectPermissionSetValue_enum_is_complete()
43+
{
44+
ExecuteTest(() =>
45+
{
46+
CompareEnumToServerPermissions(typeof(ObjectPermissionSetValue), @"select type, permission_name from sys.fn_builtin_permissions(DEFAULT) where class_desc <> 'SERVER' and class_desc <> 'DATABASE'");
47+
});
48+
}
49+
private void CompareEnumToServerPermissions(Type enumType, string permissionQuery)
50+
{
51+
var permissionTypes = GetAttributeValues<PermissionTypeAttribute>(enumType);
52+
var permissionNames = GetAttributeValues<PermissionNameAttribute>(enumType);
53+
var permissionList = ServerContext.ConnectionContext.ExecuteWithResults(permissionQuery).Tables[0].Rows.Cast<DataRow>();
54+
var maxValue = Enum.GetValues(enumType).Cast<int>().Max();
55+
var textInfo = new CultureInfo("en-US", false).TextInfo;
56+
var missingValues = new StringBuilder();
57+
foreach (var row in permissionList)
58+
{
59+
var name = row["permission_name"].ToString().Trim();
60+
var type = row["type"].ToString().Trim();
61+
if (!permissionNames.Contains(name) || !permissionTypes.Contains(type))
62+
{
63+
var enumName = new StringBuilder();
64+
foreach (var s in name.Split(' '))
65+
{
66+
enumName.Append(textInfo.ToTitleCase(s.ToLowerInvariant()));
67+
}
68+
enumName.Append($" = {++maxValue},");
69+
missingValues.Append($"{Environment.NewLine}[PermissionType(\"{type}\")]{Environment.NewLine}[PermissionName(\"{name}\")]{Environment.NewLine}{enumName}{Environment.NewLine}");
70+
}
71+
}
72+
Assert.That(missingValues.ToString(), Is.Empty, $"{ enumType.Name} is incomplete. Add the missing values.");
73+
}
74+
/// <summary>
75+
/// Returns the set of string attribute values associated with the given enumeration.
76+
/// </summary>
77+
/// <typeparam name="T"></typeparam>
78+
/// <param name="enumType"></param>
79+
/// <returns></returns>
80+
static internal IEnumerable<string> GetAttributeValues<T>(Type enumType) where T: StringValueAttribute {
81+
return new HashSet<string>(Enum.GetNames(enumType).Select(n => enumType.GetMember(n).Single().GetCustomAttributes(typeof(T), false).Cast<T>().Single().Value));
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)