[tracker/parser] SPARQL: Fix ORDER BY and GROUP BY
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/parser] SPARQL: Fix ORDER BY and GROUP BY
- Date: Mon, 10 Aug 2009 12:50:06 +0000 (UTC)
commit f15a68d7f686a8debd5541520636851b515962be
Author: Jürg Billeter <j bitron ch>
Date: Mon Aug 10 14:49:45 2009 +0200
SPARQL: Fix ORDER BY and GROUP BY
src/libtracker-data/tracker-sparql-query.vala | 39 +++++++++++++++++-------
1 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 09b0de5..2b27ab2 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -589,12 +589,7 @@ public class Tracker.SparqlQuery : Object {
first = false;
}
- if (current () == SparqlTokenType.VAR) {
- next ();
- pattern_sql.append (get_sql_for_variable (get_last_string ().substring (1)));
- } else {
- parse_primary_expression ();
- }
+ parse_primary_expression_as_string ();
switch (current ()) {
case SparqlTokenType.FROM:
@@ -633,15 +628,15 @@ public class Tracker.SparqlQuery : Object {
sql.append (", ");
}
if (accept (SparqlTokenType.ASC)) {
- parse_bracketted_expression ();
+ parse_bracketted_expression_as_string ();
sql.append (pattern_sql.str);
sql.append (" ASC");
} else if (accept (SparqlTokenType.DESC)) {
- parse_bracketted_expression ();
+ parse_bracketted_expression_as_string ();
sql.append (pattern_sql.str);
sql.append (" DESC");
} else {
- parse_primary_expression ();
+ parse_primary_expression_as_string ();
sql.append (pattern_sql.str);
}
pattern_sql.truncate (0);
@@ -659,15 +654,15 @@ public class Tracker.SparqlQuery : Object {
sql.append (", ");
}
if (accept (SparqlTokenType.ASC)) {
- parse_bracketted_expression ();
+ parse_bracketted_expression_as_string ();
sql.append (pattern_sql.str);
sql.append (" ASC");
} else if (accept (SparqlTokenType.DESC)) {
- parse_bracketted_expression ();
+ parse_bracketted_expression_as_string ();
sql.append (pattern_sql.str);
sql.append (" DESC");
} else {
- parse_primary_expression ();
+ parse_primary_expression_as_string ();
sql.append (pattern_sql.str);
}
pattern_sql.truncate (0);
@@ -1036,6 +1031,15 @@ public class Tracker.SparqlQuery : Object {
}
}
+ void parse_primary_expression_as_string () throws SparqlError {
+ if (current () == SparqlTokenType.VAR) {
+ next ();
+ pattern_sql.append (get_sql_for_variable (get_last_string ().substring (1)));
+ } else {
+ parse_primary_expression ();
+ }
+ }
+
void parse_primary_expression () throws SparqlError {
switch (current ()) {
case SparqlTokenType.OPEN_PARENS:
@@ -1263,6 +1267,17 @@ public class Tracker.SparqlQuery : Object {
parse_conditional_or_expression ();
}
+ void parse_bracketted_expression_as_string () throws SparqlError {
+ expect (SparqlTokenType.OPEN_PARENS);
+ if (current () == SparqlTokenType.VAR) {
+ next ();
+ pattern_sql.append (get_sql_for_variable (get_last_string ().substring (1)));
+ } else {
+ parse_expression ();
+ }
+ expect (SparqlTokenType.CLOSE_PARENS);
+ }
+
void parse_bracketted_expression () throws SparqlError {
expect (SparqlTokenType.OPEN_PARENS);
parse_expression ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]