diff --git a/docs/assets/search.js b/docs/assets/search.js index b18024e..e3a446d 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62bb2+cuBbGv4v7FnXjvyR5V/WqUqXVbnezt/tiFI0I4ySoDMwCM51u1O9+ZWCYc5hj4sB9mfY8fsC/x8aMzQuryu81u129sG9ZsWG34uom5lpErEi2lt2yuz9+zRr7sdzukiZ7yO1fP3aWRWxf5eyWNT92tv6FKnn/3GxzFrE0T+ra1uyWsZ/R4KHNqP2vn+6GRrOisdVjkg4tf/10N9kcvxJqaG97/JI0z7+5P15t8B0qBm1HbJdUtmjQ9YHrv1LXg+HxY17WIWZD4VyjP22yCfHp6+ba/F1lTdD9nArnGv1V7Ys0CfMCtXPt7n4UaYhVXzfX5lOW27vs36C7ArVz7X4t028hVn3dXJv/Fnmg0VA5ezw92/Tbn7a21cFuQm+PEi0h+LEsmqrMQyGey+ea/scestR+fE6qJG1sldVNltYh9j7h3Av5fWeLEN++bv795jZs6A+Vc60+pKmtg/pyqHyD1cWz7EtlneL3XZOVxYQtrgt/wu2LOi13duJRQLT8Dqimbm508Z5LeMyTp7fd2buTZJb5ZSd/+PLZ7//hy+fp9QeMx0NWbNZpmec2dbavt/ruUjF1U+5KJ6wD/ZaZrB/y8iH0zvraJXabcv+QTwxubDhUL7HMiibUrytdaGbUG+za4iWGxT6feBZhv752id0uqZKtbWy1Tst9eMdeyv4/F1FMruZ911C8vqx/7RIaewy++b52pl36nBRPdmJOHczOlXOtpt9XzkYBrytTNmW+34ZMp0PhIqPQKQ5XL7T80YQhw+XLTENH5Kh8mWnwhD6uX2YbNqmj4sWGQRP7qHyZaeD0hquXW74huafyZaaBsymuXmgJf6163bKrnmtZ2aSx68d9EbqQvFTMtN4kTRI8MaDimYb2aCd+Sxms+rKZJo9ZkeSTv6QMRqB0ptmTbdbJvinTcrvNQrrxQjDTOM8eDraqwxKDihcbrov99sFWb/I9a2b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7WyeFZbdru5//vwfKkXaW3Q/AAA="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62bW2/buBaF/4v6anRC8aIkb0UPChQYzHQmczoPRmAoMpMIlSWPJLvuBP3vB5Rva8ubCiOdx7R7cUn8FinKpF6iuvreRLfzl+hbXi6j2/jqJhE6nkVlurLRbXT3x695az9Wq3Xa5g+F/evH2kazaFMX0W3U/ljb5heu5P1zuyqiWZQVadPYJrqNop+zk4c2vfa/fro7NZqXra0f0+zU8tdPd4PNiatYndpb7b6k7fNv7o9XG3xHiqHtWbROa1u25Prg+q/U9clw97GomhCzU+FYoz9tugzxOdSNtfm7ztug+zkWjjX6q96UWRrmBbVj7e5+lFmI1aFurM2nvLB3+b9BdwW1Y+1+rbJvIVaHurE2/y2LQKNT5ejx9Gyzb3/axtZbuwy9PU40heDHqmzrqgiFeC4fa/ofu80z+/E5rdOstXXetHnWhNj7hGMv5Pe1LUN8D3Xj77ewYUP/VDnW6kOW2SaoL0+Vb7C6eJZ9qa1T/L5u86ocsKV14U+4Tdlk1doOPAqYlt+BaujmehfvuYTHIn162529O0pGmV928ocvn/3+H758Hl5/YDwe8nK5yKqisJmzfb3Vd5eKoZtyVzpgHeg3zWTxUFQPoXd2qJ1it6w2D8XA4KaGp+oplnnZhvrtSyeaGfUGu654imG5KQaeRdTvUDvFbp3W6cq2tl5k1Sa8Yy9l/5+LKAdX875rKF9f1r92Ca3dBd/8oXakXfaclk92YE49mZ0rx1oVNq0X7przcmgWPzv2BaONB1+UwO/196Qhm6rYrELm8VPhJKPQuZVWT7T80YZlhZZPMw2dCnrl00yDnyT9+mm2YU8TUjzZMOiJ0iufZho4r9Lq6ZZvSO6xfJpp4DROqyda4s9kr1vuq8da1jZt7eJxU4auYC8VI62XaZsGTwykeKSh3dmBH3FOVoeykSaPeZkWgz/hnIygdKTZk20X6aatsmq1ykO68UIw0rjIH7a2bsISQ4onGy7KzerB1m/yPWtG24f177FupE21tuViGwcYnStHWq3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4Pnq/we1ZAAAA="; \ No newline at end of file diff --git a/docs/interfaces/SQLiteAPI.html b/docs/interfaces/SQLiteAPI.html index c22d557..5243897 100644 --- a/docs/interfaces/SQLiteAPI.html +++ b/docs/interfaces/SQLiteAPI.html @@ -10,7 +10,7 @@
// Import an ES6 module factory function from one of the
// package builds, either 'wa-sqlite.mjs' (synchronous) or
// 'wa-sqlite-async.mjs' (asynchronous). You should only
// use the asynchronous build if you plan to use an
// asynchronous VFS or module.
import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';

