Skip to content

fix(datamodel): add missing attachment relationships#8182

Open
grantfitzsimmons wants to merge 1 commit into
v7_12_0_7_basefrom
issue-8181
Open

fix(datamodel): add missing attachment relationships#8182
grantfitzsimmons wants to merge 1 commit into
v7_12_0_7_basefrom
issue-8181

Conversation

@grantfitzsimmons

@grantfitzsimmons grantfitzsimmons commented Jun 10, 2026

Copy link
Copy Markdown
Member

Fixes #8181

There were missing attachment data model relationships for some of the new tables. This fixes that.

Testing instructions

image

Summary by CodeRabbit

  • Refactor
    • Updated data model relationships to establish connections between attachments and age-related records, providing enhanced organization for absolute and relative age documentation within the system.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a309712-d158-4dc0-a801-d41f045ba493

📥 Commits

Reviewing files that changed from the base of the PR and between e694107 and ce9b783.

📒 Files selected for processing (1)
  • specifyweb/specify/datamodel.py

📝 Walkthrough

Walkthrough

This PR adds two missing reverse relationship definitions to the Attachment model in datamodel.py. The new absoluteageattachments and relativeageattachments relationships expose the corresponding *Attachment model associations through the API and query builder, resolving a FieldDoesNotExistError that occurred when accessing these relationships during batch editing.

Changes

Attachment reverse relationships

Layer / File(s) Summary
Attachment reverse relationships for new age attachment models
specifyweb/specify/datamodel.py
Two new one-to-many relationship entries (absoluteageattachments and relativeageattachments) are added to the Attachment datamodel definition, linking back to the newly-added AbsoluteAgeAttachment and RelativeAgeAttachment models via otherSideName='attachment'.

Suggested reviewers

  • CarolineDenis
  • emenslin
  • bhumikaguptaa
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Automatic Tests ⚠️ Warning The PR changes only specifyweb/specify/datamodel.py (+2/-0) and doesn’t modify/add any test files. Add an automated unit/integration test that exercises Attachment batch-edit/query access for absoluteageattachments and relativeageattachments (prevent FieldDoesNotExistError).
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding missing attachment relationships to the datamodel, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR adds the two missing reverse relationships (absoluteageattachments and relativeageattachments) to the Attachment table in datamodel.py, directly resolving the requirements specified in issue #8181.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding the missing relationships to the Attachment table definition; no unrelated modifications are present.
Testing Instructions ✅ Passed Testing step targets Batch Edit save/commit, matching the linked FieldDoesNotExistError on attachment editing. Verified datamodel Attachment now includes absoluteageattachments and relativeageattac...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8181

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@grantfitzsimmons grantfitzsimmons added this to the 7.12.0.7 milestone Jun 10, 2026

@bhumikaguptaa bhumikaguptaa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Perform a batch edit on an attachment table and verify that you can save and commit the changes (see #8181)

I tried running a query on the Attachments table and ran into an "AttributeError" on the Absolute Age and Relative Age fields. It only happened with Attachment as a base table, and not when Collection Object was the base table.

Crash Report: Specify 7 Crash Report - 2026-06-11T15_46_07.572Z.txt

Query: New Query.json

Issue Branch:

Screen.Recording.2026-06-11.at.10.41.54.AM.1.mov

Link to DB: https://ojsmnh20260326-issue-8181.test.specifysystems.org/specify/query/334/

@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Jun 11, 2026
@CarolineDenis CarolineDenis requested review from CarolineDenis and bhumikaguptaa and removed request for bhumikaguptaa June 12, 2026 10:42
@CarolineDenis

Copy link
Copy Markdown
Contributor

@CodeRabbit full review

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

Index(name='AttchmentGuidIDX', column_names=['GUID'])
],
relationships=[
Relationship(name='absoluteageattachments', type='one-to-many',required=False, relatedModelName='AbsoluteAgeAttachment', otherSideName='attachment'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

capital A

],
relationships=[
Relationship(name='absoluteageattachments', type='one-to-many',required=False, relatedModelName='AbsoluteAgeAttachment', otherSideName='attachment'),
Relationship(name='relativeageattachments', type='one-to-many',required=False, relatedModelName='RelativeAgeAttachment', otherSideName='attachment'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

Missing reverse relationships in datamodel.py for new *Attachment models

3 participants