Skip to content

fix: sort datamodel alphabetically#8139

Draft
grantfitzsimmons wants to merge 1 commit into
mainfrom
issue-8138
Draft

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

Conversation

@grantfitzsimmons
Copy link
Copy Markdown
Member

@grantfitzsimmons grantfitzsimmons commented May 28, 2026

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 use a two-pass approach: registering all tables first, then processing fields and relationships in a sorted sequence. This changes the internal initialization order without affecting user-facing functionality.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

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: e8009763-d610-46b9-8e6c-32564dbe058f

📥 Commits

Reviewing files that changed from the base of the PR and between 9499aa1 and bf17dbf.

📒 Files selected for processing (1)
  • specifyweb/frontend/js_src/lib/components/DataModel/tables.ts

📝 Walkthrough

Walkthrough

The PR refactors table initialization in fetchContext to ensure tables are processed in a consistent, alphabetically sorted order. Previously, tables were registered and processed individually; now, all tables are first registered into the shared lookup, then processed together in a second pass while maintaining explicit alphabetical 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.

Suggested reviewers

  • CarolineDenis
  • emenslin
  • bhumikaguptaa
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Automatic Tests ⚠️ Warning PR implements table sorting but lacks automated tests verifying alphabetical order. Schema and table tests don't check ordering; backend test only verifies fetching/serialization. Add test assertions to verify tables are returned in alphabetical order by name (e.g., in schema.test.ts or a new tables.test.ts).
Testing Instructions ⚠️ Warning Testing instructions are missing from the PR commit/description. The PR template requires testing instructions, but the actual commit message body is empty with no documented testing steps. Add testing instructions documenting how to verify alphabetical sorting in Schema Viewer, Configure data entry tables, Configure interaction tables, Record/Field formatters, Form definitions.
✅ Passed checks (4 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 and concisely describes the main change: implementing alphabetical sorting of tables in the data model.
Linked Issues check ✅ Passed The PR refactors fetchContext to sort tables alphabetically via explicit sorting in tablePairs creation, directly addressing issue #8138's requirement for alphabetical table sorting across UI contexts.
Out of Scope Changes check ✅ Passed All changes are narrowly focused on refactoring the fetchContext function to implement alphabetical sorting of tables, with no unrelated modifications detected.

✏️ 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
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

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

1 participant