[tracker/distinct-aggregates: 1/2] Add support for DISTINCT in aggregates
- From: Mikael Ottela <mottela src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/distinct-aggregates: 1/2] Add support for DISTINCT in aggregates
- Date: Wed, 9 Dec 2009 21:29:39 +0000 (UTC)
commit 69964d031dc0be3a290ad4a2b2fb81750983500b
Author: Mikael Ottela <mikael ottela ixonos com>
Date: Tue Dec 8 22:05:23 2009 +0200
Add support for DISTINCT in aggregates
src/libtracker-data/tracker-sparql-query.vala | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index f085646..673abf8 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -616,24 +616,24 @@ public class Tracker.SparqlQuery : Object {
if (accept (SparqlTokenType.COUNT)) {
sql.append ("COUNT(");
- translate_expression (sql);
+ translate_aggregate_expression (sql);
sql.append (")");
type = PropertyType.INTEGER;
} else if (accept (SparqlTokenType.SUM)) {
sql.append ("SUM(");
- type = translate_expression (sql);
+ type = translate_aggregate_expression (sql);
sql.append (")");
} else if (accept (SparqlTokenType.AVG)) {
sql.append ("AVG(");
- type = translate_expression (sql);
+ type = translate_aggregate_expression (sql);
sql.append (")");
} else if (accept (SparqlTokenType.MIN)) {
sql.append ("MIN(");
- type = translate_expression (sql);
+ type = translate_aggregate_expression (sql);
sql.append (")");
} else if (accept (SparqlTokenType.MAX)) {
sql.append ("MAX(");
- type = translate_expression (sql);
+ type = translate_aggregate_expression (sql);
sql.append (")");
} else if (accept (SparqlTokenType.GROUP_CONCAT)) {
sql.append ("GROUP_CONCAT(");
@@ -1781,6 +1781,16 @@ public class Tracker.SparqlQuery : Object {
return optype;
}
+ PropertyType translate_aggregate_expression (StringBuilder sql) throws SparqlError {
+ expect (SparqlTokenType.OPEN_PARENS);
+ if (accept (SparqlTokenType.DISTINCT)) {
+ sql.append ("DISTINCT ");
+ }
+ var optype = translate_expression (sql);
+ expect (SparqlTokenType.CLOSE_PARENS);
+ return optype;
+ }
+
PropertyType translate_constraint (StringBuilder sql) throws SparqlError {
switch (current ()) {
case SparqlTokenType.STR:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]