Last active
February 5, 2016 23:00
-
-
Save mcritchlow/8147aa8ad643f5f34f90 to your computer and use it in GitHub Desktop.
A proposed DSL syntax for SPARQL 1.1 VALUES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should support VALUES" do | |
# should support single value construct (less verbose form) | |
expect(subject.select | |
.where([:s, RDF::URI('http://purl.org/dc/terms/title'), :title]) | |
.values([:title], ["This title", "Another title"]).to_s) | |
.to eq "SELECT * WHERE { ?s <http://purl.org/dc/terms/title> ?o . VALUES ?title { 'This title' 'Another title' } }" | |
# should support single value construct (general form) | |
expect(subject.select | |
.where([:s, RDF::URI('http://purl.org/dc/terms/title'), :title]) | |
.values([:title], ["This title", "Another title"]).to_s) | |
.to eq "SELECT * WHERE { ?s <http://purl.org/dc/terms/title> ?o . VALUES (?title) { ('This title') ('Another title') } }" | |
# should support multiple values | |
expect(subject.select | |
.where([:s, RDF::URI('http://purl.org/dc/terms/title'), :title], [:s, RDF.type, :type]) | |
.values([:type, :title], [RDF::URI('http://pcdm.org/models#Object'), "This title"], [RDF::URI('http://pcdm.org/models#Collection', 'Another title']).to_s) | |
.to eq "SELECT * WHERE { ?s <http://purl.org/dc/terms/title> ?o . ?s a ?type . VALUES (?type ?title) { (<http://pcdm.org/models#Object> 'This title') (<http://pcdm.org/models#Collection> 'Another title' } }" | |
# should support UNDEF for any value | |
expect(subject.select | |
.where([:s, RDF::URI('http://purl.org/dc/terms/title'), :title], [:s, RDF.type, :type]) | |
.values([:type, :title], [UNDEF, "This title"], [RDF::URI('http://pcdm.org/models#Collection'), UNDEF]).to_s) | |
.to eq "SELECT * WHERE { ?s <http://purl.org/dc/terms/title> ?o . ?s a ?type . VALUES (?type ?title) { (UNDEF 'This title') (<http://pcdm.org/models#Collection> UNDEF) } }" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
re: ruby-rdf/sparql-client#37
Questions/thoughts:
SELECT * WHERE { ?s <http://purl.org/dc/terms/title> ?o . } } VALUES (?title) { ('This title') ('Another title')
Still thinking about how best to make this distinction in the DSL.