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

Feature Request: Implement Disposable for PreparedQuery #257

Open
NfNitLoop opened this issue Feb 21, 2024 · 0 comments
Open

Feature Request: Implement Disposable for PreparedQuery #257

NfNitLoop opened this issue Feb 21, 2024 · 0 comments

Comments

@NfNitLoop
Copy link

NfNitLoop commented Feb 21, 2024

Docs for PreparedQuery.finalize() say:

This must be called once the query is no longer needed to avoid leaking resources.

So users need to write something like:

const pq = connection.prepareQuery(query);
try {
    // ...
} finally {
    pq.finalize()
}

But, if it were to implement Disposable, then users would only need to write:

using pq = connection.prepareQuery(query);
// ...

Workaround:

In the meantime, users can explicitly defer a call to finalize like this:

const pq = connection.prepareQuery(query);
using stack = new DisposableStack();
stack.defer(() => pq.finalize());

// ...

Note that until this issue is resolved, you will also need to explicitly:

import { DisposableStack } from "https://deno.land/x/[email protected]/mod.ts"
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