Skip to content

Commit bb75a87

Browse files
authored
Merge pull request Azure#8338 from jaredmoo/capabilitiesNullRef
Fixed null ref in Get-AzSqlCapability
2 parents b1085ef + a9ff30d commit bb75a87

File tree

4 files changed

+154
-150
lines changed

4 files changed

+154
-150
lines changed

src/Sql/Sql.Test/ScenarioTests/LocationCapabilitiesTests.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15-
<#
15+
<#
1616
.SYNOPSIS
1717
Tests the Get-AzSqlCapability cmdlet
1818
#>
1919
function Test-Capabilities
2020
{
21-
$location = "Southeast Asia"
21+
$location = "eastus"
2222
$all = Get-AzSqlCapability $location
2323
Validate-Capabilities $all
24-
24+
2525
$default = Get-AzSqlCapability $location -Defaults
2626
Validate-Capabilities $default
27-
27+
2828
$version = Get-AzSqlCapability $location -ServerVersionName "12.0"
2929
Validate-Capabilities $default
30-
30+
3131
$edition = Get-AzSqlCapability $location -EditionName "Premium"
3232
Validate-Capabilities $default
33-
33+
3434
$so = Get-AzSqlCapability $location -ServiceObjectiveName "S3"
3535
Validate-Capabilities $default
3636

3737
}
3838

39-
<#
39+
<#
4040
.SYNOPSIS
4141
Validates that a LocationCapabilities object is valid and has all properties filled out
4242
#>
@@ -57,15 +57,15 @@ function Validate-Capabilities ($capabilities)
5757
Assert-NotNull $edition.EditionName
5858
Assert-NotNull $edition.Status
5959
Assert-True {$edition.SupportedServiceObjectives.Count -gt 0}
60-
60+
6161
foreach($so in $edition.SupportedServiceObjectives) {
6262
Assert-NotNull $so
6363
Assert-NotNull $so.ServiceObjectiveName
6464
Assert-NotNull $so.Status
6565
Assert-NotNull $so.Id
6666
Assert-AreNotEqual $so.Id [System.Guid]::Empty
67-
Assert-True {$so.SupportedMaxSizes.Count -gt 0}
68-
67+
#Assert-True {$so.SupportedMaxSizes.Count -gt 0} # Vcore service objectives have empty list of SupportedMaxSizes
68+
6969
foreach($size in $so.SupportedMaxSizes) {
7070
Assert-NotNull $size
7171
Assert-NotNull $size.MinValue.Limit

src/Sql/Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.LocationCapabilitiesTests/TestLocationCapabilities.json

Lines changed: 136 additions & 138 deletions
Large diffs are not rendered by default.

src/Sql/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
## Upcoming Release
2121
* Add Get/Set AzSqlDatabaseBackupShortTermRetentionPolicy
2222
* Fix issue where not being logged into Azure account would result in nullref exception when executing SQL cmdlets
23+
* Fixed null ref exception in Get-AzSqlCapability
2324

2425
## Version 1.1.0
2526
* Update incorrect online help URLs

src/Sql/Sql/Location Capabilities/Services/AzureSqlCapabilitiesAdapter.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ private ServiceObjectiveCapabilityModel CreateSupportedSLOModel(Management.Sql.M
108108
slo.Id = s.Id;
109109
slo.ServiceObjectiveName = s.Name;
110110
slo.Status = s.Status.ToString();
111-
slo.SupportedMaxSizes = s.SupportedMaxSizes.Select(CreateSupportedMaxSizeModel).ToList();
111+
112+
// Vcore service objectives don't have supported max sizes, they have max size ranges
113+
if (s.SupportedMaxSizes != null)
114+
{
115+
slo.SupportedMaxSizes = s.SupportedMaxSizes.Select(CreateSupportedMaxSizeModel).ToList();
116+
}
112117

113118
return slo;
114119
}
@@ -133,7 +138,7 @@ private MaxSizeRangeCapabilityModel CreateSupportedMaxSizeModel(Management.Sql.M
133138
Limit = m.MaxValue.Limit,
134139
Unit = m.MaxValue.Unit
135140
};
136-
141+
137142
maxSizeRange.ScaleSize = new MaxSizeCapabilityModel()
138143
{
139144
Limit = m.ScaleSize.Limit,

0 commit comments

Comments
 (0)