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] Import increments IDs for non-default locale models #127

Open KestasVenslauskas opened 1 year ago

KestasVenslauskas commented 1 year ago

Describe the bug For non-default locale imported models ID's are different.

Here is the exported json v2:

    "version": 2,
    "data": {
        "api::test-type.test-type": {
            "1": {
                "id": 1,
                "title": "one",
                "subtitle": "one",
                "createdAt": "2023-06-15T10:20:36.335Z",
                "updatedAt": "2023-06-15T10:21:10.522Z",
                "publishedAt": "2023-06-15T10:20:42.601Z",
                "locale": "en",
                "sitemap_exclude": false,
                "localizations": [
                    4
                ],
                "createdBy": null,
                "updatedBy": null
            },
            "2": {
                "id": 2,
                "title": "two",
                "subtitle": "two",
                "createdAt": "2023-06-15T10:20:53.276Z",
                "updatedAt": "2023-06-15T10:21:00.832Z",
                "publishedAt": "2023-06-15T10:20:53.853Z",
                "locale": "en",
                "sitemap_exclude": false,
                "localizations": [
                    3
                ],
                "createdBy": null,
                "updatedBy": null
            },
            "3": {
                "id": 3,
                "title": "du",
                "subtitle": "du",
                "createdAt": "2023-06-15T10:21:00.828Z",
                "updatedAt": "2023-06-15T10:21:01.519Z",
                "publishedAt": "2023-06-15T10:21:01.518Z",
                "locale": "lt",
                "sitemap_exclude": false,
                "localizations": [
                    2
                ],
                "createdBy": null,
                "updatedBy": null
            },
            "4": {
                "id": 4,
                "title": "vienas",
                "subtitle": "vienas",
                "createdAt": "2023-06-15T10:21:10.519Z",
                "updatedAt": "2023-06-15T10:21:11.345Z",
                "publishedAt": "2023-06-15T10:21:11.344Z",
                "locale": "lt",
                "sitemap_exclude": false,
                "localizations": [
                    1
                ],
                "createdBy": null,
                "updatedBy": null
            }
        }
    }
}

I created test model with 2 fields 'title' & 'subtitle'

Steps to reproduce the behavior:

  1. Have at least 2 locales.
  2. Export content-type model.
  3. Import content-type model to a different env (or delete / re-import data).

Expected behavior All id's are the same as in the JSON v2.

Actual result The IDs of entries in non-default locale are incremented. If I delete / import again all EN (default) locale IDs will remain the same but will be incremented on LT (secondary) locale.

image

Additional context The biggest problem is when we have nested contentTypes and import gives errors because IDs does not match saying "1 relation(s) of type api::some-type.some-type associated with this entity do not exist"

KestasVenslauskas commented 1 year ago

Here is the PR to fix it:

128

EDIT: but this works only for 2 locales max. I but as I see import v2 did not worked with more than 2 locales even before

KestasVenslauskas commented 1 year ago

@Baboo7 We tested this fix and can confirm that it works as expected. Waiting for your approval and a new release :)

KestasVenslauskas commented 1 year ago

@Baboo7 why is this being ignored?