Skip to content

Commit

Permalink
Register Extension Functions After Export (#565)
Browse files Browse the repository at this point in the history
- Added call to registerExtensionFunctions() after the database is reloaded during the exportDatabase() call.
- Added test for this scenario.
  • Loading branch information
dreblen authored Jan 12, 2024
1 parent 783bf12 commit ea6ae62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
var binaryDb = FS.readFile(this.filename, { encoding: "binary" });
this.handleError(sqlite3_open(this.filename, apiTemp));
this.db = getValue(apiTemp, "i32");
registerExtensionFunctions(this.db);
return binaryDb;
};

Expand Down
3 changes: 3 additions & 0 deletions test/test_extension_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ exports.test = function(sql, assert) {
var res = db.exec("SELECT reverse(str_data) FROM test;");
assert.equal(res[0]['values'][0][0], "!dlroW olleH", "reverse() function works");

db.export()
var res = db.exec("SELECT floor(4.1)");
assert.equal(res[0]['values'][0][0], 4, "extension function works after export()");
};

if (module == require.main) {
Expand Down

0 comments on commit ea6ae62

Please sign in to comment.