Skip to content

Commit 7377088

Browse files
authored
Merge pull request #158 from microsoft/sync/171.30.0
Sync to 171.30.0
2 parents 3ae2731 + 545b943 commit 7377088

File tree

67 files changed

+1639
-1813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1639
-1813
lines changed

CHANGELOG.md

+32-11
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,38 @@
33
Update this document for externally visible changes. Put most recent changes first.
44
Once we push a new version to nuget.org add a double hash header for that version.
55

6+
## 171.30.0
7+
8+
- <b>BREAKING</b>: Move Transfer interfaces to Smo.Extended and remove unused/non-implemented interfaces. This is a breaking change that requires recompilation of apps that use Transfer.
9+
- Change base class of `ConnectionException` to `Exception`
10+
- Update major package version to 171
11+
- add new database permission alter any external mirror for azure sql database
12+
613
## 170.23.0
714

15+
- Fix bug where creating Microsoft Entra ID logins for Azure SQL database and On Prem databases was disabled
816
- Upgraded SqlClient to 5.1.2 and removed direct Azure SDK dependencies from the nuget package
917
- Fix createdrop script error for versioned table in ledger database
18+
- Fix database scoped extended events enumeration on Azure SQL database instances having DATABASE_DEFAULT catalog collation
1019
- Improve scripting of dependency objects in Azure SQL database
1120
- Added `ObjectId` parameter in User and Login create options
1221
- Fix `Database.PrefetchObjects` not to throw for SQL version earlier than 2016
13-
14-
## 170.23.0, 161.48050.0
1522
- Add ledger support in Database create options for MI in SSMS
23+
- Add `OwnerLoginName` property to `JobSchedule` per [issue 120](https://github.com/microsoft/sqlmanagementobjects/issues/120)
1624
- Fixed the `Database.AvailabilityDatabaseSynchronizationState` property to reflect the correct synchronization state of MI databases in Managed Instance Link
17-
- Fix database scoped extended events enumeration on Azure SQL database instances having DATABASE_DEFAULT catalog collation
1825

19-
## 170.20.0
20-
- Add `OwnerLoginName` property to `JobSchedule` per [issue 120](https://github.com/microsoft/sqlmanagementobjects/issues/120)
26+
## 170.18.0
27+
28+
- Add `SearchPropertyList` support for Azure SQL Database
2129

22-
## 170.18.0, 161.48044.0
30+
## 170.17.0, 161.48044.0
2331

2432
- Fix issue where `Table.Create` and `View.Create` were querying the server for indexes
25-
- Add `SearchPropertyList` support for Azure SQL Database
2633
- Add option to generate scripts exclusively for Data Classification, Create a new SMO object `SensitivityClassification` under `Database`
2734
- Add support for creating Certificate objects using binary-encoded certificate bytes (https://github.com/microsoft/sqlmanagementobjects/issues/132)
35+
- Fix for incorrect scripting of Database objects targeting SQL Managed Instances
2836

29-
30-
## 161.48036.0
37+
## 170.13.0, 161.48036.0
3138

3239
- Fix [issue](https://github.com/microsoft/sqlmanagementobjects/issues/123) with `Table.Alter` for Synapse
3340
- Add initial replication of contained AG system databases to AG creation
@@ -36,20 +43,34 @@ Once we push a new version to nuget.org add a double hash header for that versio
3643
- Enable datetime masked columns
3744
- Update product display names
3845
- Add database, server, and object permissions for SQL Server 2019 and SQL Server 2022
46+
- Add support for strict encryption and HostNameInCertificate
47+
3948

40-
## 161.48028.0
49+
## 170.12.0, 161.48028.0
4150

4251
- Add certificate and asymmetric key user support for Azure DB
4352
- Change the name of the XML file used by SSMS 19 to RegSrvr16.xml
53+
- Change `SetDefaultInitFields` to [allow inclusion of properties unsupported](https://github.com/microsoft/sqlmanagementobjects/issues/84) by the connected SQL edition.
4454

45-
## 161.47027.0
55+
## 170.11.0, 161.47027.0
4656

4757
- Fix distribution columns on scripting for taking into consideration more than one distribution column
4858
- Add new EXTGOV_OPERATION_GROUP audit action type
4959
- Force [QUOTED_IDENTIFIER ON](https://github.com/microsoft/sqlmanagementobjects/issues/96) for all tables
5060
- Change Databases enumeration on Azure DB to ignore `sys.databases` entries that don't have an entry in `sys.database_service_objectives`. Prevents attempted logins to user databases when enumerating databases on the logical master
5161
- Update permissions enumeration for SQL Server 2022
5262

63+
## 170.6.0-preview
64+
65+
- Add SmoMetadataProvider preview package
66+
- Replace netcoreapp3.1 with net6
67+
68+
## 170.5.0-preview
69+
70+
- First public 170 build on Nuget.org
71+
- Upgrade Microsoft.Data.SqlClient to version 5.0
72+
- Upgrade build tools to VS2022
73+
5374
## 161.47021.0
5475

5576
- Add `LedgerViewSchema` property to table objects

Packages.props

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
<ItemGroup>
4444
<!-- GlobalPackageReference packages are installed and processed by msbuild but are not referenced by the C# compiler -->
4545
<GlobalPackageReference Include="StrawberryPerl" Version="5.28.0.1" GeneratePathProperty="true" />
46+
<GlobalPackageReference Include="Microsoft.TestPlatform" Version="17.6.0" GeneratePathProperty="true" />
47+
4648
</ItemGroup>
4749

4850
</Project>

SmoBuild/Version.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<InformationalVersion>$(AssemblyFileVersion)</InformationalVersion>
1414
<FileVersion>$(AssemblyFileVersion)</FileVersion>
1515
<Version>$(AssemblyFileVersion)</Version>
16-
<PackageMajorVersionIncrement Condition="'$(PackageMajorVersionIncrement)'==''">0</PackageMajorVersionIncrement>
16+
<PackageMajorVersionIncrement Condition="'$(PackageMajorVersionIncrement)'==''">1</PackageMajorVersionIncrement>
1717
<PackageVersion Condition="'$(PackageVersion)' == ''">$(AssemblyMajorVersion)$(PackageMajorVersionIncrement).$(AssemblyBuildVersion).$(AssemblyBuildRevision)</PackageVersion>
1818
<AssemblyVersion Condition="'$(AssemblyVersion)'==''">$(AssemblyMajorVersion).$(AssemblyMinorVersion).0.0</AssemblyVersion>
1919
</PropertyGroup>

src/Codegen/cfg.xml

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<property name="BuildNumber" generate="true" is_intrinsic="false" />
4747
<property name="IsCaseSensitive" generate="true" is_intrinsic="false" />
4848
<property name="IsFullTextInstalled" generate="true" is_intrinsic="false" />
49+
<property name="IsJsonDataTypeEnabled" generate="true" is_intrinsic="false" />
4950
<property name="MasterDBLogPath" generate="true" is_intrinsic="false" />
5051
<property name="MasterDBPath" generate="true" is_intrinsic="false" />
5152
<property name="ErrorLogPath" generate="true" is_intrinsic="false" />
@@ -1604,6 +1605,8 @@
16041605
<object class_name="EdgeConstraintClause" collection_name="EdgeConstraintClauses" urn="Server[@Name='']/Database/Table/EdgeConstraint/EdgeConstraintClause" is_design_mode="true" parent_type="SqlSmoObject" parent_mode="Design" possible_parents="EdgeConstraint" >
16051606
<property name="From" generate="true" is_intrinsic="false" />
16061607
<property name="To" generate="true" is_intrinsic="false" />
1608+
<property name="FromSchema" generate="true" is_intrinsic="false" />
1609+
<property name="ToSchema" generate="true" is_intrinsic="false" />
16071610
</object>
16081611

16091612
<!--End: Edge constraint def-->

src/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
</PropertyGroup>
8888
<PropertyGroup>
8989
<!-- these variables are referenced by packagebuild.proj for inclusion in nuspecs and used by packages.props -->
90-
<SqlParserPackageVersion>171.24.0</SqlParserPackageVersion>
90+
<SqlParserPackageVersion>172.0.1</SqlParserPackageVersion>
9191
<SqlClientPackage>Microsoft.Data.SqlClient</SqlClientPackage>
92-
<SqlClientPackageVersion>5.1.2</SqlClientPackageVersion>
92+
<SqlClientPackageVersion>5.1.4</SqlClientPackageVersion>
9393
</PropertyGroup>
9494
<Import Project="$(BuildPropsDir)\StrongName.props" Condition="Exists('$(BuildPropsDir)\StrongName.props')" />
9595
<Import Project="$(BuildPropsDir)\Version.props" />

src/FunctionalTest/Framework/TestFramework/SqlTestBase.cs

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
3636
// We don't control all dependency DLL versions in every environment so just
3737
// load whatever version is in the same folder as the test, if possible.
3838
var an = new AssemblyName(args.Name);
39+
if (an.Name.ToLower().EndsWith(".resources"))
40+
{
41+
// We are not really in the business of loading resources, so avoid unnecessary tracing...
42+
return null;
43+
}
44+
3945
var dll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), an.Name + ".dll");
4046
Trace.TraceInformation($"Trying to load dll:{dll}");
4147
try

src/FunctionalTest/Smo/ScriptingTests/Column_SmoTestSuite.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ [c] [int] NULL
9393
});
9494
}
9595

96-
private static IEnumerable<ColumnProperties> GetAllDataTypeColumns()
96+
private static IEnumerable<ColumnProperties> GetAllDataTypeColumns(_SMO.Database database)
9797
{
9898
var i = 0;
9999
yield return new ColumnProperties($"col{i++}", _SMO.DataType.BigInt);
@@ -132,17 +132,21 @@ private static IEnumerable<ColumnProperties> GetAllDataTypeColumns()
132132
yield return new ColumnProperties($"col{i++}", _SMO.DataType.Time(1));
133133
yield return new ColumnProperties($"col{i++}", _SMO.DataType.DateTimeOffset(1));
134134
yield return new ColumnProperties($"col{i++}", _SMO.DataType.DateTime2(1));
135+
136+
if (database.Parent.IsJsonDataTypeEnabled && database.DatabaseEngineEdition != DatabaseEngineEdition.SqlDataWarehouse)
137+
{
138+
yield return new ColumnProperties($"col{i++}", _SMO.DataType.Json);
139+
}
135140
}
136141

137142
[TestMethod]
138143
[UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlDataWarehouse)]
139144
public void Column_script_all_data_types()
140145
{
141-
142146
ExecuteFromDbPool(
143147
database =>
144148
{
145-
var columns = GetAllDataTypeColumns().OrderBy(c => c.Name).ToArray();
149+
var columns = GetAllDataTypeColumns(database).OrderBy(c => c.Name).ToArray();
146150
_SMO.Table table = database.CreateTable(this.TestContext.TestName, columns);
147151
table.Refresh();
148152
var createdColumns = table.Columns.Cast<_SMO.Column>()

src/FunctionalTest/Smo/ScriptingTests/EdgeConstraint_SmoTestSuite.cs

+52-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
using Microsoft.SqlServer.Test.Manageability.Utils.TestFramework;
88
using Microsoft.VisualStudio.TestTools.UnitTesting;
99
using _SMO = Microsoft.SqlServer.Management.Smo;
10+
using NUnit.Framework;
1011
using Assert = NUnit.Framework.Assert;
12+
using NUnit.Framework.Internal;
13+
using System;
1114

1215
namespace Microsoft.SqlServer.Test.SMO.ScriptingTests
1316
{
@@ -83,11 +86,47 @@ public void SmoScripting_EdgeConstraint_Sql19AndAfterOnPrem()
8386

8487
string scriptData = edgeConstraint.Script().ToSingleString();
8588

86-
Assert.IsTrue(scriptData.Contains("CONNECTION"));
87-
Assert.IsTrue(scriptData.Contains("To"));
88-
Assert.IsTrue(scriptData.Contains("fromTable"));
89-
Assert.IsTrue(scriptData.Contains("toTable"));
89+
string expectedScriptData = $"ALTER TABLE {edgeTable.FullQualifiedName} ADD CONSTRAINT [{edgeConstraint.Name}]" +
90+
$" CONNECTION ({fromNode.FullQualifiedName} To {toNode.FullQualifiedName}){Environment.NewLine}";
9091

92+
Assert.That(scriptData, Is.EqualTo(expectedScriptData));
93+
});
94+
}
95+
96+
/// <summary>
97+
/// Tests that EdgeConstraints are scripted correctly with different schemas.
98+
/// </summary>
99+
[TestMethod]
100+
[SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 15)]
101+
public void SmoScripting_ECWithMultipleSchemas_Sql19AndAfterOnPrem()
102+
{
103+
this.ExecuteFromDbPool(
104+
database =>
105+
{
106+
var fromSchema = new _SMO.Schema(database, SmoObjectHelpers.GenerateUniqueObjectName("fromSchema"));
107+
fromSchema.Create();
108+
var fromNode = GetTestGraphTable(database, "fromTable", true, fromSchema.Name);
109+
110+
var toSchema = new _SMO.Schema(database, SmoObjectHelpers.GenerateUniqueObjectName("toSchema"));
111+
toSchema.Create();
112+
var toNode = GetTestGraphTable(database, "toTable", true, toSchema.Name);
113+
114+
var edgeTable = new _SMO.Table(database, SmoObjectHelpers.GenerateUniqueObjectName("edgeTable"));
115+
edgeTable.IsEdge = true;
116+
var edgeConstraintName = GenerateSmoObjectName("EC_TEST");
117+
edgeTable.EdgeConstraints.Add(new _SMO.EdgeConstraint(edgeTable, edgeConstraintName));
118+
edgeTable.EdgeConstraints[edgeConstraintName].EdgeConstraintClauses.Add(GetEdgeConstraintTestClause(edgeTable.EdgeConstraints[edgeConstraintName], fromNode, toNode));
119+
edgeTable.Create();
120+
121+
var expectedECName = (string)database.ExecutionManager.ExecuteScalar($@"SELECT name FROM sys.edge_constraints
122+
WHERE type = 'EC' AND parent_object_id = {edgeTable.ID}");
123+
Assert.That(edgeConstraintName, Is.EqualTo(expectedECName), "Edge constraint is not found in the table.");
124+
125+
var scripter = new _SMO.Scripter(database.Parent);
126+
var script = scripter.Script(edgeTable);
127+
var expectedScriptData = $"ALTER TABLE {edgeTable.FullQualifiedName} ADD CONSTRAINT [{_SMO.SqlSmoObject.SqlBraket(edgeConstraintName)}]" +
128+
$" CONNECTION ({fromNode.FullQualifiedName} To {toNode.FullQualifiedName})";
129+
Assert.That(script, Has.Member(expectedScriptData), "Incorrect edge constraint script got generated.");
91130
});
92131
}
93132

@@ -154,10 +193,7 @@ private EdgeConstraintClause GetEdgeConstraintTestClause(EdgeConstraint edgeCons
154193
// EdgeConstraint clauses have a non-functional name. Therefore a numeric value is being used
155194
// as a name below.
156195
//
157-
_SMO.EdgeConstraintClause edgeConstraintClause = new _SMO.EdgeConstraintClause(edgeConstraint, "1567");
158-
159-
edgeConstraintClause.From = fromTable.Name;
160-
edgeConstraintClause.To = toTable.Name;
196+
_SMO.EdgeConstraintClause edgeConstraintClause = new _SMO.EdgeConstraintClause(edgeConstraint, fromTable, toTable);
161197

162198
return edgeConstraintClause;
163199
}
@@ -169,14 +205,17 @@ private EdgeConstraintClause GetEdgeConstraintTestClause(EdgeConstraint edgeCons
169205
/// <param name="database">Reference of the database object which is the parent of the table to be created</param>
170206
/// <param name="name">name identifier of the new table</param>
171207
/// <param name="isNode">flag identifying whether the graph table represents a node or an edge</param>
208+
/// <param name="schemaName">schema of the new table</param>
172209
/// <returns>Test instance of a Graph Table</returns>
173-
private Table GetTestGraphTable(Database database, string name, bool isNode)
210+
private Table GetTestGraphTable(Database database, string name, bool isNode, string schemaName = "dbo")
174211
{
175-
TableProperties tableProps = new TableProperties();
176-
tableProps.IsEdge = !isNode;
177-
tableProps.IsNode = isNode;
212+
TableProperties tableProps = new TableProperties()
213+
{
214+
IsNode = isNode,
215+
IsEdge = !isNode,
216+
};
178217

179-
_SMO.Table graphTable = DatabaseObjectHelpers.CreateTable(database, name, "dbo", tableProps);
218+
_SMO.Table graphTable = DatabaseObjectHelpers.CreateTable(database, name, schemaName, tableProps);
180219
return graphTable;
181220
}
182221
}

src/FunctionalTest/Smo/ScriptingTests/Login_SmoTestSuite.cs

+29
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,35 @@ public void SmoCreateFromExternalProvider_Login()
114114
});
115115
}
116116

