Baboo7 / strapi-plugin-import-export-entries

Import/Export data from and to your database in just few clicks.
175 stars 86 forks source link

[BUG] ID Mapping of exported content to Imported content is not applied #151

Closed Przecza closed 8 months ago

Przecza commented 10 months ago

Describe the bug During import the mapping of Original content Id to newly created content ID is not applied for Media and Relations. When content on Import side was created with different Id and mapping is done through idField

To Reproduce

lets have export file with relation or media:

{
"version": 2, 
"data": {
  "api::your-content-type.your-content-type": {
      "any-relation": [3, 4], 
      ...
  }
  "api::any-relation.any-relation": {
      3: {name: 3, [idField]: uuid, ...},
      4: {name: 4, [idField]: uuid, ...},
  }
}}

As it seems, it is possible, the any-relation content type items could be created with different ids (lets say 1, 2) (very common for my use case). In that case I have noticed there is mapping of original ID to new ID, but it is not applied correctly in all cases.

Content mapping is

The relation content type will be saved as:

{
  "api:any-relation:any-relation": {
      1: {name: 3, [idField]: uuid, ...},
      2: {name: 4, [idField]: uuid,...},
 }

But the Your-content-type will try to update these values:

{
  "api::your-content-type.your-content-type": {
      "any-relation": [3, 4]
  }
}

leading to partial import and error message : ValidationError: 1 relation(s) of type api:any-relation:any-relation associated with this entity do not exist

Expected behavior Your-content-type should respect mapping to new values

{
  "api:your-content-type:your-content-type": {
      "any-relation": [1, 2]
  }
}

Additional context It seems all code is there, it is just not used. the mapping is done in setComponents() function, but relations and media are ignored. There is also getComponents() function which is called only in setComponents() and it looks like it is made for this mapping, but it is called for zones and components only.

Question #147 seems to be related

Baboo7 commented 9 months ago

@Przecza import of media of components is now functional in version 1.22.2. I'll have a look at relations of component later