Skip to content

Fix path format queries for multi-valued fields#6635

Open
oxms16 wants to merge 1 commit into
beetbox:masterfrom
oxms16:fix/path-query-multivalue-fields
Open

Fix path format queries for multi-valued fields#6635
oxms16 wants to merge 1 commit into
beetbox:masterfrom
oxms16:fix/path-query-multivalue-fields

Conversation

@oxms16
Copy link
Copy Markdown

@oxms16 oxms16 commented May 14, 2026

Description

Fixes #6598.

(...)

To Do

the issue was that path format queries are evaluated against an in-memory Item using query.match(), where multi-valued fields such as genres are represented as lists, e.g. ["Classical"]. Before this change, string/exact matching treated that list as one whole value, so a path rule like genres:=~Classical: _Classical/... failed to match and fell back to the default path format, even though beet list genres:=~Classical worked through the database query path. This change updates in-memory matching so sequence-like field values are matched element by element, while excluding strings and byte-like values from sequence handling. I added regression tests for genres:=~Classical, genres:=Classical, avoiding a false positive for Neoclassical, and direct query.match() behavior on multi-valued fields. Manual verification showed the original version returned match: False and destination: ...\one\two, while the fixed version returns match: True and destination: ...\one\three.
-->
[yes]This is a bug fix for existing behavior and does not add or change user-facing configuration.
[no]Changelog. I can add an entry after review if maintainers prefer.
[yes]Tests.

Summary

This fixes path format selection for multi-valued fields such as genres.

Path format queries are evaluated against an in-memory Item via query.match().
For multi-valued fields, the in-memory value is a list, for example:

genres = ["Classical"]

@oxms16 oxms16 requested a review from a team as a code owner May 14, 2026 04:39
@github-actions
Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.39%. Comparing base (7c50f94) to head (c9e6d0f).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6635      +/-   ##
==========================================
+ Coverage   72.15%   72.39%   +0.23%     
==========================================
  Files         159      159              
  Lines       20645    20653       +8     
  Branches     3269     3272       +3     
==========================================
+ Hits        14897    14952      +55     
+ Misses       5041     4976      -65     
- Partials      707      725      +18     
Files with missing lines Coverage Δ
beets/dbcore/query.py 91.16% <100.00%> (+0.06%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path format configuration matching on genres fails when using operands for exact matches

1 participant