I've just started working on calibre and I'm still feeling my way around the source, but I had a question.
Why does the db.author_sort() lookup the author sort in the books table rather than the authors table and authors link table? As far as I can tell the only places db.author_sort() is used are in the initialization of the metadata_single dialog and in db.get_metadata(), which also uses authors_with_sort_strings().
I'm probably missing something, but it looks like a one way street, if authors->author_sort is updated using set_sort_field_for_author then books is also updated with the new author_sort, but if books->author_sort is updated with set_author_sort then just books is updated.
I'm specifically working on the
Ticket #847 and noticed that when I built author_sort using db.get_metadata().author_sort_map it came out differently than db.get_metadata().author_sort. After looking around I saw it was because they are drawing from two different tables, and in my particular case those tables had different data. For example my books table has "Oath of Swords" author_sort listed as Weber, David J. but looking up that book through book_authors_link and then to authors it shows as Weber, David.
I'm not really sure how they got out of sink, but it would make sense that if the author_sort column was necessary in both tables that there would only be one function for changing both tables rather than ones for updating one table or the other.
To summarize that wall of ramble.
- Why is there author_sort in the books table when author is looked up through the link table?
- Why are there functions for updating one table but not both?
- Why does get_metadata() draw from both rather than just building author_sort from the author_sort_map?
I'm still learning developing non-trivial programs and would appreciate your thoughts.
Also is there a better place to post questions like this?