Fix array fields dropping entries beyond the 9th on factsheet submit#2365
Open
ajith1994 wants to merge 3 commits into
Open
Fix array fields dropping entries beyond the 9th on factsheet submit#2365ajith1994 wants to merge 3 commits into
ajith1994 wants to merge 3 commits into
Conversation
Author
|
Hi @jh-RLI, Could you take a look when you get a chance? This fixes #2328 (Model/Framework This is my first contribution to the project. I will be happy to make any changes you'd like to see. And, please let me know if I have missed out anything. Thank you! |
Contributor
|
@ajith1994 Thanks a lot for the contribution. I’ll take a closer look at it next week; at first glance, it seems like you fixed it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the discussion
Issue #2328: adding more than 9 entries to an array field on a Model/Framework
factsheet (e.g. Author(s)) causes everything from the 10th entry onward to be
silently dropped on submit, and not restored when re-editing.
Root cause is in
processPost()(modelview/helper.py): the regex^{field}_\d$matches only a single trailing digit, so field names likeauthors_10,authors_11never match and are discarded before saving.parts.sort()also did a lexicographic (string) sort rather than numeric,which would have scrambled entry order once the truncation was fixed.
Fix: changed
\d$to\d+$, and sortpartsnumerically by the trailingindex instead of lexicographically. Manually verified by submitting a Model
factsheet with 12 authors and confirming all 12 persist, in the correct
order, in
modelview_basicfactsheet.authors.Type of change (CHANGELOG.md)
Bugs
entries of array fields (e.g. Author(s)) on submit, caused by a regex
that only matched single-digit field-name suffixes.
(#2365)
Workflow checklist
Automation
Closes #2328
PR-Assignee
CONTRIBUTING.md
CHANGELOG.md
mkdocs