Merge pull request #4140 from jcassette/aunique-flexattr

Use slow queries for flexible attributes in aunique (fix #2678, close #3553)
This commit is contained in:
Adrian Sampson 2021-11-11 14:40:07 -05:00 committed by GitHub
commit f3552f09cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View file

@ -1690,7 +1690,9 @@ class DefaultTemplateFunctions:
subqueries = []
for key in keys:
value = album.get(key, '')
subqueries.append(dbcore.MatchQuery(key, value))
# Use slow queries for flexible attributes.
fast = key in album.item_keys
subqueries.append(dbcore.MatchQuery(key, value, fast))
albums = self.lib.albums(dbcore.AndQuery(subqueries))
# If there's only one album to matching these details, then do

View file

@ -70,6 +70,9 @@ Bug fixes:
* :doc:`/plugins/export`: Fix duplicated output.
* :doc:`/dev/library`: Use slow queries for flexible attributes in aunique.
:bug:`2678` :bug:`3553`
1.5.0 (August 19, 2021)
-----------------------

View file

@ -791,6 +791,16 @@ class DisambiguationTest(_common.TestCase, PathFormattingMixin):
self._setf('foo%aunique{albumartist album,year,}/$title')
self._assert_dest(b'/base/foo 2001/the title', self.i1)
def test_key_flexible_attribute(self):
album1 = self.lib.get_album(self.i1)
album1.flex = 'flex1'
album2 = self.lib.get_album(self.i2)
album2.flex = 'flex2'
album1.store()
album2.store()
self._setf('foo%aunique{albumartist album flex,year}/$title')
self._assert_dest(b'/base/foo/the title', self.i1)
class PluginDestinationTest(_common.TestCase):
def setUp(self):