Skip to content

Commit

Permalink
Merge pull request #158 from microsoft/sync/171.30.0
Browse files Browse the repository at this point in the history
Sync to 171.30.0
  • Loading branch information
shueybubbles authored Mar 21, 2024
2 parents 3ae2731 + 545b943 commit 7377088
Show file tree
Hide file tree
Showing 67 changed files with 1,639 additions and 1,813 deletions.
43 changes: 32 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@
Update this document for externally visible changes. Put most recent changes first.
Once we push a new version to nuget.org add a double hash header for that version.

## 171.30.0

- <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.
- Change base class of `ConnectionException` to `Exception`
- Update major package version to 171
- add new database permission alter any external mirror for azure sql database

## 170.23.0

- Fix bug where creating Microsoft Entra ID logins for Azure SQL database and On Prem databases was disabled
- Upgraded SqlClient to 5.1.2 and removed direct Azure SDK dependencies from the nuget package
- Fix createdrop script error for versioned table in ledger database
- Fix database scoped extended events enumeration on Azure SQL database instances having DATABASE_DEFAULT catalog collation
- Improve scripting of dependency objects in Azure SQL database
- Added `ObjectId` parameter in User and Login create options
- Fix `Database.PrefetchObjects` not to throw for SQL version earlier than 2016

