summaryrefslogtreecommitdiff
path: root/rdflib/tools
diff options
context:
space:
mode:
authorHan Kruiger <HanKruiger@users.noreply.github.com>2023-03-14 00:40:48 +0100
committerGitHub <noreply@github.com>2023-03-14 00:40:48 +0100
commit60d98dbbf781371efd74de7d525443a11daa622e (patch)
tree23678004e27a51559ea193b9a8e39a1b4113d8af /rdflib/tools
parentf17f97516991b43cafc320c612a353c591201bca (diff)
downloadrdflib-60d98dbbf781371efd74de7d525443a11daa622e.tar.gz
fix: correctly handle resources with multiple comments in defined_namespace_creator (#2254)
FIxed a bug in defined_namespace_creator so that when a resource in an ontology is commented on multiple times (with e.g. rdfs:comment), it creates only a single class variable in the resulting DefinedNamespace where the Python comment is the concatenation of the rdfs:comments.
Diffstat (limited to 'rdflib/tools')
-rw-r--r--rdflib/tools/defined_namespace_creator.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/rdflib/tools/defined_namespace_creator.py b/rdflib/tools/defined_namespace_creator.py
index 0c93ea75..1076cd6e 100644
--- a/rdflib/tools/defined_namespace_creator.py
+++ b/rdflib/tools/defined_namespace_creator.py
@@ -77,7 +77,7 @@ def get_target_namespace_elements(
) -> Tuple[List[Tuple[str, str]], List[str]]:
namespaces = {"dcterms": DCTERMS, "owl": OWL, "rdfs": RDFS, "skos": SKOS}
q = """
- SELECT DISTINCT ?s ?def
+ SELECT ?s (GROUP_CONCAT(DISTINCT STR(?def)) AS ?defs)
WHERE {
# all things in the RDF data (anything RDF.type...)
?s a ?o .
@@ -90,6 +90,7 @@ def get_target_namespace_elements(
# only get results for the target namespace (supplied by user)
FILTER STRSTARTS(STR(?s), "xxx")
}
+ GROUP BY ?s
""".replace(
"xxx", target_namespace
)