Skip to content

Commit ddf937f

Browse files
authored
Merge pull request #8411 from dealaus/SqlFixNullRef
[SQL] Fix null ref when not logged into Azure account for all sql cmdlets
2 parents 201df91 + b954222 commit ddf937f

File tree

129 files changed

+157
-288
lines changed

Some content is hidden

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

129 files changed

+157
-288
lines changed

src/Sql/Sql/AdvancedThreatProtection/Cmdlet/SqlManagedInstanceAdvancedDataSecurityCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected override ManagedInstanceAdvancedDataSecurityPolicyModel GetEntity()
7474
/// </summary>
7575
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
7676
/// <returns>An initialized and ready to use ModelAdapter object</returns>
77-
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter(IAzureSubscription subscription)
77+
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter()
7878
{
7979
return new SqlAdvancedThreatProtectionAdapter(DefaultProfile.DefaultContext);
8080
}

src/Sql/Sql/AdvancedThreatProtection/Cmdlet/SqlServerAdvancedThreatProtectionCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ protected override ServerAdvancedThreatProtectionPolicyModel GetEntity()
7575
/// <summary>
7676
/// Creation and initialization of the ModelAdapter object
7777
/// </summary>
78-
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
7978
/// <returns>An initialized and ready to use ModelAdapter object</returns>
80-
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter(IAzureSubscription subscription)
79+
protected override SqlAdvancedThreatProtectionAdapter InitModelAdapter()
8180
{
8281
return new SqlAdvancedThreatProtectionAdapter(DefaultProfile.DefaultContext);
8382
}

src/Sql/Sql/AdvancedThreatProtection/Services/SqlAdvancedThreatProtectionAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class SqlAdvancedThreatProtectionAdapter
4848
public SqlAdvancedThreatProtectionAdapter(IAzureContext context)
4949
{
5050
Context = context;
51-
Subscription = context.Subscription;
51+
Subscription = context?.Subscription;
5252
SqlThreatDetectionAdapter = new SqlThreatDetectionAdapter(Context);
5353
}
5454

src/Sql/Sql/Advisor/Cmdlet/AzureSqlDatabaseAdvisorCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ public abstract class AzureSqlDatabaseAdvisorCmdletBase : AzureSqlCmdletBase<IEn
5151
/// <summary>
5252
/// Initializes the model adapter
5353
/// </summary>
54-
/// <param name="subscription">The subscription the cmdlets are operation under</param>
5554
/// <returns>The advisor adapter</returns>
56-
protected override AzureSqlDatabaseAdvisorAdapter InitModelAdapter(IAzureSubscription subscription)
55+
protected override AzureSqlDatabaseAdvisorAdapter InitModelAdapter()
5756
{
5857
return new AzureSqlDatabaseAdvisorAdapter(DefaultProfile.DefaultContext);
5958
}

src/Sql/Sql/Advisor/Cmdlet/AzureSqlElasticPoolAdvisorCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ public abstract class AzureSqlElasticPoolAdvisorCmdletBase : AzureSqlCmdletBase<
5151
/// <summary>
5252
/// Initializes the model adapter
5353
/// </summary>
54-
/// <param name="subscription">The subscription the cmdlets are operation under</param>
5554
/// <returns>The advisor adapter</returns>
56-
protected override AzureSqlElasticPoolAdvisorAdapter InitModelAdapter(IAzureSubscription subscription)
55+
protected override AzureSqlElasticPoolAdvisorAdapter InitModelAdapter()
5756
{
5857
return new AzureSqlElasticPoolAdvisorAdapter(DefaultProfile.DefaultContext);
5958
}

src/Sql/Sql/Advisor/Cmdlet/AzureSqlServerAdvisorCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public abstract class AzureSqlServerAdvisorCmdletBase : AzureSqlCmdletBase<IEnum
4141
/// <summary>
4242
/// Initializes the model adapter
4343
/// </summary>
44-
/// <param name="subscription">The subscription the cmdlets are operation under</param>
4544
/// <returns>The advisor adapter</returns>
46-
protected override AzureSqlServerAdvisorAdapter InitModelAdapter(IAzureSubscription subscription)
45+
protected override AzureSqlServerAdvisorAdapter InitModelAdapter()
4746
{
4847
return new AzureSqlServerAdvisorAdapter(DefaultProfile.DefaultContext);
4948
}

src/Sql/Sql/Advisor/Service/AzureSqlAdvisorCommunicatorBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public class AzureSqlAdvisorCommunicatorBase
5151
public AzureSqlAdvisorCommunicatorBase(IAzureContext context)
5252
{
5353
Context = context;
54-
if (context.Subscription != Subscription)
54+
if (context?.Subscription != Subscription)
5555
{
56-
Subscription = context.Subscription;
56+
Subscription = context?.Subscription;
5757
SqlClient = null;
5858
}
5959
}

src/Sql/Sql/Auditing/Cmdlet/AuditingSettings/SqlDatabaseAuditingSettingsCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ protected override DatabaseBlobAuditingSettingsModel GetEntity()
4242
/// <summary>
4343
/// Creation and initialization of the ModelAdapter object
4444
/// </summary>
45-
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
4645
/// <returns>An initialized and ready to use ModelAdapter object</returns>
47-
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
46+
protected override SqlAuditAdapter InitModelAdapter()
4847
{
4948
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
5049
}

src/Sql/Sql/Auditing/Cmdlet/AuditingSettings/SqlServerAuditingSettingsCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ protected override ServerBlobAuditingSettingsModel GetEntity()
5252
/// <summary>
5353
/// Creation and initialization of the ModelAdapter object
5454
/// </summary>
55-
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
5655
/// <returns>An initialized and ready to use ModelAdapter object</returns>
57-
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
56+
protected override SqlAuditAdapter InitModelAdapter()
5857
{
5958
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
6059
}

src/Sql/Sql/Auditing/Cmdlet/SqlDatabaseAuditingCmdletBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ protected override AuditingPolicyModel GetEntity()
5959
/// <summary>
6060
/// Creation and initialization of the ModelAdapter object
6161
/// </summary>
62-
/// <param name="subscription">The AzureSubscription in which the current execution is performed</param>
6362
/// <returns>An initialized and ready to use ModelAdapter object</returns>
64-
protected override SqlAuditAdapter InitModelAdapter(IAzureSubscription subscription)
63+
protected override SqlAuditAdapter InitModelAdapter()
6564
{
6665
return new SqlAuditAdapter(DefaultProfile.DefaultContext);
6766
}

0 commit comments

Comments
 (0)