## 170.23.0, 161.48050.0
- Add ledger support in Database create options for MI in SSMS
- Add `OwnerLoginName` property to `JobSchedule` per [issue 120](https://github.com/microsoft/sqlmanagementobjects/issues/120)
- Fixed the `Database.AvailabilityDatabaseSynchronizationState` property to reflect the correct synchronization state of MI databases in Managed Instance Link
- Fix database scoped extended events enumeration on Azure SQL database instances having DATABASE_DEFAULT catalog collation

## 170.20.0
- Add `OwnerLoginName` property to `JobSchedule` per [issue 120](https://github.com/microsoft/sqlmanagementobjects/issues/120)
## 170.18.0

- Add `SearchPropertyList` support for Azure SQL Database

## 170.18.0, 161.48044.0
## 170.17.0, 161.48044.0

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


## 161.48036.0
## 170.13.0, 161.48036.0

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


## 161.48028.0
## 170.12.0, 161.48028.0

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

## 161.47027.0
## 170.11.0, 161.47027.0

- Fix distribution columns on scripting for taking into consideration more than one distribution column
- Add new EXTGOV_OPERATION_GROUP audit action type
- Force [QUOTED_IDENTIFIER ON](https://github.com/microsoft/sqlmanagementobjects/issues/96) for all tables
- 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
- Update permissions enumeration for SQL Server 2022

## 170.6.0-preview

- Add SmoMetadataProvider preview package
- Replace netcoreapp3.1 with net6

## 170.5.0-preview

- First public 170 build on Nuget.org
- Upgrade Microsoft.Data.SqlClient to version 5.0
- Upgrade build tools to VS2022

## 161.47021.0

- Add `LedgerViewSchema` property to table objects
Expand Down
2 changes: 2 additions & 0 deletions Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<ItemGroup>
<!-- GlobalPackageReference packages are installed and processed by msbuild but are not referenced by the C# compiler -->
<GlobalPackageReference Include="StrawberryPerl" Version="5.28.0.1" GeneratePathProperty="true" />
<GlobalPackageReference Include="Microsoft.TestPlatform" Version="17.6.0" GeneratePathProperty="true" />

</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion SmoBuild/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<InformationalVersion>$(AssemblyFileVersion)</InformationalVersion>
<FileVersion>$(AssemblyFileVersion)</FileVersion>
<Version>$(AssemblyFileVersion)</Version>
<PackageMajorVersionIncrement Condition="'$(PackageMajorVersionIncrement)'==''">0</PackageMajorVersionIncrement>
<PackageMajorVersionIncrement Condition="'$(PackageMajorVersionIncrement)'==''">1</PackageMajorVersionIncrement>
<PackageVersion Condition="'$(PackageVersion)' == ''">$(AssemblyMajorVersion)$(PackageMajorVersionIncrement).$(AssemblyBuildVersion).$(AssemblyBuildRevision)</PackageVersion>
<AssemblyVersion Condition="'$(AssemblyVersion)'==''">$(AssemblyMajorVersion).$(AssemblyMinorVersion).0.0</AssemblyVersion>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/Codegen/cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<property name="BuildNumber" generate="true" is_intrinsic="false" />
<property name="IsCaseSensitive" generate="true" is_intrinsic="false" />
<property name="IsFullTextInstalled" generate="true" is_intrinsic="false" />
<property name="IsJsonDataTypeEnabled" generate="true" is_intrinsic="false" />
<property name="MasterDBLogPath" generate="true" is_intrinsic="false" />
<property name="MasterDBPath" generate="true" is_intrinsic="false" />
<property name="ErrorLogPath" generate="true" is_intrinsic="false" />
Expand Down Expand Up @@ -1604,6 +1605,8 @@
<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" >
<property name="From" generate="true" is_intrinsic="false" />
<property name="To" generate="true" is_intrinsic="false" />
<property name="FromSchema" generate="true" is_intrinsic="false" />
<property name="ToSchema" generate="true" is_intrinsic="false" />
</object>

<!--End: Edge constraint def-->
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@
</PropertyGroup>
<PropertyGroup>
<!-- these variables are referenced by packagebuild.proj for inclusion in nuspecs and used by packages.props -->
<SqlParserPackageVersion>171.24.0</SqlParserPackageVersion>
<SqlParserPackageVersion>172.0.1</SqlParserPackageVersion>
<SqlClientPackage>Microsoft.Data.SqlClient</SqlClientPackage>
<SqlClientPackageVersion>5.1.2</SqlClientPackageVersion>
<SqlClientPackageVersion>5.1.4</SqlClientPackageVersion>
</PropertyGroup>
<Import Project="$(BuildPropsDir)\StrongName.props" Condition="Exists('$(BuildPropsDir)\StrongName.props')" />
<Import Project="$(BuildPropsDir)\Version.props" />
Expand Down
6 changes: 6 additions & 0 deletions src/FunctionalTest/Framework/TestFramework/SqlTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
// We don't control all dependency DLL versions in every environment so just
// load whatever version is in the same folder as the test, if possible.
var an = new AssemblyName(args.Name);
if (an.Name.ToLower().EndsWith(".resources"))
{
// We are not really in the business of loading resources, so avoid unnecessary tracing...
return null;
}

var dll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), an.Name + ".dll");
Trace.TraceInformation($"Trying to load dll:{dll}");
try
Expand Down
10 changes: 7 additions & 3 deletions src/FunctionalTest/Smo/ScriptingTests/Column_SmoTestSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ [c] [int] NULL
});
}

private static IEnumerable<ColumnProperties> GetAllDataTypeColumns()
private static IEnumerable<ColumnProperties> GetAllDataTypeColumns(_SMO.Database database)
{
var i = 0;
yield return new ColumnProperties($"col{i++}", _SMO.DataType.BigInt);
Expand Down Expand Up @@ -132,17 +132,21 @@ private static IEnumerable<ColumnProperties> GetAllDataTypeColumns()
yield return new ColumnProperties($"col{i++}", _SMO.DataType.Time(1));
yield return new ColumnProperties($"col{i++}", _SMO.DataType.DateTimeOffset(1));
yield return new ColumnProperties($"col{i++}", _SMO.DataType.DateTime2(1));

if (database.Parent.IsJsonDataTypeEnabled && database.DatabaseEngineEdition != DatabaseEngineEdition.SqlDataWarehouse)
{
yield return new ColumnProperties($"col{i++}", _SMO.DataType.Json);
}
}