// Import the Javascript API wrappers.
import * as SQLite from 'wa-sqlite';

// Use an async function to simplify Promise handling.
(async function() {
// Invoke the ES6 module factory to create the SQLite
// Emscripten module. This will fetch and compile the
// .wasm file.
const module = await SQLiteESMFactory();

// Use the module to build the API instance.
const sqlite3 = SQLite.Factory(module);

// Use the API to open and access a database.
const db = await sqlite3.open_v2('myDB');
...
})();

See

https://sqlite.org/c3ref/funclist.html

-
interface SQLiteAPI {
    bind(stmt, i, value): number;
    bind_blob(stmt, i, value): number;
    bind_collection(stmt, bindings): number;
    bind_double(stmt, i, value): number;
    bind_int(stmt, i, value): number;
    bind_int64(stmt, i, value): number;
    bind_null(stmt, i): number;
    bind_parameter_count(stmt): number;
    bind_parameter_name(stmt, i): string;
    bind_text(stmt, i, value): number;
    changes(db): number;
    close(db): Promise<number>;
    column(stmt, i): SQLiteCompatibleType;
    column_blob(stmt, i): Uint8Array;
    column_bytes(stmt, i): number;
    column_count(stmt): number;
    column_double(stmt, i): number;
    column_int(stmt, i): number;
    column_int64(stmt, i): bigint;
    column_name(stmt, i): string;
    column_names(stmt): string[];
    column_text(stmt, i): string;
    column_type(stmt, i): number;
    create_function(db, zFunctionName, nArg, eTextRep, pApp, xFunc?, xStep?, xFinal?): number;
    data_count(stmt): number;
    exec(db, zSQL, callback?): Promise<number>;
    finalize(stmt): Promise<number>;
    get_autocommit(db): number;
    libversion(): string;
    libversion_number(): number;
    limit(db, id, newVal): number;
    open_v2(zFilename, iFlags?, zVfs?): Promise<number>;
    progress_handler(db, nProgressOps, handler, userData): any;
    reset(stmt): Promise<number>;
    result(context, value): void;
    result_blob(context, value): void;
    result_double(context, value): void;
    result_int(context, value): void;
    result_int64(context, value): void;
    result_null(context): void;
    result_text(context, value): void;
    row(stmt): SQLiteCompatibleType[];
    set_authorizer(db, authFunction, userData): number;
    sql(stmt): string;
    statements(db, sql, options?): AsyncIterable<number>;
    step(stmt): Promise<number>;
    value(pValue): SQLiteCompatibleType;
    value_blob(pValue): Uint8Array;
    value_bytes(pValue): number;
    value_double(pValue): number;
    value_int(pValue): number;
    value_int64(pValue): bigint;
    value_text(pValue): string;
    value_type(pValue): number;
    vfs_register(vfs, makeDefault?): number;
}

Methods

