[tracker/sam/2.x-export-data: 3/3] cli: tracker export: Hardcode some value types



commit bb75f2d8f45b9d8247c97be025f18eb149f94cd5
Author: Sam Thursfield <sam afuera me uk>
Date:   Tue Jun 2 12:26:16 2020 +0200

    cli: tracker export: Hardcode some value types
    
    We were outputting tag URIs formatted as strings rather than URIs.
    
    The root cause here is that tracker_sparql_cursor_get_value_type()
    doesn't reliably distingish URIs and strings for us. I worked around
    this by querying from the schema, but the query doesn't work when
    rdfs:range is rdf:Resource. Rather than complicate the query, I've
    hardcoded the values here.

 src/tracker/tracker-export.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/tracker/tracker-export.c b/src/tracker/tracker-export.c
index 87947788f..96f3ae955 100644
--- a/src/tracker/tracker-export.c
+++ b/src/tracker/tracker-export.c
@@ -337,18 +337,17 @@ export_run_photo_favourites (void)
        const gchar *query;
        g_autoptr(GError) error = NULL;
 
-       query = "SELECT \"\" COALESCE(nie:url(?u), ?u) ?p ?v"
-                "       (EXISTS { ?p rdfs:range [ rdfs:subClassOf rdfs:Resource ] }) AS ?is_resource "
+       query = "SELECT \"\" COALESCE(nie:url(?u), ?u) ?p ?v ?is_resource"
                "{"
                "    { "
-               "        SELECT ?u (rdf:type AS ?p) (nmm:Photo AS ?v) "
+               "        SELECT ?u (rdf:type AS ?p) (nmm:Photo AS ?v) (true AS ?is_resource)"
                "        { "
                "            ?u a nmm:Photo ; nao:hasTag nao:predefined-tag-favorite . "
                "        } "
                "    } "
                "    UNION "
                "    { "
-               "        SELECT ?u (nao:hasTag AS ?p) (nao:predefined-tag-favorite AS ?v) "
+               "        SELECT ?u (nao:hasTag AS ?p) (nao:predefined-tag-favorite AS ?v) (true AS 
?is_resource)"
                "        { "
                "            ?u a nmm:Photo ; nao:hasTag nao:predefined-tag-favorite . "
                "        } "
@@ -371,18 +370,17 @@ export_run_files_starred (void)
        const gchar *query;
        g_autoptr(GError) error = NULL;
 
-       query = "SELECT \"\" COALESCE(nie:url(?u), ?u) ?p ?v"
-                "       (EXISTS { ?p rdfs:range [ rdfs:subClassOf rdfs:Resource ] }) AS ?is_resource "
+       query = "SELECT \"\" COALESCE(nie:url(?u), ?u) ?p ?v ?is_resource"
                "{"
                "    { "
-               "        SELECT ?u (rdf:type AS ?p) (nfo:FileDataObject AS ?v) "
+               "        SELECT ?u (rdf:type AS ?p) (nfo:FileDataObject AS ?v) (true AS ?is_resource)"
                "        { "
                "            ?u a nfo:FileDataObject ; nao:hasTag <urn:gnome:nautilus:starred> "
                "        } "
                "    } "
                "    UNION "
                "    { "
-               "        SELECT ?u (nao:hasTag AS ?p) (<urn:gnome:nautilus:starred> AS ?v) "
+               "        SELECT ?u (nao:hasTag AS ?p) (<urn:gnome:nautilus:starred> AS ?v) (true AS 
?is_resource)"
                "        { "
                "            ?u a nfo:FileDataObject ; nao:hasTag <urn:gnome:nautilus:starred> "
                "        } "


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]