Closed alf closed 9 years ago
An additional reason why supporting both is good is that users can keep using their preferred variable marker in SPARQL and use the other one in ob-sparql.
This assumes of course that people don't mix '$' and '?' in the same query...
I seem to not have been very clear. I am sorry about that. What I meant was that you should use both keys that SPARQL uses, not a third one. E.g. if you have the query
#+BEGIN_SRC sparql :var x="friend:Julia"
SELECT * WHERE {
?x foaf:name ?name.
$x foaf:email ?email.
}
#+END_SRC
it becomes
SELECT * WHERE {
friend:Julia foaf:name ?name.
friend:Julia foaf:email ?email.
}
You replace both since they are identical in SPARQL.
Excellent, then we are in agreement.
Created new pull request for this: #35
Closed by #35
I'm implementing this and would like to discuss some details.
In my original pull request #32, I used '$' as the variable marker. The problem with this is that in SPARQL both '?' and '$' function as query variable markers and the variable '$var' is the exact same variable as the variable '?var'.
I've now changed the code to use '%' as the variable marker as mentioned in that pull request.
However, I'm wondering whether this is the correct choice for the following reasons:
In addition I'm wondering if it might actually be a feature that we use the same variable marker as used in SPARQL. The reason for this is that I can write a general query where I use variable ?x as an unbound. My query does not return quite what I'm interested in, so I decide to bind ?x to a known property to debug the query. Using org-babel I could then add
:var x="<prop>"
to replace?x
with<prop>
without changing the query. I could test different bindings for?x
by using#+call
etc.My new favourite solution is that we support both
?
and$
as variable markers.Note: The way variable substitution works is that we look for and replace only the variables declared in the
:var
header.