quintodrome/model/criteria
Deluan Quintão 08fd222791
fix(smartplaylist): support isMissing/isPresent operators on ReplayGain fields (#5585)
* fix(smartplaylist): support isMissing/isPresent operators on ReplayGain fields

ReplayGain values are stored in dedicated nullable columns (rg_album_gain,
rg_album_peak, rg_track_gain, rg_track_peak) rather than in the media_file.tags
JSON blob. The isMissing/isPresent operators previously only supported tag and
role fields, causing two failure modes:

1. Using the documented alias names (replaygain_album_gain etc.) from PR #5256:
   these got registered as JSON tags from mappings.yaml, so isMissing queried
   json_tree(media_file.tags, '$.replaygain_album_gain') which is always empty
   -> the playlist matched ALL songs.

2. Using the canonical field names (rgalbumgain etc.): not a tag/role, so SQL
   generation returned an error. Because refreshSmartPlaylist deletes old tracks
   before regenerating, the abort left the playlist empty.

Fix: add Nullable bool to FieldInfo and mark the four ReplayGain fields. Add
static alias entries (replaygain_album_gain -> rgalbumgain etc.) with
Numeric+Nullable set; because AddTagNames skips names already in the field map,
these static entries take precedence over the mappings.yaml tag registration.
missingExpr now emits IS NULL / IS NOT NULL for nullable column fields instead
of the json_tree lookup.

Fixes #5584

* chore(smartplaylist): address code review feedback

- Simplify the isMissing/isPresent unsupported-field error message,
  removing the internal "nullable fields" jargon
- Standardize comments on mappings.yaml (the actual filename)
- Clarify the alias precedence comment in the LookupField test
2026-06-10 21:12:31 -04:00
..
criteria.go refactor: centralize criteria sort parsing and extract smart playlist logic (#5415) 2026-04-26 14:49:59 -04:00
criteria_suite_test.go feat(bfr): Big Refactor: new scanner, lots of new fields and tags, improvements and DB schema changes (#2709) 2025-02-19 20:35:17 -05:00
criteria_test.go refactor: centralize criteria sort parsing and extract smart playlist logic (#5415) 2026-04-26 14:49:59 -04:00
export_test.go refactor: more warnings clean up 2026-05-20 17:43:12 -03:00
fields.go fix(smartplaylist): support isMissing/isPresent operators on ReplayGain fields (#5585) 2026-06-10 21:12:31 -04:00
fields_test.go fix(smartplaylist): support isMissing/isPresent operators on ReplayGain fields (#5585) 2026-06-10 21:12:31 -04:00
json.go fix(smartplaylists): coerce string booleans in smart playlist rules (#5450) 2026-05-01 19:21:48 -04:00
operators.go refactor: more warnings clean up 2026-05-20 17:43:12 -03:00
operators_test.go fix(smartplaylists): coerce string booleans in smart playlist rules (#5450) 2026-05-01 19:21:48 -04:00
sort.go refactor(smartplaylist): clarify FieldInfo naming in criteria package 2026-04-28 20:24:04 -04:00
sort_test.go refactor: centralize criteria sort parsing and extract smart playlist logic (#5415) 2026-04-26 14:49:59 -04:00
walk.go feat(smartplaylist): add isMissing and isPresent operators (#5436) 2026-04-28 19:40:08 -04:00
walk_test.go refactor: simplify criteria Expression interface 2026-04-26 10:58:57 -04:00