Expand merging to Localities, Paleo Ctxt, Collecting Event - #4606
Conversation
Triggered by b62a79b on branch refs/heads/issue-4046
|
What would be the logical new code? MergeSubviewButton line 52, CompareSubView.tsx () =>
relationshipIsToMany(relationship)
? (resource as SpecifyResource<Accession>).getDependentResource(
relationship.name as 'accessionAgents'
)?.models.length ?? 0
: resource.get(relationship.name) === undefined
? 0
: 1,
[relationship, resource]
);In the code above, relationship is a 'zero-to-one'. export const relationshipIsToMany = (
relationship: Relationship | undefined
): boolean =>
relationship?.type.includes('-to-many') === true ||
relationship?.type === 'zero-to-one';models.length is now throwing an error for other tables Why do we have zero-to-one being consider as a IsToMany? |
Triggered by 938370d on branch refs/heads/issue-4046
zero-to-one is a "hack" relationship type introduced at some point in sp6 to do a quick fix for some user request, and now we have to live with the consequences (that's why quick fixes aren't a good idea most of the time) But, @realVinayak or @melton-jason might be able to provide a better description that me based on their knowledge of back-end, business rules, databases and sp6 If it becomes really necessary, and we can't infer what zero-to-one means from the back-end code, we could contact Ben to ask him to explain it one more time edit: my messages to Ben about this:
Ben:
See also helpful information in https://specifydev.slack.com/archives/CC6V12D3J/p1617992659051300 Max:
Ben:
|
The assesment @maxpatiiuk provided is correct to my knowledge. There are two I don't think the backend of Specify 7 has any dedicated logic to handling specify7/specifyweb/specify/load_datamodel.py Lines 333 to 336 in 906d739 At a database level, it is indistinguishable from a However, for whatever reason the restriction was needed in Specify 6 to enforce the relationship as a In the Specify 6 code, the relationship was denoted Although, when working with the ORM Specify6 uses (Hibernate), the columns still needed to be mapped as
It seems they were first added in specify/specify6@3126d02, but I can not find any documenttation or reasoning as to why this restriction was needed or desired in the first place. The relationship can be approached conceptually as "A Locality can have zero or one associated LocalityDetail/GeocoordDetail records". |
Triggered by eee4cb4 on branch refs/heads/issue-4046
|
Thanks for the detailed analysis @melton-jason!
Interesting, because it seems like this could have been represented as an optional one-to-one, unless it has to be different for some reason specific to sp6 codebase |
|
@melton-jason would it make sense to use the schemaoverwrites files to make sp7 front-end treat this as a -to-one relationship? |
|
Currently, it would be easiest for the frontend to treat While it would require modifications to both the frontend and backend, It might be easier to treat the relationship as a dependent However, there is a small concern regarding the name of the relationships: |
the current pr patches that for this. see relevant changes |
Triggered by 1437127 on branch refs/heads/issue-4046
maxpatiiuk
left a comment
There was a problem hiding this comment.
small simplification, otherwise looking good
Triggered by 4f2370f on branch refs/heads/issue-4046
Triggered by 476f2fa on branch refs/heads/issue-4046
alesan99
left a comment
There was a problem hiding this comment.
- perform same tests as agent merging but for new tables
- Verify that we can’t merge PC and CE records when they are configured to be embedded
- Test for #4969 (see instructions in that issue) -- has a unit test
I also encountered a crash when removing all Locality Attachments when merging Localitites
chrome_HxfA730Ahg.mp4
emenslin
left a comment
There was a problem hiding this comment.
Testing instructions
- perform same tests as agent merging but for new tables
- Verify that we can’t merge PC and CE records when they are configured to be embedded
- Test for #4969 (see instructions in that issue) -- has a unit test
Collectors issue seems to be fixed, if deleted in the merge dialog they are not deleted from the individual record

The show conflicting fields issue is in edge so I will write up a separate issue for that.
Everything looks good but I would like another testing review just to make sure we caught everything since there's a lot to cover
lexiclevenger
left a comment
There was a problem hiding this comment.
Testing instructions
- perform same tests as agent merging but for new tables
- Verify that we can’t merge PC and CE records when they are configured to be embedded
- Test for #4969 (see instructions in that issue) -- has a unit test
Looks good! The requested changes also seem to be fixed.
Areyes42
left a comment
There was a problem hiding this comment.
Testing instructions
- perform same tests as agent merging but for new tables
- Verify that we can’t merge PC and CE records when they are configured to be embedded
- Test for Merging agents unchecks isCurrent checkbox in associated determinations #4969 (see instructions in that issue) -- has a unit test
I encountered similar issues as mentioned in the previous comments when I first tested this PR, but it appears everything has been resolved now. Great job! 👏
pashiav
left a comment
There was a problem hiding this comment.
Testing instructions
- perform same tests as agent merging but for new tables
- Verify that we can’t merge PC and CE records when they are configured to be embedded
- Test for #4969 (see instructions in that issue) -- has a unit test
Looks good! Working as expected.




Fixes #4046
Checklist
and self-explanatory (or properly documented)
Testing instructions
Utils:
https://discourse.specifysoftware.org/t/shared-vs-embedded-records-configuration/1712/1