From a3452628463e4851448ca93c8815d82582431456 Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Sun, 14 Aug 2011 14:58:11 -0400 Subject: [PATCH] Factoids: fix bug when making an alias to a newkey that already has a factoid associated with it. --- plugins/Factoids/plugin.py | 4 ++-- plugins/Factoids/test.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/Factoids/plugin.py b/plugins/Factoids/plugin.py index bb55ce6ca..cb2ff60a6 100644 --- a/plugins/Factoids/plugin.py +++ b/plugins/Factoids/plugin.py @@ -345,11 +345,11 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler): # check if we already have the requested relation cursor.execute("""SELECT id FROM relations WHERE key_id=? and fact_id=?""", - (arelation[1], arelation[2])) + (newkey_info[0][0], arelation[2])) existentrelation = cursor.fetchall() if len(existentrelation) != 0: newkey_info = False - if len(newkey_info) == 0: + elif len(newkey_info) == 0: cursor.execute("""INSERT INTO keys VALUES (NULL, ?)""", (newkey,)) db.commit() diff --git a/plugins/Factoids/test.py b/plugins/Factoids/test.py index 035e4efed..da9590c9a 100644 --- a/plugins/Factoids/test.py +++ b/plugins/Factoids/test.py @@ -191,6 +191,10 @@ class FactoidsTestCase(ChannelPluginTestCase): self.assertError('alias foo gnoop') self.assertNotError('alias foo gnoop 2') self.assertRegexp('whatis gnoop', 'snorp') + self.assertNotError('learn floop as meep') + self.assertNotError('learn bar as baz') + self.assertNotError('alias floop bar') + self.assertRegexp('whatis bar', 'meep.*baz') def testRank(self): self.assertNotError('learn foo as bar')