--- a/spa2rql.py Wed Jul 22 19:42:10 2009 +0200
+++ b/spa2rql.py Wed Jul 22 19:42:35 2009 +0200
@@ -45,6 +45,8 @@
unions = zip(*make_domains([unions, thisunions]))
baserql = 'Any %s WHERE %s' % (', '.join(self.selection),
', '.join(self.restrictions))
+ if self.sparqlst.distinct:
+ baserql = 'DISTINCT ' + baserql
if not unions:
return baserql
rqls = ['(%s, %s)' % (baserql, ', '.join(unionrestrs))
--- a/test/unittest_spa2rql.py Wed Jul 22 19:42:10 2009 +0200
+++ b/test/unittest_spa2rql.py Wed Jul 22 19:42:35 2009 +0200
@@ -41,6 +41,24 @@
doap:created ?created.
}''', 'Any CREATED WHERE PROJECT creation_date CREATED, PROJECT is Project')
+ def test_base_attr_sel_distinct(self):
+ self._test('''
+ PREFIX doap: <http://usefulinc.com/ns/doap#>
+ SELECT DISTINCT ?name
+ WHERE {
+ ?project a doap:Project;
+ doap:name ?name.
+ }''', 'DISTINCT Any NAME WHERE PROJECT name NAME, PROJECT is Project')
+
+ def test_base_attr_sel_reduced(self):
+ self._test('''
+ PREFIX doap: <http://usefulinc.com/ns/doap#>
+ SELECT REDUCED ?name
+ WHERE {
+ ?project a doap:Project;
+ doap:name ?name.
+ }''', 'Any NAME WHERE PROJECT name NAME, PROJECT is Project')
+
def test_base_any_attr_sel(self):
self._test('''