Feature #22701


Allow forward reference to parent when importing issues

Added by Gregor Schmidt about 8 years ago. Updated over 7 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


When importing issues via CSV with parent relations, the parent issues need to be positioned before child issues. Otherwise the relation will be ignored.

To work around this limitation, the issue import could be extended to use multiple passes:

  1. one to import basic issue properties
  2. one to import relations to other issues

This way it becomes easier to create the CSV files for imports, since order is no longer important.

This change would also be a prerequisite to import general issue relations. Since those cannot be more complex that parent relations and cannot necessarily be linearized properly.

Attached you find a patch series based on trunk r15361.

While implemented the changes, I tried to keep the Import free from issue related information. Other existing Import sub classes - within plugins e.g. - should need as little updates as possible.

0001 Extend test data for issue import

This change adds two rows to the existing issue import fixture file. These rows contain a parent and a child issue, while the parent is placed after the child. This would not import properly given the current implementation.

The patch also updates the existing tests, where the number of imported issues is asserted.

0002 Add test for issue relations to following rows

This patch extends the existing parent issue import test to also verify that the newly introduced parent child relation is properly imported. This test fails with the current implementation.

0003 Multi-pass CSV import

This patch defines a required_passes method within Import which returns 1 by default and may be overwritten in sub classes. The IssueImport does so and returns 1 if no parent_id mapping was set, otherwise it returns 2.

The run method is split into run and run_pass. The first one is recursive and called once for each pass. It also handles the max_* options. The second is only responsible for reading the rows, creating or updating the ImportItems and passing everything to build_object.

Since build_object may now be called multiple times (once for each pass), the argument list was extended to provide more context. If somebody created a custom import in a plugin, this would need to be changed by the plugin's author.

In the IssueImport, build_object is now split into build_issue and build_relations, the first is called in the first pass, the second in pass 2.

The patch also contains a migration, which adds a completed_passes field to ImportItem. This is needed to properly (re-)store progress for multi-step imports, like the ones via the web UI.

Finally the patch adds some test to make sure, that the general behavior of multi-step imports did not change with the introduction of multi-pass imports.

Disclaimer: I know, this is a rather large change to fix a minor nuisance. But as mentioned earlier, I think, this change is a necessary prerequisite to support importing "Related Issues" properly, which I would like to contribute next, if this patch is accepted.


Related issues

Related to Redmine - Feature #28198: Support issue relations when importing issuesClosedGo MAEDA

Has duplicate Redmine - Feature #25799: Issue Import - Dynamic Parent pasksClosed

Actions #1

Updated by Jan from Planio about 8 years ago

  • Target version set to Candidate for next minor release
Actions #2

Updated by Go MAEDA almost 8 years ago

  • Category set to Importers
  • Target version changed from Candidate for next minor release to 3.4.0
Actions #3

Updated by Toshi MARUYAMA almost 8 years ago

  • Description updated (diff)
Actions #4

Updated by Jean-Philippe Lang over 7 years ago

  • Subject changed from Multi-Pass CSV import to improve parent issue imports to Allow forward reference to parent when importing issues
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Feature added in r16241 using a callback mechanism instead of the more complex multi-pass solution proposed in the patch.
It can be extend easily to support issue relations in the future as well.

Actions #5

Updated by Gregor Schmidt over 7 years ago

Interesting approach. Thanks for taking care of this issue.

Actions #6

Updated by Toshi MARUYAMA almost 7 years ago

  • Has duplicate Feature #25799: Issue Import - Dynamic Parent pasks added
Actions #7

Updated by Mischa The Evil over 6 years ago

  • Related to Feature #28198: Support issue relations when importing issues added

Also available in: Atom PDF