-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix for showing on GET and persisting Tags on SET (if not given) for Database, Server and Elastic Pool #3206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ET and SET. Fixed SET server command.
Hi @vaishali33, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!
TTYL, AZPRBOT; |
Can one of the admins verify this patch? |
@@ -113,7 +113,7 @@ protected override IEnumerable<AzureSqlDatabaseModel> ApplyUserInputToModel(IEnu | |||
Edition = Edition, | |||
MaxSizeBytes = MaxSizeBytes, | |||
RequestedServiceObjectiveName = RequestedServiceObjectiveName, | |||
Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true), | |||
Tags = this.MyInvocation.BoundParameters.ContainsKey("Tags") ? TagsConversionHelper.CreateTagDictionary(Tags, validate: true) : model.FirstOrDefault().Tags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If .FirstOrDefault
returns null, .Tags
will throw NullRefException. I think that model should always have exactly one element here, if this is correct then use Single
instead of FirstOrDefault
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this line is a little complicated and is repeated several times, I suggest extracting it as a common method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that we are using .FirstOrDefault in code just two lines below model.FirstOrDefault().Location. model.FirstOrDefault() should not be null or else we will not reach to this point in code.
For second comment I don't think this its complex statement and its only used at 3 places. Doesn't make sense to extract that to a method in some base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you know that the collection is non-empty, then using FirstOrDefault()
is just confusing to the reader - use First()
instead.
The exact same code in 3 places is enough justification to extract method. It can be in utility class or base class, your choice. The fact that the code is complex enough to have a bug once (this time) means that it's complex enough to have a bug again, and when that happens the fix should only be done in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed.
@azuresdkci test this please |
@azuresdkci add to whitelist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please respond to jaredmoo review comments and please add a test to cover this scenario - it can be a unit test or a scenario test
@@ -95,12 +95,13 @@ protected override IEnumerable<Model.AzureSqlServerModel> ApplyUserInputToModel( | |||
{ | |||
// Construct a new entity so we only send the relevant data to the server | |||
List<Model.AzureSqlServerModel> updateData = new List<Model.AzureSqlServerModel>(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@vaishali33 Please respond to review comments, please read and fill out the checklist. |
@vaishali33 please address the PR. Code complete is next week. |
@markcowl and @shahabhijeet I have addressed the comments and added tests. Please review. Thank you! |
# Conflicts: # src/ResourceManager/Sql/ChangeLog.md
…into dev # Conflicts: # src/ResourceManager/Sql/ChangeLog.md
Thanks for the changes Vaishali, LGTM! |
Description
Fix for showing on GET and persisting Tags on SET (if not given) for Database, Server and Elastic Pool.
Also fixed Set-AzureRmSqlServer if SqlAdministratorPassword is not provided.
Fixes #1134 :Fetching Tags from Get-AzureRmSqlDatabase to set Tags values in set-AzureRmSqlDatabase if not provided
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThrough
parameter.Cmdlet Parameter Guidelines