117+
/// <summary>
118+
/// Test for scripting external logins which checks if scripting is returning appropriate string on SQL22 and later.
119+
/// CreateSmoObject(login) won't work since the syntax call does the search of login in Azure Active Directory,
120+
/// so we only check the script string.
121+
/// </summary>
122+
[TestMethod]
123+
[SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 16)]
124+
public void SmoCreateFromExternalProviderOnPrem_Login()
125+
{
126+
this.ExecuteWithDbDrop(
127+
database =>
128+
{
129+
_SMO.Server server = database.Parent;
130+
Login login = new Login(server,
131+
GenerateUniqueSmoObjectName("login"));
132+
login.LoginType = LoginType.ExternalUser;
133+
134+
ScriptingOptions so = new ScriptingOptions();
135+
string scriptLogin = ScriptSmoObject((IScriptable)login, so);
136+
string expectedOutput = string.Format("CREATE LOGIN {0} FROM EXTERNAL PROVIDER\r\n", login.FullQualifiedName);
137+
Assert.That(scriptLogin, Is.EqualTo(expectedOutput), "CREATE LOGIN syntax is not scripted correctly. This login type should include keywords 'FROM EXTERNAL PROVIDER'.");
138+
139+
so.ScriptDrops = true;
140+
scriptLogin = ScriptSmoObject((IScriptable)login, so);
141+
expectedOutput = string.Format("DROP LOGIN {0}\r\n", login.FullQualifiedName);
142+
Assert.That(scriptLogin, Is.EqualTo(expectedOutput), "DROP LOGIN syntax is not scripted correctly.");
143+
});
144+
}
145+
117146
/// <summary>
118147
/// Test for scripting external logins which checks if scripting is returning appropriate string.
119148
/// CreateSmoObject(login) won't work since the syntax call does the search of login in Azure Active Directory,

src/FunctionalTest/Smo/ScriptingTests/QueryStore_SmoTestSuite.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void VerifyScriptingQueryStoreOptions()
3939
QueryStoreOperationMode operationMode in
4040
Enum.GetValues(typeof (QueryStoreOperationMode))
4141
.Cast<QueryStoreOperationMode>()
42-
.Except(new[] { QueryStoreOperationMode.Off }))
42+
.Except(new[] { QueryStoreOperationMode.Off, QueryStoreOperationMode.Error }))
4343
{
4444
SetAndValidateOption(database,
4545
typeof (QueryStoreOptions).GetProperty("DesiredState"),
@@ -48,6 +48,7 @@ QueryStoreOperationMode operationMode in
4848
}
4949

5050
database.QueryStoreOptions.DesiredState = QueryStoreOperationMode.ReadWrite;
51+
database.Alter();
5152

5253
foreach (QueryStoreCaptureMode captureMode in
5354
Enum.GetValues(typeof(QueryStoreCaptureMode))

0 commit comments

Comments
 (0)