-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prepared quey now carry the original (unparsed) parameters #565
Conversation
hmm, i'm not sure i fully understand what you're trying to do here... wouldn't the following just work? Q = "SELECT * { ?x <http://example.org/prop> ?y }" I'm not per se against adding an Some other considerations: while python certainly allows this kind of "just add an attribute to some instance", it's not necessarily the best thing to do... |
I am confused, why is:
the case - that seems to be the bug here? If some other SPARQL engine messes up the preparedQuery - that is the problem of that SPARQL engine, that's why I clone here: 6200934#diff-8939ddb2af331e50406fdd945bf5fb2cR424 So when I insert the bindings into the algebra, the original prepared query remain unchanged. |
@joernhees of course, nothing forces me to prepare the query Q, but I would like to take advantage of the preparation (at least for stores that support it). @gromgull sorry if I was not clear. I'm using an implementation of Granted, my solution is quick hack which I thought had minimal impact (if at all) on the rest of the lib. It is true, however, that the I like @joernhees 's last proposal: having a way to reconstruct the SPARQL string for a |
Right - now I understand! The long-term solution is certainly being able to re-serialize a parsed query object, but this is probably a days work at least. (I wondered about this recently, when I then made this dirty hack: https://gist.github.com/gromgull/70e2d0500fbcb820dd99 instead) In the mean time - this is probably ok. Currently, there are no other ways to create a query object apart from through the parser logic - perhaps the parsed string should be saved there. (Perhaps it already is? :) ) |
* pull/565: indicate that original_args are private prepared quey now carry the original (unparsed) parameters
Here is my use case: I use prepareQuery in my code when a query is used several times. It looks like this:
This saves some time by parsing the query once an for all.
Except that... this works fine when
graph
uses the SPARQL processor shipped with RDFlib. But if I use a third-party Store, which has its own native implementation of SPARQL, Q is not usable anymore...The solution I found is to add an attribute to the object produced by
prepareQuery
, containing the original query string, so that alternative Store implementations can get the original query string and pass it to their own parser. Granted, in that case,prepareQuery
works for nothing, but at least the code above works regardless of the underlying store (and the spurious parsing is done only once, so it is not too bad).