Skip to content
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

Add error logging when exception occures during database seeding #1197

Merged
merged 2 commits into from
Sep 10, 2022

Conversation

kbeaugrand
Copy link
Member

@kbeaugrand kbeaugrand commented Sep 10, 2022

Description

What's new?

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

@kbeaugrand kbeaugrand requested a review from a team as a code owner September 10, 2022 15:06
@codecov
Copy link

codecov bot commented Sep 10, 2022

Codecov Report

Base: 88.56% // Head: 88.56% // No change to project coverage 👍

Coverage data is based on head (3e824dc) compared to base (0c0dfaf).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1197   +/-   ##
=======================================
  Coverage   88.56%   88.56%           
=======================================
  Files         208      208           
  Lines        6942     6942           
=======================================
  Hits         6148     6148           
  Misses        794      794           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kbeaugrand kbeaugrand merged commit b573f21 into main Sep 10, 2022
@kbeaugrand kbeaugrand deleted the fix/1190_device_model_properties_not_migrated branch September 10, 2022 16:48
Comment on lines +22 to +44
foreach (var item in table.Query<TableEntity>().ToArray())
{
if (await set.AnyAsync(c => c.Id == item.RowKey))
continue;

#pragma warning disable CS8629 // Nullable value type may be null.
_ = await set.AddAsync(new DeviceModelProperty
{
Id = item.RowKey,
ModelId = item.PartitionKey,
Name = item.GetString(nameof(DeviceModelProperty.Name)),
DisplayName = item.GetString(nameof(DeviceModelProperty.DisplayName)),
PropertyType = Enum.Parse<DevicePropertyType>(item.GetString(nameof(DeviceModelProperty.PropertyType))),
Order = item.GetInt32(nameof(DeviceModelProperty.Order)) ?? 0,
IsWritable = item.GetBoolean(nameof(DeviceModelProperty.IsWritable)).Value
});
#pragma warning restore CS8629 // Nullable value type may be null.

if (config is ProductionConfigHandler)
{
_ = await table.DeleteEntityAsync(item.PartitionKey, item.RowKey);
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where

This foreach loop implicitly filters its target sequence [here](1) - consider filtering the sequence explicitly using '.Where(...)'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Device model properties are not saved to dabase
1 participant