[TestMethod]
[UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlDataWarehouse)]
public void Column_script_all_data_types()
{

ExecuteFromDbPool(
database =>
{
var columns = GetAllDataTypeColumns().OrderBy(c => c.Name).ToArray();
var columns = GetAllDataTypeColumns(database).OrderBy(c => c.Name).ToArray();
_SMO.Table table = database.CreateTable(this.TestContext.TestName, columns);
table.Refresh();
var createdColumns = table.Columns.Cast<_SMO.Column>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
using Microsoft.SqlServer.Test.Manageability.Utils.TestFramework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using _SMO = Microsoft.SqlServer.Management.Smo;
using NUnit.Framework;
using Assert = NUnit.Framework.Assert;
using NUnit.Framework.Internal;
using System;

namespace Microsoft.SqlServer.Test.SMO.ScriptingTests
{
Expand Down Expand Up @@ -83,11 +86,47 @@ public void SmoScripting_EdgeConstraint_Sql19AndAfterOnPrem()

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

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

Assert.That(scriptData, Is.EqualTo(expectedScriptData));
});
}

/// <summary>
/// Tests that EdgeConstraints are scripted correctly with different schemas.
/// </summary>
[TestMethod]
[SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 15)]
public void SmoScripting_ECWithMultipleSchemas_Sql19AndAfterOnPrem()
{
this.ExecuteFromDbPool(
database =>
{
var fromSchema = new _SMO.Schema(database, SmoObjectHelpers.GenerateUniqueObjectName("fromSchema"));
fromSchema.Create();
var fromNode = GetTestGraphTable(database, "fromTable", true, fromSchema.Name);

var toSchema = new _SMO.Schema(database, SmoObjectHelpers.GenerateUniqueObjectName("toSchema"));
toSchema.Create();
var toNode = GetTestGraphTable(database, "toTable", true, toSchema.Name);

var edgeTable = new _SMO.Table(database, SmoObjectHelpers.GenerateUniqueObjectName("edgeTable"));
edgeTable.IsEdge = true;
var edgeConstraintName = GenerateSmoObjectName("EC_TEST");
edgeTable.EdgeConstraints.Add(new _SMO.EdgeConstraint(edgeTable, edgeConstraintName));
edgeTable.EdgeConstraints[edgeConstraintName].EdgeConstraintClauses.Add(GetEdgeConstraintTestClause(edgeTable.EdgeConstraints[edgeConstraintName], fromNode, toNode));
edgeTable.Create();

var expectedECName = (string)database.ExecutionManager.ExecuteScalar($@"SELECT name FROM sys.edge_constraints
WHERE type = 'EC' AND parent_object_id = {edgeTable.ID}");
Assert.That(edgeConstraintName, Is.EqualTo(expectedECName), "Edge constraint is not found in the table.");

var scripter = new _SMO.Scripter(database.Parent);
var script = scripter.Script(edgeTable);
var expectedScriptData = $"ALTER TABLE {edgeTable.FullQualifiedName} ADD CONSTRAINT [{_SMO.SqlSmoObject.SqlBraket(edgeConstraintName)}]" +
$" CONNECTION ({fromNode.FullQualifiedName} To {toNode.FullQualifiedName})";
Assert.That(script, Has.Member(expectedScriptData), "Incorrect edge constraint script got generated.");
});
}

Expand Down Expand Up @@ -154,10 +193,7 @@ private EdgeConstraintClause GetEdgeConstraintTestClause(EdgeConstraint edgeCons
// EdgeConstraint clauses have a non-functional name. Therefore a numeric value is being used
// as a name below.
//
_SMO.EdgeConstraintClause edgeConstraintClause = new _SMO.EdgeConstraintClause(edgeConstraint, "1567");

edgeConstraintClause.From = fromTable.Name;
edgeConstraintClause.To = toTable.Name;
_SMO.EdgeConstraintClause edgeConstraintClause = new _SMO.EdgeConstraintClause(edgeConstraint, fromTable, toTable);

return edgeConstraintClause;
}
Expand All @@ -169,14 +205,17 @@ private EdgeConstraintClause GetEdgeConstraintTestClause(EdgeConstraint edgeCons
/// <param name="database">Reference of the database object which is the parent of the table to be created</param>
/// <param name="name">name identifier of the new table</param>
/// <param name="isNode">flag identifying whether the graph table represents a node or an edge</param>
/// <param name="schemaName">schema of the new table</param>
/// <returns>Test instance of a Graph Table</returns>
private Table GetTestGraphTable(Database database, string name, bool isNode)
private Table GetTestGraphTable(Database database, string name, bool isNode, string schemaName = "dbo")
{
TableProperties tableProps = new TableProperties();
tableProps.IsEdge = !isNode;
tableProps.IsNode = isNode;
TableProperties tableProps = new TableProperties()
{
IsNode = isNode,
IsEdge = !isNode,
};

_SMO.Table graphTable = DatabaseObjectHelpers.CreateTable(database, name, "dbo", tableProps);
_SMO.Table graphTable = DatabaseObjectHelpers.CreateTable(database, name, schemaName, tableProps);
return graphTable;
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/FunctionalTest/Smo/ScriptingTests/Login_SmoTestSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,35 @@ public void SmoCreateFromExternalProvider_Login()
});
}

