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')