← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-714510 into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-714510 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #714510 in OpenLP: "MySQL support on Windows fails "
  https://bugs.launchpad.net/openlp/+bug/714510

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-714510/+merge/62866

Fix bug #714510 by removing the indexes, which were unnecessary and caused various foreign key constraints in real relational databases like InnoDB and PostgreSQL. I also defaulted the song book id on songs to NULL instead of 0, since NULL is a valid value for foreign keys.
-- 
https://code.launchpad.net/~raoul-snyman/openlp/bug-714510/+merge/62866
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/bug-714510 into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/db.py'
--- openlp/plugins/songs/lib/db.py	2011-05-27 08:21:23 +0000
+++ openlp/plugins/songs/lib/db.py	2011-05-30 11:23:23 +0000
@@ -165,7 +165,7 @@
         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 @@
     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 @@
     # 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 @@
             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)

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-05-28 19:38:19 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-05-30 11:23:23 +0000
@@ -27,6 +27,7 @@
 
 import logging
 import locale
+import re
 
 from PyQt4 import QtCore, QtGui
 from sqlalchemy.sql import or_

=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py	2011-05-26 17:11:22 +0000
+++ openlp/plugins/songs/lib/xml.py	2011-05-30 11:23:23 +0000
@@ -514,7 +514,7 @@
         ``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:


Follow ups