[tracker/wip/carlosg/serialize-api: 8/11] libtracker-data: Forward annotated column types on DESCRIBE queries




commit 4749683b24554ad1f9543d0a0eed8a73dd5fbd5f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jan 30 16:09:00 2022 +0100

    libtracker-data: Forward annotated column types on DESCRIBE queries
    
    All of subject/predicate/graph are ensured to always be resources, the
    only variable type is the object, which is fetched from the tracker_triples
    table directly.
    
    Since this involves changes (towards better) in the interpretation of
    RDF data for our serialization tests, update these as well.

 src/libtracker-data/tracker-sparql.c                 | 20 +++++++++++++-------
 .../serialize/describe-graph-trig.out                |  6 +++---
 .../serialize/describe-graph-ttl.out                 |  4 ++--
 .../serialize/describe-single-trig.out               |  2 +-
 .../serialize/describe-single-ttl.out                |  2 +-
 .../serialize/describe-var-trig.out                  |  4 ++--
 .../libtracker-sparql/serialize/describe-var-ttl.out |  4 ++--
 7 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 0ea9f4e27..51f3e1cd5 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -3409,13 +3409,19 @@ translate_DescribeQuery (TrackerSparql  *sparql,
        /* DescribeQuery ::= 'DESCRIBE' ( VarOrIri+ | '*' ) DatasetClause* WhereClause? SolutionModifier
         */
        _expect (sparql, RULE_TYPE_LITERAL, LITERAL_DESCRIBE);
-       _append_string (sparql,
-                       "SELECT "
-                       "  COALESCE((SELECT Uri FROM Resource WHERE ID = subject), 'urn:bnode:' || subject),"
-                       "  (SELECT Uri FROM Resource WHERE ID = predicate),"
-                       "  object, "
-                       "  (SELECT Uri FROM Resource WHERE ID = graph) "
-                       "FROM tracker_triples ");
+       _append_string_printf (sparql,
+                              "SELECT "
+                              "  COALESCE((SELECT Uri FROM Resource WHERE ID = subject), 'urn:bnode:' || 
subject),"
+                              "  (SELECT Uri FROM Resource WHERE ID = predicate),"
+                              "  object, "
+                              "  (SELECT Uri FROM Resource WHERE ID = graph) ");
+
+       handle_value_type_column (sparql, TRACKER_PROPERTY_TYPE_RESOURCE, NULL);
+       handle_value_type_column (sparql, TRACKER_PROPERTY_TYPE_RESOURCE, NULL);
+       _append_string (sparql, ", object_type ");
+       handle_value_type_column (sparql, TRACKER_PROPERTY_TYPE_RESOURCE, NULL);
+
+       _append_string_printf (sparql, "FROM tracker_triples ");
 
        if (sparql->policy.graphs) {
                _append_graph_checks (sparql, "graph",
diff --git a/tests/libtracker-sparql/serialize/describe-graph-trig.out 
b/tests/libtracker-sparql/serialize/describe-graph-trig.out
index ac95a7f36..07165da63 100644
--- a/tests/libtracker-sparql/serialize/describe-graph-trig.out
+++ b/tests/libtracker-sparql/serialize/describe-graph-trig.out
@@ -37,11 +37,11 @@ GRAPH <B> {
 }
 
 GRAPH <A> {
-  <a> rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, 
"http://tracker.api.gnome.org/ontology/v3/nie#InformationElement";, 
"http://tracker.api.gnome.org/ontology/v3/nfo#Media";, 
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicPiece"; .
+  <a> rdf:type rdfs:Resource, nie:InformationElement, nfo:Media, nmm:MusicPiece .
 }
 
 GRAPH <B> {
-  <a> rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, 
"http://tracker.api.gnome.org/ontology/v3/nie#InformationElement";, 
"http://tracker.api.gnome.org/ontology/v3/nfo#Media";, 
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicPiece"; .
+  <a> rdf:type rdfs:Resource, nie:InformationElement, nfo:Media, nmm:MusicPiece .
 
-  <b> rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, 
"http://tracker.api.gnome.org/ontology/v3/nie#InformationElement";, 
"http://tracker.api.gnome.org/ontology/v3/nfo#Media";, 
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicPiece"; .
+  <b> rdf:type rdfs:Resource, nie:InformationElement, nfo:Media, nmm:MusicPiece .
 }
diff --git a/tests/libtracker-sparql/serialize/describe-graph-ttl.out 
b/tests/libtracker-sparql/serialize/describe-graph-ttl.out
index 5d52de100..f6e9b5199 100644
--- a/tests/libtracker-sparql/serialize/describe-graph-ttl.out
+++ b/tests/libtracker-sparql/serialize/describe-graph-ttl.out
@@ -24,6 +24,6 @@
 
 
 
-<a> rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, 
"http://tracker.api.gnome.org/ontology/v3/nie#InformationElement";, 
"http://tracker.api.gnome.org/ontology/v3/nfo#Media";, 
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicPiece";, "http://www.w3.org/2000/01/rdf-schema#Resource";, 
"http://tracker.api.gnome.org/ontology/v3/nie#InformationElement";, 
"http://tracker.api.gnome.org/ontology/v3/nfo#Media";, 
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicPiece"; .
+<a> rdf:type rdfs:Resource, nie:InformationElement, nfo:Media, nmm:MusicPiece, rdfs:Resource, 
nie:InformationElement, nfo:Media, nmm:MusicPiece .
 
-<b> rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, 
"http://tracker.api.gnome.org/ontology/v3/nie#InformationElement";, 
"http://tracker.api.gnome.org/ontology/v3/nfo#Media";, 
"http://tracker.api.gnome.org/ontology/v3/nmm#MusicPiece"; .
+<b> rdf:type rdfs:Resource, nie:InformationElement, nfo:Media, nmm:MusicPiece .
diff --git a/tests/libtracker-sparql/serialize/describe-single-trig.out 
b/tests/libtracker-sparql/serialize/describe-single-trig.out
index 6e485625d..ec5667d31 100644
--- a/tests/libtracker-sparql/serialize/describe-single-trig.out
+++ b/tests/libtracker-sparql/serialize/describe-single-trig.out
@@ -18,5 +18,5 @@
   rdfs:Resource nrl:classSpecification "https://www.w3.org/TR/rdf-schema/#ch_resource"; ;
     rdfs:label "All Resources" ;
     rdfs:comment "All resources" ;
-    rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, "http://www.w3.org/2000/01/rdf-schema#Class"; .
+    rdf:type rdfs:Resource, rdfs:Class .
 }
diff --git a/tests/libtracker-sparql/serialize/describe-single-ttl.out 
b/tests/libtracker-sparql/serialize/describe-single-ttl.out
index fed9b04df..78b8ce55a 100644
--- a/tests/libtracker-sparql/serialize/describe-single-ttl.out
+++ b/tests/libtracker-sparql/serialize/describe-single-ttl.out
@@ -17,4 +17,4 @@
 rdfs:Resource nrl:classSpecification "https://www.w3.org/TR/rdf-schema/#ch_resource"; ;
   rdfs:label "All Resources" ;
   rdfs:comment "All resources" ;
-  rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, "http://www.w3.org/2000/01/rdf-schema#Class"; .
+  rdf:type rdfs:Resource, rdfs:Class .
diff --git a/tests/libtracker-sparql/serialize/describe-var-trig.out 
b/tests/libtracker-sparql/serialize/describe-var-trig.out
index f4a3af0e5..eb1ceda36 100644
--- a/tests/libtracker-sparql/serialize/describe-var-trig.out
+++ b/tests/libtracker-sparql/serialize/describe-var-trig.out
@@ -18,6 +18,6 @@
   rdfs:Class nrl:classSpecification "https://www.w3.org/TR/rdf-schema/#ch_class"; ;
     rdfs:label "Class" ;
     rdfs:comment "The class of classes" ;
-    rdfs:subClassOf "http://www.w3.org/2000/01/rdf-schema#Resource"; ;
-    rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, "http://www.w3.org/2000/01/rdf-schema#Class"; .
+    rdfs:subClassOf rdfs:Resource ;
+    rdf:type rdfs:Resource, rdfs:Class .
 }
diff --git a/tests/libtracker-sparql/serialize/describe-var-ttl.out 
b/tests/libtracker-sparql/serialize/describe-var-ttl.out
index 6718f7bed..8cd80c5d4 100644
--- a/tests/libtracker-sparql/serialize/describe-var-ttl.out
+++ b/tests/libtracker-sparql/serialize/describe-var-ttl.out
@@ -17,5 +17,5 @@
 rdfs:Class nrl:classSpecification "https://www.w3.org/TR/rdf-schema/#ch_class"; ;
   rdfs:label "Class" ;
   rdfs:comment "The class of classes" ;
-  rdfs:subClassOf "http://www.w3.org/2000/01/rdf-schema#Resource"; ;
-  rdf:type "http://www.w3.org/2000/01/rdf-schema#Resource";, "http://www.w3.org/2000/01/rdf-schema#Class"; .
+  rdfs:subClassOf rdfs:Resource ;
+  rdf:type rdfs:Resource, rdfs:Class .


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