diff --git a/src/calibre/db/tests/writing.py b/src/calibre/db/tests/writing.py index a199da6b28..762517a294 100644 --- a/src/calibre/db/tests/writing.py +++ b/src/calibre/db/tests/writing.py @@ -297,6 +297,11 @@ class WritingTest(BaseTest): ae(sf('tags', {3: ('x', 'X')}), {3}, 'Failed when setting tag twice with different cases') ae(('x',), cache.field_for('tags', 3)) + # Test setting of authors with | in their names (for legacy database + # format compatibility | is replaced by ,) + ae(sf('authors', {3: ('Some| Author',)}), {3}) + ae(('Some, Author',), cache.field_for('authors', 3)) + # }}} def test_dirtied(self): # {{{ diff --git a/src/calibre/db/write.py b/src/calibre/db/write.py index fc8691aa42..ee81659984 100644 --- a/src/calibre/db/write.py +++ b/src/calibre/db/write.py @@ -156,7 +156,7 @@ def get_adapter(name, metadata): if name == 'author_sort': return lambda x: ans(x) or '' if name == 'authors': - return lambda x: ans(x) or (_('Unknown'),) + return lambda x: tuple(y.replace('|', ',') for y in ans(x)) or (_('Unknown'),) if name in {'timestamp', 'last_modified'}: return lambda x: ans(x) or UNDEFINED_DATE if name == 'series_index':