beets icon indicating copy to clipboard operation
beets copied to clipboard

`field:=value` in `paths:` config queries behaves inconsistently with `ls` for aggregate fields

Open eternaleye opened this issue 5 months ago • 1 comments

Problem

If I have the following paths config:

paths:
    albumtypes:=ep: "foo"
    default: "bar"

and an item in my library with the albumtypes ep and not named bar, then beet mv -p albumtypes:=ep will try to name it bar.

Setup

  • OS: Exherbo Linux
  • Python version: 3.11.5
  • beets version: 1.6.1 (git 7f1250dd0a286b099d032fe65d1c287b0ed37d46)
  • Turning off plugins made problem go away (yes/no): no

My configuration (output of beet config) is: very long, and not relevant (I tested the minimized case)

I was able to track this down somewhat - the stack (and relevant variables) looks like this:

Note that return value - this fails to succeed in the subsequent .match(), while (AndQuery([MatchQuery('albumtypes', ['ep'], fast=True)]), NullSort()) succeeds (adding square brackets around the value).

The search to gather the items, meanwhile, goes via a completely different path - it passes down to the database, and never goes through .match() at all.

I can see two ways of addressing this - one would be to make parse_query_string consider field types when deciding how to parse the value of a match; the other would be to make match for MatchQuery transform both sides into some "canonical form" (e.g. semicolon-separated list-in-string, for albumtypes) on a field-dependent basis.

eternaleye avatar Feb 12 '24 01:02 eternaleye

I've worked around this for now by using the inline plugin and defining:

album_fields:
    albumtypes_str: '"; ".join(albumtypes)'

so I can match on that in paths: queries.

eternaleye avatar Feb 12 '24 02:02 eternaleye