From 30ec309ff8550cab242331aabcaf2f27cfbd7ff6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 30 May 2011 08:45:58 +0200 Subject: [PATCH 1/2] Fixed up various index errors on InnoDB tables. --- openlp/plugins/songs/lib/db.py | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index ced98537e..9a332e994 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -165,7 +165,7 @@ def init_schema(url): Column(u'id', types.Integer, primary_key=True), Column(u'first_name', types.Unicode(128)), Column(u'last_name', types.Unicode(128)), - Column(u'display_name', types.Unicode(255), nullable=False) + Column(u'display_name', types.Unicode(255), index=True, nullable=False) ) # Definition of the "media_files" table @@ -186,7 +186,7 @@ def init_schema(url): songs_table = Table(u'songs', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'song_book_id', types.Integer, - ForeignKey(u'song_books.id'), default=0), + ForeignKey(u'song_books.id'), default=None), Column(u'title', types.Unicode(255), nullable=False), Column(u'alternate_title', types.Unicode(255)), Column(u'lyrics', types.UnicodeText, nullable=False), @@ -203,7 +203,7 @@ def init_schema(url): # Definition of the "topics" table topics_table = Table(u'topics', metadata, Column(u'id', types.Integer, primary_key=True), - Column(u'name', types.Unicode(128), nullable=False) + Column(u'name', types.Unicode(128), index=True, nullable=False) ) # Definition of the "authors_songs" table @@ -230,27 +230,6 @@ def init_schema(url): ForeignKey(u'topics.id'), primary_key=True) ) - # Define table indexes - Index(u'authors_id', authors_table.c.id) - Index(u'authors_display_name_id', authors_table.c.display_name, - authors_table.c.id) - Index(u'media_files_id', media_files_table.c.id) - Index(u'song_books_id', song_books_table.c.id) - Index(u'songs_id', songs_table.c.id) - Index(u'topics_id', topics_table.c.id) - Index(u'authors_songs_author', authors_songs_table.c.author_id, - authors_songs_table.c.song_id) - Index(u'authors_songs_song', authors_songs_table.c.song_id, - authors_songs_table.c.author_id) - Index(u'media_files_songs_file', media_files_songs_table.c.media_file_id, - media_files_songs_table.c.song_id) - Index(u'media_files_songs_song', media_files_songs_table.c.song_id, - media_files_songs_table.c.media_file_id) - Index(u'topics_song_topic', songs_topics_table.c.topic_id, - songs_topics_table.c.song_id) - Index(u'topics_song_song', songs_topics_table.c.song_id, - songs_topics_table.c.topic_id) - mapper(Author, authors_table) mapper(Book, song_books_table) mapper(MediaFile, media_files_table) From 99ae60aba318fc9b50bcaa1552ccac61cae593a4 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 30 May 2011 13:17:23 +0200 Subject: [PATCH 2/2] Fixed up loading a song from a service. --- openlp/plugins/songs/lib/mediaitem.py | 1 + openlp/plugins/songs/lib/xml.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 3d9a9ef76..65e2289cd 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -27,6 +27,7 @@ import logging import locale +import re from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 7bcf56aa1..f5ec28103 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -514,7 +514,7 @@ class OpenLyrics(object): ``song`` The song object. """ - song.song_book_id = 0 + song.song_book_id = None song.song_number = u'' if hasattr(properties, u'songbooks'): for songbook in properties.songbooks.songbook: