diff options
Diffstat (limited to 'ext/wasm')
-rw-r--r-- | ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api | 1 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-api-glue.c-pp.js | 1 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-api-oo1.c-pp.js | 13 | ||||
-rw-r--r-- | ext/wasm/tester1.c-pp.js | 37 |
4 files changed, 43 insertions, 9 deletions
diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api index c2dedfd57..dc6211ccb 100644 --- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api +++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api @@ -10,6 +10,7 @@ _sqlite3_bind_int64 _sqlite3_bind_null _sqlite3_bind_parameter_count _sqlite3_bind_parameter_index +_sqlite3_bind_parameter_name _sqlite3_bind_pointer _sqlite3_bind_text _sqlite3_busy_handler diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js index d3ea8a35a..2c40f2100 100644 --- a/ext/wasm/api/sqlite3-api-glue.c-pp.js +++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js @@ -95,6 +95,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ ["sqlite3_bind_null",undefined, "sqlite3_stmt*", "int"], ["sqlite3_bind_parameter_count", "int", "sqlite3_stmt*"], ["sqlite3_bind_parameter_index","int", "sqlite3_stmt*", "string"], + ["sqlite3_bind_parameter_name", "string", "sqlite3_stmt*", "int"], ["sqlite3_bind_pointer", "int", "sqlite3_stmt*", "int", "*", "string:static", "*"], ["sqlite3_busy_handler","int", [ diff --git a/ext/wasm/api/sqlite3-api-oo1.c-pp.js b/ext/wasm/api/sqlite3-api-oo1.c-pp.js index e557cbd57..0b9bbbbca 100644 --- a/ext/wasm/api/sqlite3-api-oo1.c-pp.js +++ b/ext/wasm/api/sqlite3-api-oo1.c-pp.js @@ -2030,6 +2030,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ return (affirmStmtOpen(this).parameterCount ? capi.sqlite3_bind_parameter_index(this.pointer, name) : undefined); + }, + /** + If this statement has named bindable parameters and the given + index refers to one, its name is returned, else null is + returned. If this statement has no bound parameters, undefined + is returned. + + Added in 3.47. + */ + getParamName: function(ndx){ + return (affirmStmtOpen(this).parameterCount + ? capi.sqlite3_bind_parameter_name(this.pointer, ndx) + : undefined); } }/*Stmt.prototype*/; diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 4ebe8f83a..a6befb54e 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2064,15 +2064,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule; }) //////////////////////////////////////////////////////////////////// - .t("Interrupt", function(sqlite3){ - const db = new sqlite3.oo1.DB(); - T.assert( 0===capi.sqlite3_is_interrupted(db) ); - capi.sqlite3_interrupt(db); - T.assert( 0!==capi.sqlite3_is_interrupted(db) ); - db.close(); - }) - - //////////////////////////////////////////////////////////////////// .t("Read-only", function(sqlite3){ T.assert( 0===capi.sqlite3_db_readonly(this.db, "main") ); const db = new sqlite3.oo1.DB('file://'+this.db.filename+'?mode=ro'); @@ -3223,6 +3214,34 @@ globalThis.sqlite3InitModule = sqlite3InitModule; }/*OPFS SAH Pool sanity checks*/) //////////////////////////////////////////////////////////////////////// + T.g('Misc. APIs') + .t('bind_parameter', function(sqlite3){ + const db = new sqlite3.oo1.DB(); + db.exec("create table t(a)"); + const stmt = db.prepare("insert into t(a) values($a)"); + T.assert( 1===capi.sqlite3_bind_parameter_count(stmt) ) + .assert( 1===capi.sqlite3_bind_parameter_index(stmt, "$a") ) + .assert( 0===capi.sqlite3_bind_parameter_index(stmt, ":a") ) + .assert( 1===stmt.getParamIndex("$a") ) + .assert( 0===stmt.getParamIndex(":a") ) + .assert( "$a"===capi.sqlite3_bind_parameter_name(stmt, 1) ) + .assert( null===capi.sqlite3_bind_parameter_name(stmt, 0) ) + .assert( "$a"===stmt.getParamName(1) ) + .assert( null===stmt.getParamName(0) ); + stmt.finalize(); + db.close(); + }) + + //////////////////////////////////////////////////////////////////// + .t("interrupt", function(sqlite3){ + const db = new sqlite3.oo1.DB(); + T.assert( 0===capi.sqlite3_is_interrupted(db) ); + capi.sqlite3_interrupt(db); + T.assert( 0!==capi.sqlite3_is_interrupted(db) ); + db.close(); + }) + + //////////////////////////////////////////////////////////////////////// T.g('Bug Reports') .t({ name: 'Delete via bound parameter in subquery', |