diff options
author | stephan <stephan@noemail.net> | 2022-12-09 12:12:49 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-12-09 12:12:49 +0000 |
commit | 3ec44736b51d1f8ed7239654e1ee891e93fd7577 (patch) | |
tree | c3a0b2e954bfe3565ec52cfb5474445be95b906e /ext/wasm/tester1.c-pp.js | |
parent | 81a368317456d9c1500e33949b214185e1e0b565 (diff) | |
download | sqlite-3ec44736b51d1f8ed7239654e1ee891e93fd7577.tar.gz sqlite-3ec44736b51d1f8ed7239654e1ee891e93fd7577.zip |
Remove some unused sqlite3_status() codes from the JS API. Add custom JS wrappers for sqlite3_create_collation/_v2() which accept JS functions (plus tests). Expand the argument options for sqlite3_wasm_db_error() to enable it to translate exception objects to C-level errors.
FossilOrigin-Name: 073a2f1eb006230ae0995a5ea6c789407bcaa819ec15b5064c66d8973ed4671a
Diffstat (limited to 'ext/wasm/tester1.c-pp.js')
-rw-r--r-- | ext/wasm/tester1.c-pp.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index ddf60def9..1dc58983f 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -2106,6 +2106,29 @@ self.sqlite3InitModule = sqlite3InitModule; .assert(2000===list[0][1]); } })/*custom vtab #2*/ + //////////////////////////////////////////////////////////////////////// + .t('Custom collation', function(sqlite3){ + let myCmp = function(pArg,n1,p1,n2,p2){ + //int (*)(void*,int,const void*,int,const void*) + const rc = wasm.exports.sqlite3_strnicmp(p1,p2,(n1<n2?n1:n2)); + return rc ? rc : (n1 - n2); + }; + let rc = capi.sqlite3_create_collation_v2(this.db, "mycollation", capi.SQLITE_UTF8, + 0, myCmp, 0); + this.db.checkRc(rc); + rc = this.db.selectValue("select 'hi' = 'HI' collate mycollation"); + T.assert(1===rc); + rc = this.db.selectValue("select 'hii' = 'HI' collate mycollation"); + T.assert(0===rc); + rc = this.db.selectValue("select 'hi' = 'HIi' collate mycollation"); + T.assert(0===rc); + rc = capi.sqlite3_create_collation(this.db,"hi",capi.SQLITE_UTF8/*not enough args*/); + T.assert(capi.SQLITE_MISUSE === rc); + rc = capi.sqlite3_create_collation_v2(this.db,"hi",0/*wrong encoding*/,0,0,0); + T.assert(capi.SQLITE_FORMAT === rc) + .mustThrowMatching(()=>this.db.checkRc(rc), + /SQLITE_UTF8 is the only supported encoding./); + }) //////////////////////////////////////////////////////////////////////// .t('Close db', function(){ |