mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-02 08:21:08 -05:00
Factoids: Fix @lock and @unlock.
This commit is contained in:
parent
c133d973aa
commit
b9a46cef21
@ -583,10 +583,10 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
"""
|
"""
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("UPDATE factoids, keys, relations "
|
cursor.execute("UPDATE factoids "
|
||||||
"SET factoids.locked=1 WHERE key LIKE ? AND "
|
"SET locked=1 WHERE factoids.id IN "
|
||||||
"factoids.id=relations.fact_id AND "
|
"(SELECT fact_id FROM relations WHERE key_id IN "
|
||||||
"keys.id=relations.key_id", (key,))
|
"(SELECT id FROM keys WHERE key LIKE ?));", (key,))
|
||||||
db.commit()
|
db.commit()
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
lock = wrap(lock, ['channel', 'text'])
|
lock = wrap(lock, ['channel', 'text'])
|
||||||
@ -601,10 +601,10 @@ class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
"""
|
"""
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""UPDATE factoids, keys, relations
|
cursor.execute("UPDATE factoids "
|
||||||
SET factoids.locked=1 WHERE key LIKE ? AND
|
"SET locked=0 WHERE factoids.id IN "
|
||||||
factoids.id=relations.fact_id AND
|
"(SELECT fact_id FROM relations WHERE key_id IN "
|
||||||
keys.id=relations.key_id""", (key,))
|
"(SELECT id FROM keys WHERE key LIKE ?));", (key,))
|
||||||
db.commit()
|
db.commit()
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
unlock = wrap(unlock, ['channel', 'text'])
|
unlock = wrap(unlock, ['channel', 'text'])
|
||||||
|
@ -208,4 +208,10 @@ class FactoidsTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNotError('learn foo as "\\"bar\\""')
|
self.assertNotError('learn foo as "\\"bar\\""')
|
||||||
self.assertRegexp('whatis foo', r'"bar"')
|
self.assertRegexp('whatis foo', r'"bar"')
|
||||||
|
|
||||||
|
def testLock(self):
|
||||||
|
self.assertNotError('learn foo as bar')
|
||||||
|
self.assertNotError('lock foo')
|
||||||
|
self.assertNotError('unlock foo')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user