Merge lp:~stefanor/ibid/empty-factoid-606065 into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 963
Merged at revision: 971
Proposed branch: lp:~stefanor/ibid/empty-factoid-606065
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
Diff against target: 42 lines (+16/-1)
1 file modified
ibid/plugins/factoid.py (+16/-1)
To merge this branch: bzr merge lp:~stefanor/ibid/empty-factoid-606065
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Max Rabkin Approve
Review via email: mp+32702@code.launchpad.net

Commit message

Get rid of (and disallow) empty factoid names

Description of the change

Get rid of (and disallow) empty factoid names

To post a comment you must log in.
Revision history for this message
Max Rabkin (max-rabkin) wrote :

Can we not add a non-empty constraint to the schema so that this gets caught even if we add more ways to add factoids?

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote :

> Can we not add a non-empty constraint to the schema so that this gets caught
> even if we add more ways to add factoids?

We don't currently have database-agnostic support for such constraints

Revision history for this message
Max Rabkin (max-rabkin) wrote :

<Taejo> tibid: ?! is <reply>$who: ‽
<tibid> Taejo: Sorry, I'm not interested in empty factoids

Revision history for this message
Stefano Rivera (stefanor) wrote :

Max: Of course that's a positive result from this merge, that is a separate bug

Revision history for this message
Max Rabkin (max-rabkin) wrote :

Of course. I was short on sleep. I'm a little concerned about the data-loss issue in the schema-upgrade. Perhaps we should rename it to "<empty>" or somesuch?

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/factoid.py'
2--- ibid/plugins/factoid.py 2010-05-11 22:31:27 +0000
3+++ ibid/plugins/factoid.py 2010-08-15 10:08:45 +0000
4@@ -92,8 +92,15 @@
5 key='_name', nullable=False, unique=True,
6 index=True), force_rebuild=True)
7 self.add_index(self.table.c._name)
8+ def upgrade_8_to_9(self):
9+ for row in self.upgrade_session.query(FactoidName) \
10+ .filter_by(name=u'') \
11+ .all():
12+ self.upgrade_session.delete(row)
13+ if len(row.factoid.names) == 0:
14+ self.upgrade_session.delete(row.factoid)
15
16- __table__.versioned_schema = FactoidNameSchema(__table__, 8)
17+ __table__.versioned_schema = FactoidNameSchema(__table__, 9)
18
19 def __init__(self, name, identity_id, factoid_id=None, factpack=None):
20 self.name = name
21@@ -354,6 +361,10 @@
22
23 target = strip_name(target)
24
25+ if target == u'':
26+ event.addresponse(u"Sorry, I'm not interested in empty factoids")
27+ return
28+
29 if target.lower() == source.lower():
30 event.addresponse(u"That makes no sense, they *are* the same")
31 return
32@@ -541,6 +552,10 @@
33
34 name = strip_name(name)
35
36+ if name == u'':
37+ event.addresponse(u"Sorry, I'm not interested in empty factoids")
38+ return
39+
40 if name.lower() in self.interrogatives:
41 event.addresponse(choice((
42 u"I'm afraid I have no idea",

Subscribers

People subscribed via source and target branches