Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Data Import): Allow parent with differing child table lengths #11223

Merged
merged 2 commits into from Aug 24, 2020

Conversation

gwhitney
Copy link
Contributor

@gwhitney gwhitney commented Aug 9, 2020

Prior to this commit, if a parent has multiple child tables and
the child tables have different numbers of rows, then the
data import will fail with an error when it detects missing
mandatory fields in the (necessary) empty records in the
shorter child table.

This commit fixes the problem by ignoring child rows that have
only INVALID_VALUES for fields relating to that child (e.g.,
that are altogether empty in the fields for that child).

Closes #11222.

@gwhitney
Copy link
Contributor Author

gwhitney commented Aug 9, 2020

The Travis failures do not seem connected with this pull request in any way...

  Prior to this commit, if a parent has multiple child tables and
  the child tables have different numbers of rows, then the
  data import will fail with an error when it detects missing
  mandatory fields in the (necessary) empty records in the
  shorter child table.

  This commit fixes the problem by ignoring child rows that have
  only INVALID_VALUES for fields relating to that child (e.g.,
  that are altogether empty in the fields for that child).

  Fixes frappe#11222.
Copy link
Contributor

@netchampfaris netchampfaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gwhitney Hey, thanks for sending this. I have made a minor change. We can return early from parse_doc if we find an empty child row. Let me know if this is fine so we can go ahead with this.

@gwhitney
Copy link
Contributor Author

Thank you for looking at this in depth. Yes, it is fine to return from parse_doc if there are only invalid values. Whether it actually improves or hurts efficiency depends on how fast get_columns is or is not -- with the check as you've inserted, you have to look at every column, including the parent type columns, for each child table doctype; without that check, you only look at each column once overall, but potentially at the cost of more calls to get_columns. Since I don't have the experience to know whether get_columns is expensive, I completely defer to your judgment. As far as I am concerned, the PR as amended is fine and would be a big improvement in importing (Purchase Invoices, in particular, since they have an Items child table and a Charges and Taxes subtable, both of which are frequently used).

@mergify mergify bot merged commit 60d9667 into frappe:develop Aug 24, 2020
@netchampfaris
Copy link
Contributor

@Mergifyio backport version-12-hotfix

@mergify
Copy link
Contributor

mergify bot commented Sep 9, 2020

Command backport version-12-hotfix: success

Backports have been created

surajshetty3416 pushed a commit that referenced this pull request Sep 9, 2020
…11223) (#11464)

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-authored-by: Faris Ansari <netchamp.faris@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data Import trouble with different child tables having different lengths
3 participants