summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeif Lotfy <seif@lotfy.com>2012-12-29 15:13:54 +0100
committerSeif Lotfy <seif@lotfy.com>2012-12-29 15:13:54 +0100
commitabcb0f43f7569f12b45311b7d33b9b9172f9bab7 (patch)
tree56ad20c7682b1582f7c48c7f58484c1309baf25d
parentd45d54759f984efd5d9acb73e824bafca32bb25d (diff)
Remove distinct since it does not play well with the new query structure
-rw-r--r--src/db-reader.vala13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/db-reader.vala b/src/db-reader.vala
index d1d5ade2..c78e155d 100644
--- a/src/db-reader.vala
+++ b/src/db-reader.vala
@@ -171,7 +171,7 @@ public class DbReader : Object
public uint32[] find_event_ids_for_clause (WhereClause where,
uint max_events, uint result_type) throws EngineError
{
- string sql = "SELECT DISTINCT id FROM event_view ";
+ string sql = "SELECT id FROM event_view ";
string where_sql = "";
if (!where.is_empty ())
{
@@ -297,8 +297,6 @@ public class DbReader : Object
if (where.get_is_simple ())
sql = sql.replace ("FROM event_view", "FROM event");
- if (max_events > 0)
- sql += " LIMIT %u".printf (max_events);
int rc;
Sqlite.Statement stmt;
@@ -318,8 +316,13 @@ public class DbReader : Object
while ((rc = stmt.step()) == Sqlite.ROW)
{
- event_ids += (uint32) uint64.parse(
+ var event_id = (uint32) uint64.parse(
stmt.column_text (EventViewRows.ID));
+ // Events are supposed to be contiguous in the database
+ if (event_ids.length == 0 || event_ids[event_ids.length-1] != event_id) {
+ event_ids += event_id;
+ if (event_ids.length == max_events) break;
+ }
}
if (rc != Sqlite.DONE && rc != Sqlite.ROW)
{
@@ -600,7 +603,7 @@ public class DbReader : Object
}
return """
- SELECT DISTINCT id, %s, %s(timestamp) AS timestamp
+ SELECT id, %s, %s(timestamp) AS timestamp
%s
FROM event_view %s AND %s IS NOT NULL
GROUP BY %s