diff --git a/src/calibre/db/lazy.py b/src/calibre/db/lazy.py index 0b73b51ac0..566e51b32a 100644 --- a/src/calibre/db/lazy.py +++ b/src/calibre/db/lazy.py @@ -12,7 +12,7 @@ from functools import wraps from collections import MutableMapping, MutableSequence from copy import deepcopy -from calibre.ebooks.metadata.book.base import Metadata, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, NULL_VALUES +from calibre.ebooks.metadata.book.base import Metadata, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, NULL_VALUES, ALL_METADATA_FIELDS from calibre.ebooks.metadata.book.formatter import SafeFormat from calibre.utils.date import utcnow @@ -350,3 +350,8 @@ class ProxyMetadata(Metadata): return field_metadata[field] return None + def all_field_keys(self): + um = ga(self, '_user_metadata') + return frozenset(ALL_METADATA_FIELDS.union(um.iterkeys())) + + diff --git a/src/calibre/db/tests/reading.py b/src/calibre/db/tests/reading.py index c242206539..dbeda9f6b0 100644 --- a/src/calibre/db/tests/reading.py +++ b/src/calibre/db/tests/reading.py @@ -495,5 +495,13 @@ class ReadingTest(BaseTest): self.assertEqual(mi.format_field(field), pmi.format_field(field), 'Custom field format: %s not the same for book %s' % (field, book_id)) + # Test handling of recursive templates + cache.create_custom_column('comp2', 'comp2', 'composite', False, display={'composite_template':'{title}'}) + cache.create_custom_column('comp1', 'comp1', 'composite', False, display={'composite_template':'foo{#comp2}'}) + cache.close() + cache = self.init_cache() + mi, pmi = cache.get_metadata(1), cache.get_proxy_metadata(1) + self.assertEqual(mi.get('#comp1'), pmi.get('#comp1')) + # }}}