Skip to content

Filter Record Sets created from queries on Record Sets#8339

Open
CarolineDenis wants to merge 4 commits into
mainfrom
issue-5280
Open

Filter Record Sets created from queries on Record Sets#8339
CarolineDenis wants to merge 4 commits into
mainfrom
issue-5280

Conversation

@CarolineDenis

@CarolineDenis CarolineDenis commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #5280

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

  1. Query on a record set
  2. Create a record set by clicking "Create Record Set" without any row selected.
  • Verify your record set has the correct number of record

NOTES:

Summary by CodeRabbit

  • New Features

    • Record sets created from query results now retain their originating record set.
    • Queries based on an existing record set are automatically scoped to that source record set.
  • Bug Fixes

    • Prevented query-generated record sets from including unrelated records.
  • Tests

    • Added coverage verifying source record set filtering.

@github-actions

Copy link
Copy Markdown

Warning

One or more dependencies are approaching or past End-of-Life.
Please plan upgrades accordingly.

STATUS=WARNING
NODE_VERSION=20
NODE_CYCLE=20
EOL_DATE=2026-04-30
DAYS_REMAINING=-83

--- Node.js ---
Version: 20
EOL: 2026-04-30
Status: WARNING

STATUS=OK
PYTHON_VERSION=3.12
PYTHON_CYCLE=3.12
EOL_DATE=2028-10-31
DAYS_REMAINING=832

--- Python ---
Version: 3.12
EOL: 2028-10-31
Status: OK

STATUS=WARNING
DJANGO_VERSION=4.2
DJANGO_CYCLE=4.2
EOL_DATE=2026-04-07
DAYS_REMAINING=-106

--- Django ---
Version: 4.2
EOL: 2026-04-07
Status: WARNING


@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@CarolineDenis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35bda344-6328-41f5-96d1-09e1a2253b8a

📥 Commits

Reviewing files that changed from the base of the PR and between 17a65fd and 633e1fb.

📒 Files selected for processing (1)
  • specifyweb/backend/stored_queries/execution.py
📝 Walkthrough

Walkthrough

Record-set creation now preserves the originating record-set ID in the query payload. Backend execution passes that ID to query construction, and a unit test verifies the scoped query arguments.

Changes

Record Set Query Scoping

Layer / File(s) Summary
Propagate source record-set ID
specifyweb/frontend/js_src/lib/components/QueryBuilder/Components.tsx, specifyweb/frontend/js_src/lib/components/QueryBuilder/Wrapped.tsx
MakeRecordSetButton accepts the source record-set ID, receives it from query results, and includes it in the fromQuery payload.
Apply record-set query scope
specifyweb/backend/stored_queries/execution.py, specifyweb/backend/stored_queries/tests/test_recordset.py
recordset() passes the payload’s record-set ID to build_query; the test verifies this argument is supplied.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The backend, frontend, and tests all address #5280 by carrying the source record set ID and scoping the generated record set.
Out of Scope Changes check ✅ Passed The changes stay focused on record-set query scoping and supporting tests, with no obvious unrelated additions.
Automatic Tests ✅ Passed Added TestRecordSet.test_query_is_scoped_to_source_recordset, which asserts recordset() passes the source recordset id into build_query.
Testing Instructions ✅ Passed The steps start from a query on a record set and create a record set with no row selected, which exercises the affected QueryBuilder UI and backend scoping path.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the core change: filtering new Record Sets created from queries on existing Record Sets.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-5280

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.

@coderabbitai coderabbitai Bot left a comment

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.

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 687-694: Validate the recordset returned by the lookup before
passing it into the query-building flow around build_query. Handle a missing or
stale recordsetid without dereferencing recordset.dbTableId, and, when enforcing
collection-local scope, verify recordset.collectionMemberId before joining its
items.
🪄 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: cad46515-7bc1-46b4-bd67-a6e164460f6f

📥 Commits

Reviewing files that changed from the base of the PR and between 8f38321 and 17a65fd.

📒 Files selected for processing (4)
  • specifyweb/backend/stored_queries/execution.py
  • specifyweb/backend/stored_queries/tests/test_recordset.py
  • specifyweb/frontend/js_src/lib/components/QueryBuilder/Components.tsx
  • specifyweb/frontend/js_src/lib/components/QueryBuilder/Wrapped.tsx

Comment thread specifyweb/backend/stored_queries/execution.py
@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Jul 22, 2026
@CarolineDenis
CarolineDenis requested a review from a team July 22, 2026 13:34
@CarolineDenis CarolineDenis modified the milestones: 7.12.2, 7.12.1 Jul 22, 2026

@emenslin emenslin 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.

  • Verify your record set has the correct number of record

Looks good!

07-22_12.04.mp4

@emenslin
emenslin requested a review from a team July 22, 2026 17:12
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.

Record Sets created from queries on Record Sets are not filtered correctly

2 participants