zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #01849
lp:~thekorn/zeitgeist/fix-642686-eventview-add-origin-and-uri-id into lp:zeitgeist
Markus Korn has proposed merging lp:~thekorn/zeitgeist/fix-642686-eventview-add-origin-and-uri-id into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
Related bugs:
#642686 Add subj_uri_id and subj_origin_id columns to event_view
https://bugs.launchpad.net/bugs/642686
Added 'subj_uri_id' and 'subj_origin_id' columns to event_view (LP: #642686)
Note: We don't need to raise the version of our db scheme, as this event_view is regenerated on every startup anyway.
--
https://code.launchpad.net/~thekorn/zeitgeist/fix-642686-eventview-add-origin-and-uri-id/+merge/35952
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~thekorn/zeitgeist/fix-642686-eventview-add-origin-and-uri-id into lp:zeitgeist.
=== modified file '_zeitgeist/engine/sql.py'
--- _zeitgeist/engine/sql.py 2010-09-18 15:09:08 +0000
+++ _zeitgeist/engine/sql.py 2010-09-19 10:49:40 +0000
@@ -365,10 +365,14 @@
AS payload,
(SELECT value FROM uri WHERE uri.id=event.subj_id)
AS subj_uri,
+ (SELECT id FROM uri WHERE uri.id=event.subj_id)
+ AS subj_uri_id,
event.subj_interpretation,
event.subj_manifestation,
(SELECT value FROM uri WHERE uri.id=event.subj_origin)
AS subj_origin,
+ (SELECT id FROM uri WHERE uri.id=event.subj_origin)
+ AS subj_origin_id,
event.subj_mimetype,
(SELECT value FROM text WHERE text.id = event.subj_text)
AS subj_text,
@@ -484,22 +488,14 @@
def add_text_condition(self, column, value, like=False, negation=False, cache=None):
if like:
- # thekorn: unfortunatly the data in event_view is a bit inconsistent
- # e.g.:
- # subj_uri and subj_origin are presented as string-values
- # actor and subj_mimetype are ids
- # (LP: #580601)
+ assert column in ("subj_uri", "subj_origin", "actor", "subj_mimetype"), \
+ "prefix search on the %r column is not supported by zeitgeist"
if column in ("subj_uri", "subj_origin"):
- value_type = "value"
- elif column in ("actor", "subj_mimetype"):
- value_type = "id"
+ view_column = "%s_id" %column
else:
- raise AssertionError("We don't know how to handle this type of data")
- # thekorn: this is a first (unoptimized version)
- # see http://www.sqlite.org/optoverview.html '4.0 The LIKE optimization'
- # for how this will look in the future
- sql = "%s %sIN (SELECT %s FROM %s WHERE value GLOB ?)" \
- %(column, self.NOT if negation else "", value_type, TABLE_MAP.get(column, column))
+ view_column = column
+ sql = "%s %sIN (SELECT id FROM %s WHERE value GLOB ?)" \
+ %(view_column, self.NOT if negation else "", TABLE_MAP.get(column, column))
value += "*"
else:
sql = "%s %s= ?" %(column, "!" if negation else "")
=== modified file 'test/sql-test.py'
--- test/sql-test.py 2010-05-15 08:45:08 +0000
+++ test/sql-test.py 2010-09-19 10:49:40 +0000
@@ -91,12 +91,12 @@
where = WhereClause(WhereClause.AND)
where.add_text_condition("subj_uri", "bar", like=True)
self.assertEquals(where.sql.replace("?", "%s") % tuple(where.arguments),
- "(subj_uri IN (SELECT value FROM uri WHERE value GLOB bar*))")
+ "(subj_uri_id IN (SELECT id FROM uri WHERE value GLOB bar*))")
where = WhereClause(WhereClause.AND)
where.add_text_condition("subj_origin", "bar", like=True)
self.assertEquals(where.sql.replace("?", "%s") % tuple(where.arguments),
- "(subj_origin IN (SELECT value FROM uri WHERE value GLOB bar*))")
+ "(subj_origin_id IN (SELECT id FROM uri WHERE value GLOB bar*))")
where = WhereClause(WhereClause.AND)
where.add_text_condition("actor", "bar", like=True, negation=True)