Skip to content

fix: sort datamodel alphabetically#8139

Open
grantfitzsimmons wants to merge 3 commits into
mainfrom
issue-8138
Open

fix: sort datamodel alphabetically#8139
grantfitzsimmons wants to merge 3 commits into
mainfrom
issue-8138

Conversation

@grantfitzsimmons

@grantfitzsimmons grantfitzsimmons commented May 28, 2026

Copy link
Copy Markdown
Member

Fixes #8138

This PR sorts the tables in the data model alphabetically. See now that Absolute Age is at the top in both cases, which is the first by alphabetical sort.

image image image

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR
  • Add migration function to
    def fix_schema_config(stdout: WriteToStdOut | None = None):

Testing instructions

Make sure to test this against the latest v7 tagged release!

  • Verify that tables are sorted alphabetically in
    • Schema Viewer
    • Configure data entry tables
    • Configure interaction tables
    • Configure visible query tables
    • Record formatters app resources
    • Field formatters app resources
    • Form definitions

Summary by CodeRabbit

  • Refactor

    • Reorganized data model table initialization to a two-pass, sorted sequence (register then process). No change to user-facing behavior.
  • Tests

    • Updated unit test snapshot to reflect the adjusted ordering of detected circular tables.

@coderabbitai

coderabbitai Bot commented May 28, 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: 3d30d289-8f8a-45af-9168-71763e54c01b

📥 Commits

Reviewing files that changed from the base of the PR and between bf17dbf and 996d755.

⛔ Files ignored due to path filters (2)
  • specifyweb/frontend/js_src/lib/components/Attachments/__tests__/__snapshots__/utils.test.ts.snap is excluded by !**/*.snap
  • specifyweb/frontend/js_src/lib/components/FormEditor/__tests__/__snapshots__/createView.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/automapper.test.ts

📝 Walkthrough

Walkthrough

Refactors table initialization in fetchContext to perform registration in a first pass (all tables added to genericTables) and a second pass that builds literal fields, relationships, front-end-only fields, derived maps, and invokes schemaExtras, using an explicit alphabetical table ordering.

Changes

Data Model Table Initialization

Layer / File(s) Summary
Two-pass table initialization with alphabetical sorting
specifyweb/frontend/js_src/lib/components/DataModel/tables.ts
fetchContext post-load processing refactored from per-table register-then-process to a two-pass approach: creates a sorted tablePairs list, registers all tables to genericTables first, then processes fields, relationships, front-end-only fields, derived maps, and schema callbacks across all tables in the second iteration.

Test snapshot update

Layer / File(s) Summary
Updated circularTables snapshot
specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/automapper.test.ts
Jest inline snapshot for circularTables() updated to expect "[table TectonicUnitTreeDefItem]" and no longer expect "[table TectonicUnit]".

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Testing Instructions ⚠️ Warning PR template "Testing instructions" section is empty with only comments. Commit message lacks detail. No explicit steps provided to verify the 7 UI areas listed in PR objectives. Add testing instructions detailing how to verify alphabetical sorting in: Schema Viewer, Configure data entry tables, Configure interaction tables, Configure visible query tables, formatters app resources, and Form definitions.
✅ 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 'fix: sort datamodel alphabetically' clearly describes the main change: sorting tables alphabetically in the data model, which aligns with the primary objective.
Linked Issues check ✅ Passed The code changes implement alphabetical sorting of tables in the data model initialization via a two-pass approach, and the test update reflects the new sorted ordering, satisfying the requirement to sort tables alphabetically.
Out of Scope Changes check ✅ Passed All changes are directly related to sorting tables alphabetically: the refactored initialization logic in tables.ts and the updated snapshot in the test file reflect the sorting implementation.
Automatic Tests ✅ Passed PR includes automated tests: automapper.test.ts snapshot updated to verify alphabetical table ordering through circularTables() function test, demonstrating the sorting implementation works correctly.

✏️ 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-8138

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 marked this pull request as draft May 28, 2026 21:37
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

@grantfitzsimmons grantfitzsimmons marked this pull request as ready for review June 8, 2026 00:57
@grantfitzsimmons grantfitzsimmons modified the milestones: 7.12.0.7, 7.12.1 Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Tables are not sorted alphabetically in all contexts

2 participants