dyedgreen / deno-sqlite

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

store all executed sql statement (as options) #212

Closed elycheikhsmail closed 1 year ago

elycheikhsmail commented 1 year ago

debuging sql always hard, I suggess to add option for saving all sql statement befor execute them in some table(middlwear) something similar to the following code :

export { DB } from "https://deno.land/x/sqlite/mod.ts"; 
const db = new DB("test.db");
db.options({saveSqlStatementBeforExecute:true}) // defaut false

in this way it will be easy to debeug: for example if some params omitted...

dyedgreen commented 1 year ago

I don't think something like this belongs into this library. If you need to debug your queries, you can always just log them / store them in user code.

elycheikhsmail commented 1 year ago

I don't think something like this belongs into this library. If you need to debug your queries, you can always just log them / store them in user code.

I don't know how get sql statement prepared by prepareQuery

dyedgreen commented 1 year ago

It's just the exact string you pass into db.prepareQuery. Things like bindings (e.g. as in SELECT * FROM foo WHERE bar = ? are handled by SQLite directly, so the query is just that string.)