migration-scripts
migration-scripts copied to clipboard
v3-mongodb-v3-sql : empty column causing bug on the map method
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
- Run the migration script.
- 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 !
I second this proposed change, this gets me further to a working script for my strapi instance.