Commit 5dca5b65 authored by Carlos Garnacho's avatar Carlos Garnacho

Merge branch 'wip/carlosg/double-precision'

parents 69c3cf70 d47efdcd
Pipeline #64554 passed with stage
in 2 minutes and 17 seconds
......@@ -1659,7 +1659,7 @@ string_to_gvalue (const gchar *value,
break;
case TRACKER_PROPERTY_TYPE_DOUBLE:
g_value_init (gvalue, G_TYPE_DOUBLE);
g_value_set_double (gvalue, atof (value));
g_value_set_double (gvalue, g_ascii_strtod (value, NULL));
break;
case TRACKER_PROPERTY_TYPE_DATE:
g_value_init (gvalue, G_TYPE_INT64);
......@@ -1700,7 +1700,9 @@ gvalue_to_string (TrackerPropertyType type,
retval = g_value_get_int64 (gvalue) == 0 ? g_strdup ("false") : g_strdup ("true");
break;
case TRACKER_PROPERTY_TYPE_DOUBLE:
retval = g_strdup_printf ("%f", g_value_get_double (gvalue));
retval = g_new0 (char, G_ASCII_DTOSTR_BUF_SIZE);
g_ascii_dtostr (retval, G_ASCII_DTOSTR_BUF_SIZE,
g_value_get_double (gvalue));
break;
case TRACKER_PROPERTY_TYPE_DATE:
datet = g_value_get_int64 (gvalue);
......
......@@ -1369,8 +1369,9 @@ convert_expression_to_string (TrackerSparql *sparql,
switch (type) {
case TRACKER_PROPERTY_TYPE_STRING:
case TRACKER_PROPERTY_TYPE_INTEGER:
/* Nothing to convert. Do not use CAST to convert integers to
* strings as this breaks use of index when sorting by variable
case TRACKER_PROPERTY_TYPE_DOUBLE:
/* Nothing to convert. Do not use CAST to convert integer/double to
* to string as this breaks use of index when sorting by variable
* introduced in select expression
*/
break;
......@@ -2612,8 +2613,29 @@ get_solution_for_pattern (TrackerSparql *sparql,
while (tracker_db_cursor_iter_next (cursor, NULL, NULL)) {
for (i = 0; i < n_cols; i++) {
const gchar *str = tracker_db_cursor_get_string (cursor, i, NULL);
tracker_solution_add_value (solution, str);
GValue value = G_VALUE_INIT;
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);
}
}
......
......@@ -180,6 +180,7 @@ const TestInfo tests[] = {
{ "update/delete-data-query-2", "update/delete-data-2", FALSE, TRUE },
{ "update/delete-where-query-1", "update/delete-where-1", FALSE, FALSE },
{ "update/delete-where-query-2", "update/delete-where-2", FALSE, FALSE },
{ "update/delete-where-query-3", "update/delete-where-3", FALSE, FALSE },
{ "update/invalid-insert-where-query-1", "update/invalid-insert-where-1", FALSE, TRUE },
{ "update/delete-insert-where-query-1", "update/delete-insert-where-1", FALSE, FALSE },
{ "update/delete-insert-where-query-2", "update/delete-insert-where-2", FALSE, FALSE },
......
INSERT DATA {
example:a a example:A ;
example:double 0.333333333333333333333 .
example:b a example:A ;
example:double 0.444444444444444444444 .
}
DELETE WHERE {
example:a example:double ?o
}
"http://example/b" "0.444444444444444"
SELECT ?s ?o { ?s example:double ?o }
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