Commit bb88e1d3 authored by Carlos Garnacho's avatar Carlos Garnacho

libtracker-data: Convert from GValues when generating solution for updates

Conversion to strings in Sqlite may cause precision loss which may result in
mismatches. Instead, get values from the cursor as GValues and handle
conversions to strings ourselves.

Ideally we should be preserving these as GValues, as further down the
updates handling pipe we translate these strings to GValues again. However
that involves heavier refactors.

https://bugzilla.gnome.org/show_bug.cgi?id=659600
Closes: #45
parent 7d84c563
...@@ -2613,8 +2613,29 @@ get_solution_for_pattern (TrackerSparql *sparql, ...@@ -2613,8 +2613,29 @@ get_solution_for_pattern (TrackerSparql *sparql,
while (tracker_db_cursor_iter_next (cursor, NULL, NULL)) { while (tracker_db_cursor_iter_next (cursor, NULL, NULL)) {
for (i = 0; i < n_cols; i++) { for (i = 0; i < n_cols; i++) {
const gchar *str = tracker_db_cursor_get_string (cursor, i, NULL); GValue value = G_VALUE_INIT;
tracker_solution_add_value (solution, str);
tracker_db_cursor_get_value (cursor, i, &value);
if (G_VALUE_TYPE (&value) == G_TYPE_STRING) {
tracker_solution_add_value (solution,
g_value_get_string (&value));
} else if (G_VALUE_TYPE (&value) == G_TYPE_INT64) {
gchar *str;
str = g_strdup_printf ("%" G_GINT64_FORMAT,
g_value_get_int64 (&value));
tracker_solution_add_value (solution, str);
g_free (str);
} else if (G_VALUE_TYPE (&value) == G_TYPE_DOUBLE) {
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr (buf, sizeof (buf),
g_value_get_double (&value));
tracker_solution_add_value (solution, buf);
} else {
g_assert_not_reached ();
}
g_value_unset (&value);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment