[tracker/wip/carlosg/date-var-names] libtracker-data: Pass correct variable name for non-direct types
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/date-var-names] libtracker-data: Pass correct variable name for non-direct types
- Date: Fri, 4 Mar 2022 22:57:20 +0000 (UTC)
commit 6303cd484162b7750131d69587e5d39614d44270
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Mar 4 23:42:40 2022 +0100
libtracker-data: Pass correct variable name for non-direct types
Property types like dates or resources use wrapper functions to print
the user visible values, so the SQL query ends up as:
SELECT SparqlFormatTime("v_date") ...
And results in those variables having the unintended name (e.g.
`SparqlFormatTime("v_date")` instead of `date`. Ensure these (and
any other variable, just redundantly) get an AS alias so we get
the right variable name propagated. E.g.:
SELECT SparqlFormatTime("v_date") AS "date" ...
It is worth noting that in other places, the internal variable
name (e.g. `v_date`) is passed to the upper layers, and the v_
prefix is removed in TrackerDBCursor code. This cannot be done
here esp. for date types, since SQL places GROUP/ORDER BY at a
different level than SPARQL, so these manage to pick up the
user-visible strings instead of the more accurate timestamps.
This is not intended, so produce the final variable name in
place so the SQL does not get confused about that variable to
use.
Fixes: https://gitlab.gnome.org/GNOME/tracker/-/issues/352
src/libtracker-data/tracker-sparql.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index d02686360..fa52cc85e 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2968,7 +2968,9 @@ translate_SelectClause (TrackerSparql *sparql,
return FALSE;
}
} else {
- if (!found) {
+ if (sparql->current_state->select_context == sparql->context) {
+ _append_string_printf (sparql, "AS \"%s\" ", var->name);
+ } else if (!found) {
_append_string_printf (sparql, "AS %s ",
tracker_variable_get_sql_expression
(var));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]