feat(Query Builder): Respect Sorting When Exporting Query to CSV (duplicate of #8168)#8167
feat(Query Builder): Respect Sorting When Exporting Query to CSV (duplicate of #8168)#8167g1rly-c0d3r wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughThis PR applies ordering expressions to the SQLAlchemy query used for CSV export and makes apply_special_post_query_processing return the query when list mode is disabled, ensuring CSV export receives a valid, ordered query. ChangesCSV Export Ordering
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@specifyweb/backend/stored_queries/execution.py`:
- Around line 333-335: In query_to_csv, move the ordering so query =
query.order_by(*order_by_expers) is called before
apply_special_post_query_processing to avoid calling .order_by on a materialized
list; specifically, swap the two calls so that
apply_special_post_query_processing(query, tableid, field_specs, collection,
user, should_list_query=False) receives an already-ordered query, and note that
parent_inheritance_post_query_processing and
cog_inheritance_post_query_processing may return list(query) which makes the
original order unsafe.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e13395b2-b1ff-491c-bbb6-217c0d3d5b7f
📒 Files selected for processing (1)
specifyweb/backend/stored_queries/execution.py
Fixes #5038
Checklist
self-explanatory (or properly documented)
Testing instructions
Screenshots
(sorting by taxon in descending order)

Summary by CodeRabbit