sqlite: add StatementSync.prototype.close() and [Symbol.dispose]()#64232
sqlite: add StatementSync.prototype.close() and [Symbol.dispose]()#64232araujogui wants to merge 3 commits into
Conversation
This extends explicit resource management support to prepared statements, allowing a StatementSync to be deterministically finalized via a `using` declaration, mirroring the existing DatabaseSync and Session dispose methods. Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
|
Review requested:
|
|
We are currently finalizing statements when the wrapper is deconstructed after GC. This PR only makes sense if we are going to change this to an explicit "user should finalize statements themselves" model, in which case we should also expose a named |
I think we can support both approaches. I don't see any issue with that. We can either let the GC finalize statements as they are today, or let users finalize them explicitly with a |
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Expose an explicit close() method on StatementSync that finalizes the prepared statement, mirroring DatabaseSync.prototype.close(). Unlike Symbol.dispose, close() throws if the statement is already finalized, so Dispose() is reintroduced as a thin wrapper that swallows that exception to keep statement[Symbol.dispose]() a no-op on an already-finalized statement. Also add "throws if the statement is already finalized" test coverage for get(), all(), iterate(), run(), sourceSQL, expandedSQL, setReadBigInts(), setReturnArrays(), setAllowBareNamedParameters(), and setAllowUnknownNamedParameters(), matching the check already present in each of these methods' native implementation. These tests use in-memory databases with `using` declarations for explicit resource management, matching the convention used by the neighboring Symbol.dispose() suite. Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
No description provided.