[tracker] SPARQL: Fix local time handling with optional patterns
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] SPARQL: Fix local time handling with optional patterns
- Date: Mon, 9 May 2011 14:25:00 +0000 (UTC)
commit 9a34a2c8a31b2856d6e2bccb0566e0f0c50b06b3
Author: Jürg Billeter <j bitron ch>
Date: Mon May 9 14:39:19 2011 +0200
SPARQL: Fix local time handling with optional patterns
Fixes NB#253807.
src/libtracker-data/tracker-sparql-pattern.vala | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index a5fc6cf..d2fb265 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -961,6 +961,11 @@ class Tracker.Sparql.Pattern : Object {
// first used in optional part
context.parent_context.var_set.insert (v, VariableState.OPTIONAL);
select.append_printf ("t%d_g.%s", right_index, v.sql_expression);
+
+ if (v.binding.data_type == PropertyType.DATETIME) {
+ select.append_printf (", t%d_g.%s", right_index, v.get_extra_sql_expression ("localDate"));
+ select.append_printf (", t%d_g.%s", right_index, v.get_extra_sql_expression ("localTime"));
+ }
} else {
if (first_common) {
sql.append (" ON ");
@@ -973,10 +978,20 @@ class Tracker.Sparql.Pattern : Object {
// variable definitely bound in non-optional part
sql.append_printf ("t%d_g.%s = t%d_g.%s", left_index, v.sql_expression, right_index, v.sql_expression);
select.append_printf ("t%d_g.%s", left_index, v.sql_expression);
+
+ if (v.binding.data_type == PropertyType.DATETIME) {
+ select.append_printf (", t%d_g.%s", left_index, v.get_extra_sql_expression ("localDate"));
+ select.append_printf (", t%d_g.%s", left_index, v.get_extra_sql_expression ("localTime"));
+ }
} else if (old_state == VariableState.OPTIONAL) {
// variable maybe bound in non-optional part
sql.append_printf ("(t%d_g.%s IS NULL OR t%d_g.%s = t%d_g.%s)", left_index, v.sql_expression, left_index, v.sql_expression, right_index, v.sql_expression);
select.append_printf ("COALESCE (t%d_g.%s, t%d_g.%s) AS %s", left_index, v.sql_expression, right_index, v.sql_expression, v.sql_expression);
+
+ if (v.binding.data_type == PropertyType.DATETIME) {
+ select.append_printf (", COALESCE (t%d_g.%s, t%d_g.%s) AS %s", left_index, v.get_extra_sql_expression ("localDate"), right_index, v.get_extra_sql_expression ("localDate"), v.get_extra_sql_expression ("localDate"));
+ select.append_printf (", COALESCE (t%d_g.%s, t%d_g.%s) AS %s", left_index, v.get_extra_sql_expression ("localTime"), right_index, v.get_extra_sql_expression ("localTime"), v.get_extra_sql_expression ("localTime"));
+ }
}
}
}
@@ -990,6 +1005,11 @@ class Tracker.Sparql.Pattern : Object {
}
select.append_printf ("t%d_g.%s", left_index, v.sql_expression);
+
+ if (v.binding.data_type == PropertyType.DATETIME) {
+ select.append_printf (", t%d_g.%s", left_index, v.get_extra_sql_expression ("localDate"));
+ select.append_printf (", t%d_g.%s", left_index, v.get_extra_sql_expression ("localTime"));
+ }
}
}
if (first) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]