Skip to content

Commit

Permalink
BaseClass Differencing Validation fix (backport #7224) [release/4.9.x] (
Browse files Browse the repository at this point in the history
#7290)

Co-authored-by: Stefan Apfel <[email protected]>
  • Loading branch information
mergify[bot] and StefanApfel-Bentley authored Oct 22, 2024
1 parent b8093f9 commit 2bc4906
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/ecschema-editing",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/ecschema-editing"
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class SchemaDifferenceValidationVisitor implements ISchemaDifferenceVisitor {
* Shared base-class validation for all types of ClassItemDifference union.
*/
private async visitBaseClassDifference(entry: ClassItemDifference, targetClassItem: ECClass) {
if (entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {
if ("baseClass" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {
return this.addConflict({
code: ConflictCode.RemovingBaseClass,
schemaType: targetClassItem.schemaItemType,
Expand Down
35 changes: 35 additions & 0 deletions core/ecschema-editing/src/test/Differencing/Conflicts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,41 @@ describe("Schema Difference Conflicts", () => {
await expect(findConflictItem(differences, "ActualBaseClassEntity")).to.be.eventually.undefined;
});

it("should not find a conflict if other properties but baseclass change", async () => {
const sourceSchema = {
...schemaHeader,
name: "ConflictSchema2",
items: {
BaseEntity: {
schemaItemType: "EntityClass",
modifier: "Abstract",
},
ActualBaseClassEntity: {
schemaItemType: "EntityClass",
label: "ActualBaseClassEntity",
description: "This describes the actual base class entity",
baseClass: "ConflictSchema2.BaseEntity",
},
},
};

const targetSchema = {
...schemaHeader,
items: {
BaseEntity: {
schemaItemType: "EntityClass",
modifier: "Abstract",
},
ActualBaseClassEntity: {
schemaItemType: "EntityClass",
baseClass: "ConflictSchema.BaseEntity",
},
},
};
const differences = await runDifferences(sourceSchema, targetSchema);
await expect(findConflictItem(differences, "ActualBaseClassEntity")).to.eventually.not.exist;
});

it("should not find a conflict if the new base class derives from target baseclass from referenced schemas", async () => {
const sourceSchemaJson = {
...schemaHeader,
Expand Down

0 comments on commit 2bc4906

Please sign in to comment.