Skip to content

Commit

Permalink
[rss] Fix new table setup for mysql
Browse files Browse the repository at this point in the history
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 sopel-irc#306
  • Loading branch information
embolalia committed Jul 30, 2013
1 parent 3ad02b0 commit fba42df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit fba42df

Please sign in to comment.