Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cbhaley/calibre
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Aug 5, 2015
2 parents a212026 + 2e6f389 commit df3f850
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resources/metadata_sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ CREATE TRIGGER fkc_update_books_tags_link_b
CREATE TRIGGER series_insert_trg
AFTER INSERT ON series
BEGIN
UPDATE series SET sort=NEW.name WHERE id=NEW.id;
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
CREATE TRIGGER series_update_trg
AFTER UPDATE ON series
BEGIN
UPDATE series SET sort=NEW.name WHERE id=NEW.id;
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
pragma user_version=21;
pragma user_version=22;
25 changes: 25 additions & 0 deletions src/calibre/db/schema_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,28 @@ def upgrade_version_20(self):
self.db.execute(script)


def upgrade_version_21(self):
'''
Write the series sort into the existing sort column in the series table
'''

script = '''
DROP TRIGGER IF EXISTS series_insert_trg;
DROP TRIGGER IF EXISTS series_update_trg;
UPDATE series SET sort=title_sort(name);
CREATE TRIGGER series_insert_trg
AFTER INSERT ON series
BEGIN
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
CREATE TRIGGER series_update_trg
AFTER UPDATE ON series
BEGIN
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
'''
self.db.execute(script)

0 comments on commit df3f850

Please sign in to comment.