Skip to content
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

Query string cannot be empty error when attempting to issue an update! in a transaction #175

Open
RickMoynihan opened this issue Jan 25, 2021 · 0 comments

Comments

@RickMoynihan
Copy link
Member

Creating a transaction on a grafter/rdf4j sparql-repo and then calling update! yeilds an error:

user> (require 'grafter-2.rdf4j.repository)
;; => nil
user> (def repo (grafter-2.rdf4j.repository/sparql-repo "http://localhost:5820/test-db/query" "http://localhost:5820/test-db/update"))
;; => #'user/repo
user> (def conn (grafter-2.rdf4j.repository/->connection repo))
;; => #'user/conn
user> (grafter-2.rdf.protocols/begin conn)
;; => nil
user> (grafter-2.rdf.protocols/update! conn "INSERT DATA { <http://foo-4> <http://bar-1> <http://baz-1> . }")
;; => nil
user> (grafter-2.rdf.protocols/commit conn)
[nRepl-session-9a2d78ce-51e6-4c7d-86f9-771ddf06d921] WARN org.eclipse.rdf4j.http.client.SharedHttpClientSessionManager$2 - Server reports problem: {"message":"Query string cannot be empty"}

This is because RDF4j's SPARQLRepository class only considers direct add/delete operations on the connection to be part of the transaction, whilst the update! operation is sent immediately (outside of the transaction).

This means that when the transaction is commited it is empty and hence you have no "query string" (transaction data).

e.g. this does not error:

user> (def repo (grafter-2.rdf4j.repository/sparql-repo "http://localhost:5820/test-xsd/query" "http://localhost:5820/test-xsd/update"))
;; => #'user/repo
user> (def conn (grafter-2.rdf4j.repository/->connection repo))
;; => #'user/conn
user> (grafter-2.rdf.protocols/begin conn)
;; => nil
user> (grafter-2.rdf.protocols/add conn [(grafter-2.rdf.protocols/->Triple (java.net.URI. "http://foo") (java.net.URI. "http://foo") (java.net.URI. "http://foo"))])
;; => #object[org.eclipse.rdf4j.repository.sparql.SPARQLConnection 0x29c02d3b "http://localhost:5820/test-xsd/query"]
user> (grafter-2.rdf.protocols/update! conn "INSERT DATA { <http://foo-5> <http://bar-1> <http://baz-1> . }")
;; => nil
user> (grafter-2.rdf.protocols/commit conn)

However the update! call occured before the addition of the triple (outside the transaction).

These problems exist in the RDF4j implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant