summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoern Hees <dev@joernhees.de>2015-10-24 14:09:19 +0200
committerJoern Hees <dev@joernhees.de>2015-10-24 14:09:19 +0200
commita4002e3c502126cc82362e875fe61ce717912e6a (patch)
tree2f2e36125cf079188dd0a2a9a71c04de5b2b1197
parente1d0002fe699149865d8fa33937fa93806f4652a (diff)
downloadrdflib-a4002e3c502126cc82362e875fe61ce717912e6a.tar.gz
SPARQL can now compare xsd:date type as well, fixes #532
-rw-r--r--rdflib/plugins/sparql/datatypes.py2
-rw-r--r--test/test_issue532.py52
2 files changed, 53 insertions, 1 deletions
diff --git a/rdflib/plugins/sparql/datatypes.py b/rdflib/plugins/sparql/datatypes.py
index 82c21a91..be2351e2 100644
--- a/rdflib/plugins/sparql/datatypes.py
+++ b/rdflib/plugins/sparql/datatypes.py
@@ -9,7 +9,7 @@ XSD_DTs = set(
XSD.boolean, XSD.dateTime, XSD.nonPositiveInteger, XSD.negativeInteger,
XSD.long, XSD.int, XSD.short, XSD.byte, XSD.nonNegativeInteger,
XSD.unsignedLong, XSD.unsignedInt, XSD.unsignedShort, XSD.unsignedByte,
- XSD.positiveInteger))
+ XSD.positiveInteger, XSD.date))
_sub_types = {
XSD.integer: [
diff --git a/test/test_issue532.py b/test/test_issue532.py
new file mode 100644
index 00000000..3a745bc6
--- /dev/null
+++ b/test/test_issue532.py
@@ -0,0 +1,52 @@
+# test for https://github.com/RDFLib/rdflib/issues/532
+
+from rdflib import Graph
+
+data = """
+@base <http://purl.org/linkedpolitics/MembersOfParliament_background> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix lpv: <vocabulary/> .
+@prefix NationalParty: <NationalParty/> .
+
+<EUmember_1026>
+ a lpv:MemberOfParliament ;
+ lpv:MEP_ID "1026" ;
+ lpv:countryOfRepresentation <EUCountry_FR> ;
+ lpv:dateOfBirth "1946-07-13"^^xsd:date ;
+ lpv:politicalFunction [
+ a lpv:PoliticalFunction ;
+ lpv:beginning "1989-10-13"^^xsd:date ;
+ lpv:end "1992-01-14"^^xsd:date ;
+ lpv:institution NationalParty:sans_etiquette
+ ] , [
+ a lpv:PoliticalFunction ;
+ lpv:beginning "2005-02-24"^^xsd:date ;
+ lpv:end "2007-01-30"^^xsd:date ;
+ lpv:institution NationalParty:Union_pour_la_democratie_francaise
+ ] ;
+ foaf:familyName "Bourlanges" ;
+ foaf:givenName "Jean-Louis" .
+"""
+
+g = Graph()
+g.parse(data=data, format='n3')
+
+getnewMeps ="""
+PREFIX lpv: <http://purl.org/linkedpolitics/vocabulary/>
+prefix foaf: <http://xmlns.com/foaf/0.1/>
+prefix xsd: <http://www.w3.org/2001/XMLSchema#>
+
+SELECT DISTINCT ?name ?lastname WHERE {
+ ?member a lpv:MemberOfParliament .
+ ?member foaf:givenName ?name .
+ ?member foaf:familyName ?lastname .
+ ?member lpv:politicalFunction ?function .
+ ?function lpv:beginning ?date .
+
+ FILTER (?date >= "2004-06-20"^^xsd:date)
+}
+"""
+
+result = list(g.query(getnewMeps))
+assert len(result) == 1