diff options
author | stephan <stephan@noemail.net> | 2022-09-27 09:17:37 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-27 09:17:37 +0000 |
commit | 3d64548491f6e95854b843f978a4ada16eff614c (patch) | |
tree | 23fda2d6c089dcfd00799e6b96624688d18634f5 /ext/wasm/api/sqlite3-api-oo1.js | |
parent | 278d3faf1ffa6bbd14253865edba3e81631d0cb5 (diff) | |
download | sqlite-3d64548491f6e95854b843f978a4ada16eff614c.tar.gz sqlite-3d64548491f6e95854b843f978a4ada16eff614c.zip |
wasm/js: rename /persistent to /opfs to account for potential future persistent storage options. Minor flag-handling cleanups in the speedtest1 pages. Minor API tweaks in oo1.
FossilOrigin-Name: 4dc972a3656b2a9ec915bfb3f653136560c753ce4024c3f0d0d0c28f66db7a0a
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-oo1.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index e0f812baa..4f7ffe1cd 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -495,24 +495,25 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ } }, /** - Similar to this.filename but will return a falsy value for - special names like ":memory:". Throws if the DB has been - closed. If passed an argument it then it will return the + Similar to the this.filename property but will return a falsy + value for special names like ":memory:". Throws if the DB has + been closed. If passed an argument it then it will return the filename of the ATTACHEd db with that name, else it assumes a - name of `main`. + name of `main`. The argument may be either a JS string or + a pointer to a WASM-allocated C-string. */ getFilename: function(dbName='main'){ return capi.sqlite3_db_filename(affirmDbOpen(this).pointer, dbName); }, /** Returns true if this db instance has a name which resolves to a - file. If the name is "" or ":memory:", it resolves to false. + file. If the name is "" or starts with ":", it resolves to false. Note that it is not aware of the peculiarities of URI-style names and a URI-style name for a ":memory:" db will fool it. Returns false if this db is closed. */ hasFilename: function(){ - return this.filename && ':memory'!==this.filename; + return this.filename && ':'!==this.filename[0]; }, /** Returns the name of the given 0-based db number, as documented @@ -525,9 +526,13 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ Compiles the given SQL and returns a prepared Stmt. This is the only way to create new Stmt objects. Throws on error. - The given SQL must be a string, a Uint8Array holding SQL, or a - WASM pointer to memory holding the NUL-terminated SQL string. - If the SQL contains no statements, an SQLite3Error is thrown. + The given SQL must be a string, a Uint8Array holding SQL, a + WASM pointer to memory holding the NUL-terminated SQL string, + or an array of strings. In the latter case, the array is + concatenated together, with no separators, to form the SQL + string (arrays are often a convenient way to formulate long + statements). If the SQL contains no statements, an + SQLite3Error is thrown. Design note: the C API permits empty SQL, reporting it as a 0 result code and a NULL stmt pointer. Supporting that case here @@ -541,6 +546,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ */ prepare: function(sql){ affirmDbOpen(this); + if(Array.isArray(sql)) sql = sql.join(''); const stack = capi.wasm.scopedAllocPush(); let ppStmt, pStmt; try{ |