Feature Request: Implement `Disposable` for `PreparedQuery`
Opened this issue · 0 comments
NfNitLoop commented
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/dispose@1.0.1/mod.ts"