iTwin / imodel-transformer

API for exporting an iModel's parts and also importing them into another iModel
MIT License
3 stars 2 forks source link

[fed guid optimization] ProcessChanges doesn't handle element update if an Element was updated by recreating it with the same fedGuid in source #92

Closed ViliusRuskys closed 11 months ago

ViliusRuskys commented 1 year ago

To reproduce this issue: Add an Element A into source Run initial transformation Delete element A from source Insert Element B to source with the same federation guid that Element A had Run change processing

Expected: only Element B in target Actual: 0 Elements in target

original issue: When provenance was tracked by external source aspects Element A and Element B would never be mapped to each other by forEachTrackedElement. Inserting Element B would produce an error since inserts are handled before deletes and it would produce a conflict because of duplicate federationGuid.

How iModel Transformation service handled this case: Before inserting Elements, we check if an element with identical federation guid already exists in the target. If it does, we insert this element with a new random federation guid assigned and we save the original federation guid in a map. After element deletes have been handled we update all elements that had new federation guids assigned to them, back to the original fedGuid values.

new issue: Now during initialization Element A in target gets mapped to Element B in source (because of matching fed guids), so an element insert is never triggered. Processing element deletes, deletes the Element A in target.

MichaelBelousov commented 11 months ago

closed by #99