Skip to content

Accession CO subview searches with multiple catalogNumbers only returns last number#8226

Merged
g1rly-c0d3r merged 4 commits into
mainfrom
issue-8221
Jun 17, 2026
Merged

Accession CO subview searches with multiple catalogNumbers only returns last number#8226
g1rly-c0d3r merged 4 commits into
mainfrom
issue-8221

Conversation

@g1rly-c0d3r

@g1rly-c0d3r g1rly-c0d3r commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Express search now splits on commas instead of spaces

Fixes #8221

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

Testing instructions

  • Go to any table that has a one-to-many relationship with collection objects and has a subform to add them and open the express search.
  • enter a comma-separated list of catalog numbers and make sure that those numbers are all returned in the results box
  • try adding spaces between the commas, both before and after to make sure those do not break the search box
  • try adding non-conventional whitespace, like a tab to ensure that the search box does not break (you'll have to paste the tab in, here it is between the quotes " ")

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced search term parsing to split unquoted input by commas (instead of whitespace), improving multi-term search behavior while keeping quoted single-term searches unchanged.

@coderabbitai

coderabbitai Bot commented Jun 16, 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: 725cc698-d1d1-41ef-b316-dcd14320f2bb

📥 Commits

Reviewing files that changed from the base of the PR and between 05a6469 and 8649051.

📒 Files selected for processing (1)
  • specifyweb/backend/express_search/search_terms.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • specifyweb/backend/express_search/search_terms.py

📝 Walkthrough

Walkthrough

In parse_search_str, the non-quoted branch that splits the input search string into individual terms is changed from whitespace-based splitting (search_str.split()) to comma-based splitting with trimming ([t.strip() for t in search_str.split(',') if t.strip()]). Quoted-term handling remains unchanged.

Changes

Express Search Term Parsing Fix

Layer / File(s) Summary
Switch term delimiter from whitespace to comma
specifyweb/backend/express_search/search_terms.py
parse_search_str now splits on commas and trims empty segments instead of splitting on whitespace in the non-quoted branch, enabling comma-separated inputs (e.g., catalog numbers) to produce multiple distinct search terms.
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Automatic Tests ⚠️ Warning The PR modifies the parse_search_str function to split on commas instead of spaces, but includes no automatic unit tests for this critical parsing logic change. Add unit tests for parse_search_str covering: comma-separated terms, whitespace handling, quoted strings, and edge cases.
Testing Instructions ⚠️ Warning Testing instructions lack specificity: they reference "any table" instead of the specific Accession form CO subview context from issue #8221, and don't detail verification criteria for success. Specify "Accession form → CO subview search" instead of "any table," and clarify expected results: "verify all entered catalog numbers appear in results."
✅ 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 accurately describes the main bug being fixed: restoring comma-separated catalog number search functionality in the Accession CO subview.
Linked Issues check ✅ Passed The code change directly addresses issue #8221 by modifying parse_search_str to split on commas instead of whitespace, enabling multiple catalog number searches as required.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to the parse_search_str function in the express search module, directly addressing the reported bug with no unrelated modifications.

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

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.

@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/express_search/search_terms.py`:
- Line 120: The search_str.split(',') call at line 120 preserves whitespace
around comma-separated terms, causing terms like ' cat2' (with leading space) to
be stored instead of 'cat2'. Since make_term only strips asterisks and not
whitespace, these spaces persist and cause create_text_filter to fail matching
against database values. Fix this by stripping whitespace from each term after
splitting and filtering out empty strings that result from consecutive or
trailing commas. Apply this fix to the split operation itself so that the terms
list contains clean, non-empty values before they are processed downstream.
🪄 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: 2465ae6c-efe6-46ac-85bf-c598717f2cfb

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0ef8c and 05a6469.

📒 Files selected for processing (1)
  • specifyweb/backend/express_search/search_terms.py

Comment thread specifyweb/backend/express_search/search_terms.py Outdated
@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Jun 16, 2026
@CarolineDenis CarolineDenis added this to the 7.12.1 milestone Jun 17, 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.

  • enter a comma-separated list of catalog numbers and make sure that those numbers are all returned in the results box
  • try adding spaces between the commas, both before and after to make sure those do not break the search box
  • try adding non-conventional whitespace, like a tab to ensure that the search box does not break (you'll have to paste the tab in, here it is between the quotes " ")

Looks good, all results appear in the box with a comma-separated list!

Image

@emenslin emenslin requested a review from a team June 17, 2026 14:10
@g1rly-c0d3r g1rly-c0d3r merged commit 8649051 into main Jun 17, 2026
18 checks passed
@g1rly-c0d3r g1rly-c0d3r deleted the issue-8221 branch June 17, 2026 15:04
@github-project-automation github-project-automation Bot moved this from Dev Attention Needed to ✅Done in General Tester Board Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅Done

Development

Successfully merging this pull request may close these issues.

Accession CO subview searches with multiple catalogNumbers only returns last number

3 participants