/// <summary>
/// Test for scripting external logins which checks if scripting is returning appropriate string on SQL22 and later.
/// CreateSmoObject(login) won't work since the syntax call does the search of login in Azure Active Directory,
/// so we only check the script string.
/// </summary>
[TestMethod]
[SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 16)]
public void SmoCreateFromExternalProviderOnPrem_Login()
{
this.ExecuteWithDbDrop(
database =>
{
_SMO.Server server = database.Parent;
Login login = new Login(server,
GenerateUniqueSmoObjectName("login"));
login.LoginType = LoginType.ExternalUser;

ScriptingOptions so = new ScriptingOptions();
string scriptLogin = ScriptSmoObject((IScriptable)login, so);
string expectedOutput = string.Format("CREATE LOGIN {0} FROM EXTERNAL PROVIDER\r\n", login.FullQualifiedName);
Assert.That(scriptLogin, Is.EqualTo(expectedOutput), "CREATE LOGIN syntax is not scripted correctly. This login type should include keywords 'FROM EXTERNAL PROVIDER'.");

so.ScriptDrops = true;
scriptLogin = ScriptSmoObject((IScriptable)login, so);
expectedOutput = string.Format("DROP LOGIN {0}\r\n", login.FullQualifiedName);
Assert.That(scriptLogin, Is.EqualTo(expectedOutput), "DROP LOGIN syntax is not scripted correctly.");
});
}

/// <summary>
/// Test for scripting external logins which checks if scripting is returning appropriate string.
/// CreateSmoObject(login) won't work since the syntax call does the search of login in Azure Active Directory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void VerifyScriptingQueryStoreOptions()
QueryStoreOperationMode operationMode in
Enum.GetValues(typeof (QueryStoreOperationMode))
.Cast<QueryStoreOperationMode>()
.Except(new[] { QueryStoreOperationMode.Off }))
.Except(new[] { QueryStoreOperationMode.Off, QueryStoreOperationMode.Error }))
{
SetAndValidateOption(database,
typeof (QueryStoreOptions).GetProperty("DesiredState"),
Expand All @@ -48,6 +48,7 @@ QueryStoreOperationMode operationMode in
}

database.QueryStoreOptions.DesiredState = QueryStoreOperationMode.ReadWrite;
database.Alter();

foreach (QueryStoreCaptureMode captureMode in
Enum.GetValues(typeof(QueryStoreCaptureMode))
Expand Down
Loading

0 comments on commit 7377088

Please sign in to comment.