dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

Provide a way to access `columns()` when a query result is empty #135

Closed lodry closed 3 years ago

lodry commented 3 years ago

result.columns() triggers error when there is no results for query

dyedgreen commented 3 years ago

This is the expected behavior, and results from the Rows object automatically cleaning up any statements which have completed.

I believe a good solution here might be to add the columns to the prepared query interface instead (since with a prepared query, the user is responsible for finalizing the statements, meaning the statement would still be available).

If something like this is added, it would also make sense to remove / deprecate the columns accessor on the Rows class.

dyedgreen commented 3 years ago

You can also use .columns() on a prepared query, which doesn't require a non empty result and is available in the latest tagged version and on master.