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/Write protocols should not be extended to Repository (only RepositoryConnection) #109

Closed
RickMoynihan opened this issue Jul 20, 2017 · 0 comments

Comments

@RickMoynihan
Copy link
Member

RickMoynihan commented Jul 20, 2017

For convenience at a REPL we've always allowed you to call query etc on a Repository object directly. However doing so leaks a RepositoryConnection resource, which can cause serious and hard to find bugs in production.

We should remove the extensions of these functions to Repository, and instead raise an error telling people to change to call the function on the result of (->connection repo) not repo itself, and wrap in a with-open

This has been a common bug in code, hopefully this will improve the situation; though we also need to encourage more eager processing of queries (See #104).

RickMoynihan added a commit that referenced this issue Jul 20, 2017
Clients who receive this exception should adopt a pattern migrating
code from this:

(let [repo (repo)]
  (query repo "select * where { ?s ?p ?o .} limit 10")
  )

To something more like this:

(let [repo (repo)]
  (with-open [conn (->connection repo)]
    (doall (query conn "select * where { ?s ?p ?o . } limit 10"))))

We plan to add more eager APIs to assist with this in the future.
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