interface SQLiteAPI {
    bind(stmt, i, value): number;
    bind_blob(stmt, i, value): number;
    bind_collection(stmt, bindings): number;
    bind_double(stmt, i, value): number;
    bind_int(stmt, i, value): number;
    bind_int64(stmt, i, value): number;
    bind_null(stmt, i): number;
    bind_parameter_count(stmt): number;
    bind_parameter_name(stmt, i): string;
    bind_text(stmt, i, value): number;
    changes(db): number;
    clear_bindings(stmt): number;
    close(db): Promise<number>;
    column(stmt, i): SQLiteCompatibleType;
    column_blob(stmt, i): Uint8Array;
    column_bytes(stmt, i): number;
    column_count(stmt): number;
    column_double(stmt, i): number;
    column_int(stmt, i): number;
    column_int64(stmt, i): bigint;
    column_name(stmt, i): string;
    column_names(stmt): string[];
    column_text(stmt, i): string;
    column_type(stmt, i): number;
    create_function(db, zFunctionName, nArg, eTextRep, pApp, xFunc?, xStep?, xFinal?): number;
    data_count(stmt): number;
    exec(db, zSQL, callback?): Promise<number>;
    finalize(stmt): Promise<number>;
    get_autocommit(db): number;
    libversion(): string;
    libversion_number(): number;
    limit(db, id, newVal): number;
    open_v2(zFilename, iFlags?, zVfs?): Promise<number>;
    progress_handler(db, nProgressOps, handler, userData): any;
    reset(stmt): Promise<number>;
    result(context, value): void;
    result_blob(context, value): void;
    result_double(context, value): void;
    result_int(context, value): void;
    result_int64(context, value): void;
    result_null(context): void;
    result_text(context, value): void;
    row(stmt): SQLiteCompatibleType[];
    set_authorizer(db, authFunction, userData): number;
    sql(stmt): string;
    statements(db, sql, options?): AsyncIterable<number>;
    step(stmt): Promise<number>;
    value(pValue): SQLiteCompatibleType;
    value_blob(pValue): Uint8Array;
    value_bytes(pValue): number;
    value_double(pValue): number;
    value_int(pValue): number;
    value_int64(pValue): bigint;
    value_text(pValue): string;
    value_type(pValue): number;
    vfs_register(vfs, makeDefault?): number;
}

Methods

Parameters

  • db: any

    database pointer

Returns number

number of rows modified

  • Close database connection

    Parameters

    • db: any

      database pointer

    Returns Promise<number>

    SQLITE_OK (throws exception on error)

    @@ -366,4 +371,4 @@

Parameters

  • vfs: SQLiteVFS

    VFS object

  • Optional makeDefault: boolean

Returns number

SQLITE_OK (throws exception on error)

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/src/sqlite-api.js b/src/sqlite-api.js index 37cf8d0..2d29f90 100644 --- a/src/sqlite-api.js +++ b/src/sqlite-api.js @@ -236,6 +236,16 @@ export function Factory(Module) { }; })(); + sqlite3.clear_bindings = (function() { + const fname = 'sqlite3_clear_bindings'; + const f = Module.cwrap(fname, ...decl('n:n')); + return function(stmt) { + verifyStatement(stmt); + const result = f(stmt); + return check(fname, result, mapStmtToDB.get(stmt)); + }; + })(); + sqlite3.close = (function() { const fname = 'sqlite3_close'; const f = Module.cwrap(fname, ...decl('n:n'), { async }); diff --git a/src/types/index.d.ts b/src/types/index.d.ts index e39b92f..31a5985 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -330,6 +330,14 @@ declare interface SQLiteAPI { */ changes(db): number; + /** + * Reset all bindings on a prepared statement. + * @see https://www.sqlite.org/c3ref/clear_bindings.html + * @param stmt prepared statement pointer + * @returns `SQLITE_OK` (throws exception on error) + */ + clear_bindings(stmt: number): number; + /** * Close database connection * @see https://www.sqlite.org/c3ref/close.html diff --git a/test/api_statements.js b/test/api_statements.js index 9a3d568..d3f76d9 100644 --- a/test/api_statements.js +++ b/test/api_statements.js @@ -366,6 +366,41 @@ export function api_statements(context) { rc = await sqlite3.finalize(stmt); expect(rc).toEqual(SQLite.SQLITE_OK); }); + + it('should clear bindings', async function() { + let rc; + + const sql = 'SELECT ?'; + for await (const stmt of i(sqlite3.statements(db, sql))) { + { + rc = await sqlite3.bind_int(stmt, 1, 42); + expect(rc).toEqual(SQLite.SQLITE_OK); + + rc = await sqlite3.reset(stmt); + expect(rc).toEqual(SQLite.SQLITE_OK); + + rc = await sqlite3.step(stmt); + expect(rc).toEqual(SQLite.SQLITE_ROW); + + const value = await sqlite3.column(stmt, 0); + expect(value).toEqual(42); + } + + { + rc = await sqlite3.clear_bindings(stmt); + expect(rc).toEqual(SQLite.SQLITE_OK); + + rc = await sqlite3.reset(stmt); + expect(rc).toEqual(SQLite.SQLITE_OK); + + rc = await sqlite3.step(stmt); + expect(rc).toEqual(SQLite.SQLITE_ROW); + + const value = await sqlite3.column(stmt, 0); + expect(value).not.toEqual(42); + } + } + }); }); }