Factoids: fix bug when making an alias to a newkey that already has a factoid associated with it.

This commit is contained in:
Daniel Folkinshteyn 2011-08-14 14:58:11 -04:00
parent af32d6bfd3
commit a345262846
2 changed files with 6 additions and 2 deletions

View File

@ -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()

View File

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