Skip to content

Commit a83fe7a

Browse files
Explicit upgrade fixed to occur before the properties get upgraded (#284)
2 parents c0c5d78 + 5394b3a commit a83fe7a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

BHoMUpgrader/Upgrader.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,21 @@ private BsonDocument UpgradeObject(BsonDocument document, Converter converter)
279279
// Check if the object type is classified as deleted or without update
280280
CheckForNoUpgrade(converter, oldType, "object type");
281281

282-
// Upgrade porperties
283-
BsonDocument withNewProperties = UpgradeObjectProperties(document, converter);
284-
BsonDocument newDoc = withNewProperties ?? document;
282+
BsonDocument newDoc = document;
285283

286284
//Check if there are any full object upgraders available
285+
bool upgradedExplicitly = false;
287286
if (converter.ToNewObject.ContainsKey(oldType))
288287
{
289288
//If so, use them to upgrade the object
290289
newDoc = UpgradeObjectExplicit(newDoc, converter, oldType) ?? newDoc;
290+
upgradedExplicitly = true;
291291
}
292-
else
292+
293+
// Upgrade properties
294+
newDoc = UpgradeObjectProperties(newDoc, converter) ?? newDoc;
295+
296+
if(!upgradedExplicitly)
293297
{
294298
//If not, try upgrading the names of the types and properties
295299
newDoc = UpgradeObjectTypeAndPropertyNames(newDoc, converter, oldType) ?? newDoc;

0 commit comments

Comments
 (0)