iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
582 stars 210 forks source link

Don't add entry to differences if difference is empty (sourceValue = undefined) #6920

Open AureMonke opened 2 days ago

AureMonke commented 2 days ago

const sourceSchema = await Schema.fromJson({ $schema: "https://dev.bentley.com/json_schemas/ec/32/ecschema", name: "SourceSchema", version: "1.0.0", alias: "source", items: { TestItem: { schemaItemType: "EntityClass", properties: [ { name: "Name", type: "PrimitiveProperty", description: "name of item", label: "Name", priority: 0, typeName: "string", }, ], }, }, }, new SchemaContext());

const targetSchema = await Schema.fromJson({
  $schema: "[https://dev.bentley.com/json_schemas/ec/32/ecschema"](https://dev.bentley.com/json_schemas/ec/32/ecschema%22),
  name: "TargetSchema",
  version: "1.0.0",
  alias: "target",
  items: {
    TestPropertyCategory: {
      schemaItemType:"PropertyCategory",
      label:"Property Category",
      priority: 100000,
    },
    TestItem: {
      schemaItemType: "EntityClass",
      properties: [
        {
          name: "Name",
          type: "PrimitiveProperty",
          description: "name of item",
          label: "Name",
          priority: 0,
          typeName: "string",
          category: "TargetSchema.TestPropertyCategory",
        },
      ],
    },
  },
}, new SchemaContext());

returns an empty difference { changeType: "modify", schemaType: "Property", itemName: "TestItem", path: "Name", difference: { }, }

Either we need to show it as conflict when source property value is undefined, and target - not undefined, or ignore it.