mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add missing sqlite3_bind_parameter_name() binding to JS.
FossilOrigin-Name: 6dcfcc7e1c0772b11aec750bb75899a5c8e452735ecf5028c001fbaa7aa6fda0
This commit is contained in:
@ -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
|
||||
|
@ -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", [
|
||||
|
@ -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*/;
|
||||
|
||||
|
@ -2063,15 +2063,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
"Because foo is no longer attached.");
|
||||
})
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
.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") );
|
||||
@ -3222,6 +3213,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({
|
||||
|
Reference in New Issue
Block a user