From fba42dfe4a3047677dae8148354b5904c8598f5c Mon Sep 17 00:00:00 2001 From: Edward Powell Date: Tue, 30 Jul 2013 18:47:39 -0400 Subject: [PATCH] [rss] Fix new table setup for mysql Terrible, ugly code that should be removed at the first opportunity (i.e. when someone gets around to throwing out the crappy db system I embarrased myself with^W^W^W wrote.) Close issue #306 --- rss.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rss.py b/rss.py index 9a0c568d75..4bfafe9281 100644 --- a/rss.py +++ b/rss.py @@ -40,12 +40,18 @@ def setup(bot): try: c.execute('SELECT * FROM rss_feeds') except StandardError: + # MySQL needs to only compare on the first n characters of a TEXT field + # but SQLite won't accept the syntax needed to make it do it. + if bot.db.type == 'mysql': + primary_key = '(channel(254), feed_name(254)))' + else: + primary_key = '(channel, feed_name))' c.execute(''' CREATE TABLE IF NOT EXISTS rss_feeds (channel TEXT, feed_name TEXT, feed_url TEXT, fg TINYINT, bg TINYINT, enabled BOOL DEFAULT 1, article_title TEXT, article_url TEXT, - published TEXT, etag TEXT, modified TEXT, PRIMARY KEY (channel, feed_name)) - ''') + published TEXT, etag TEXT, modified TEXT, PRIMARY KEY + ''' + primary_key) migrate_from_old_tables(c)