Skip to content

Instantly share code, notes, and snippets.

@antho1404
Last active December 19, 2015 01:18
Show Gist options
  • Save antho1404/5874528 to your computer and use it in GitHub Desktop.
Save antho1404/5874528 to your computer and use it in GitHub Desktop.
This script permits to debug websql queries
websql_query_debug = (db) ->
# replace transaction method needed to have transaction object
db.old_transaction = db.transaction
db.transaction = (callback) =>
db.old_transaction (tx) =>
# replace sql method and include log
tx.old_executeSql = tx.executeSql
tx.executeSql = (sql, values, success, error) =>
log = sql
for val in values
log = log.replace "?", val
console.log log # display the executed sql with values replaced
tx.old_executeSql sql, values, success, error
callback tx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment