migration-scripts icon indicating copy to clipboard operation
migration-scripts copied to clipboard

v3-mongodb-v3-sql : empty column causing bug on the map method

Open geoffreyhach opened this issue 9 months ago • 1 comments

Bug report

Issue Description

When running the script, if a column with a many-to-many relation is empty or contains null values, the script terminates prematurely. This issue occurs because the map method is called on a null value in such cases.

Steps to Reproduce

  1. Run the migration script.
  2. Encounter a column with a many-to-many relation that is empty or contains null values.

Expected Behavior

The script should gracefully handle cases where columns in many-to-many relations are empty or contain null values, allowing it to continue processing other data.

Temporary fix?

Found a solution for my specific use case adding guards like this line 214 : const rows = (entry[key] ?? []).map((e, idx) => ({ ... })

line 270 : if (!entry[key] || !idMap.get(entry[key])) { continue; }

I don't know if i shoud submit a Pull Request with this fix or if something more robust will be added, let me know !

geoffreyhach avatar Sep 19 '23 08:09 geoffreyhach

I second this proposed change, this gets me further to a working script for my strapi instance.

brechtvalcke avatar Oct 28 '23 19:10 brechtvalcke